Note that there are some explanatory texts on larger screens.

plurals
  1. POMultiple resources returned in resource.rc file
    primarykey
    data
    text
    <p>Ok, I think I know what is wrong, but I don't know how to fix this.</p> <p>LoadResource is returning text from multiple resources.</p> <p>(These are resources compiled into my EXE by MINGW's 'winres' utility.) (This is NOT an OpenGL question.)</p> <p>I am trying to load the text of a shader into memory from a resource stored in the EXE.</p> <p>Here are the relivant pieces of code:</p> <p>Where I am calling my function from:</p> <pre><code>void SetupDisplay() { UINT vShader = LoadShaderResource (VERTEX1, GL_VERTEX_SHADER); UINT fShader = LoadShaderResource (FRAGMENT1, GL_FRAGMENT_SHADER); </code></pre> <p>....</p> <p>The top half where it's starting the process of loading the shader.... (I put a bunch of stuff in here trying to locate the problem, I walked back until I found this:</p> <pre><code>UINT LoadShaderResource (int index, int type) { std::vector&lt;std::string&gt; Lines; std::string tShader = LoadTextFileResource(index); std::cerr &lt;&lt; "-------BEGIN " &lt;&lt; index &lt;&lt; "\n"; std::cerr &lt;&lt; tShader; std::cerr &lt;&lt; "-------END\n"; std::istringstream iss(tShader); </code></pre> <p>... the rest isn't relivant, the shader complie crashes, at the bottom is the diagnostics this produces as to why. I use istringstream because I get all the text back in one big glob, but that's not the issue, (I have code that follows this that splits it.) the issue is both files get included at the same time when they are not supposed to be, at least for one of them, my guess is how they are stored, but I don't know how to fix this.</p> <p>Ok, Maybe something needs to be done here?</p> <pre><code>std::string LoadTextFileResource(int name) { HMODULE handle = GetModuleHandleA(NULL); HRSRC rc = FindResourceA(handle, MAKEINTRESOURCE(name), RT_RCDATA); HGLOBAL rcData = LoadResource(handle, rc); std::string result = (const char*) LockResource(rcData); return result; } </code></pre> <p>Ok, that's all the C++ code, now for the resouce stuff:</p> <p>resource.rc</p> <pre><code>// Generated by ResEdit 1.5.11 // Copyright (C) 2006-2012 // http://www.resedit.net #include &lt;windows.h&gt; #include &lt;commctrl.h&gt; #include &lt;richedit.h&gt; #include "resource.h" LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL VERTEX1 RCDATA "..\\Data\\shader.vert" LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL FRAGMENT1 RCDATA "..\\Data\\shader.frag" // // Icon resources // LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL IDI_ICON1 ICON "..\\Data\\Generic.ico" </code></pre> <p>.... I show the icon only so you can see what is following, the rest is version info and such.</p> <p>My resource.h file to link my code to the resource.rc file:</p> <pre><code>#ifndef IDC_STATIC #define IDC_STATIC (-1) #endif #define IDI_ICON1 100 #define VERTEX1 110 #define FRAGMENT1 120 </code></pre> <p>Now, the text of the shaders. (remember, this is not an OpenGL question.)</p> <p>shader.frag</p> <pre><code>#version 330 #pragma optimize(off) #pragma debug(on) smooth in vec3 theColor; out vec4 outputColor; void main() { outputColor = vec4(theColor, 1.0); } </code></pre> <p>shader.vert</p> <pre><code>#version 330 #pragma optimize(off) #pragma debug(on) layout (location = 0) in vec3 inPosition; layout (location = 1) in vec3 inColor; smooth out vec3 theColor; void main() { gl_Position = vec4(inPosition, 1.0); theColor = inColor; } </code></pre> <p>Ok, with all that out of the way, here is what it produces. (including the double spacing.)</p> <pre><code>-------BEGIN 110 #version 330 #pragma optimize(off) #pragma debug(on) layout (location = 0) in vec3 inPosition; layout (location = 1) in vec3 inColor; smooth out vec3 theColor; void main() { gl_Position = vec4(inPosition, 1.0); theColor = inColor; } #version 330 #pragma optimize(off) #pragma debug(on) smooth in vec3 theColor; out vec4 outputColor; void main() { outputColor = vec4(theColor, 1.0); } -------END -------BEGIN 120 #version 330 #pragma optimize(off) #pragma debug(on) smooth in vec3 theColor; out vec4 outputColor; void main() { outputColor = vec4(theColor, 1.0); } -------END </code></pre> <p>Ok, now if you notice, BEGIN 110 contains both shaders, where BEGIN 120 does not. Of course, both shaders in the 110 is what is blowing things up. What I can not understand is where is it getting both shaders from in 110? </p> <p>There is something going on here I do not understand, but I am lost as what to look at next.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload