title: Reading text files in a dll file
body: <h1>The Setup</h1>
  <p><em>Microsoft Visual Studio Professional 2015</em>, running on <em>Windows 10 Pro</em><br />
  <em>Unity 5.3.1f1 (x64)</em><br />
  The project is built upon an example project provided by Unity on their <a href="http://docs.unity3d.com/Manual/NativePluginInterface.html" rel="nofollow noreferrer">site.</a> The project can be found <a href="http://docs.unity3d.com/uploads/Examples/RenderingPluginExample53.zip" rel="nofollow noreferrer">here.</a></p>
  <hr />
  <h1>That which needs to be done</h1>
  <p>I'm looking into creating a opengl plugin (in the form of a dll) for use with Unity. In their example code the <strong>vertex</strong> and <strong>fragment</strong> shaders are hard coded in the code like so:</p>
  <pre><code>#define VPROG_SRC(ver, attr, varying)                               \
      ver                                                             \
      attr &quot; highp vec3 pos;\n&quot;                                       \
      attr &quot; lowp vec4 color;\n&quot;                                      \
      &quot;\n&quot;                                                            \
      varying &quot; lowp vec4 ocolor;\n&quot;                                  \
      &quot;\n&quot;                                                            \
      &quot;uniform highp mat4 worldMatrix;\n&quot;                             \
      &quot;uniform highp mat4 projMatrix;\n&quot;                              \
      &quot;\n&quot;                                                            \
      &quot;void main()\n&quot;                                                 \
      &quot;{\n&quot;                                                           \
      &quot;   gl_Position = (projMatrix * worldMatrix) * vec4(pos,1);\n&quot;  \
      &quot;   ocolor = color;\n&quot;                                          \
      &quot;}\n&quot;                                                           \
  </code></pre>
  <p>I don't like this approach and I don't need it's flexibility. So I wanted to put each shader in their own file and load the file using the following piece of code.</p>
  <pre><code>const char* ShaderLoader::ReadShader(char *filename)
  {
      std::string shaderCode;
      std::ifstream file(filename, std::ios::in);
  
      if (!file.good())
      {
          std::cout &lt;&lt; &quot;Can't read file &quot; &lt;&lt; filename &lt;&lt; std::endl;
          return nullptr;
      }
  
      file.seekg(0, std::ios::end);
      shaderCode.resize((unsigned int)file.tellg());
      file.seekg(0, std::ios::beg);
      file.read(&amp;shaderCode[0], shaderCode.size());
      file.close();
  
      return shaderCode.c_str();
  }
  </code></pre>
  <hr />
  <h1>The Problem</h1>
  <p>The output of my project is a <strong>.dll</strong> file and I wanted my two shaders included in that file, where they could be loaded. Maybe this is not possible, I don't know.<br />
  I've added the shaders to the project. I've also right clicked each file and chosen <em>Include In Project</em>.</p>
  <p>I don't where the two files end up. Are they included in the <strong>dll</strong> file and if so what path do I need to pass to <code>ShaderLoader::ReadShader</code> to read them?</p>
  <p>I've tried to figure that out by using <code>GetModuleFileName</code> and <code>FindFirstFile</code> but to no success.</p>
  <p>So ultimately the question is: <strong>Is it possible to include text files in dll libraries built with Visual Studio and if so how do I go about it?</strong></p>