Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>My comment went just over the limit of characters, so hopefully this is worth an answer.</p> <p>The only thing I can see that might be a problem are your <code>glUniformMatrix4fv</code> calls. The second parameter, according to the <a href="http://www.opengl.org/sdk/docs/man4/xhtml/glUniform.xml" rel="nofollow">OpenGl 4 language reference</a> describes it as the number of matrices to change. The 3.2 core reference pages aren't linked on their site, so I couldn't look it up for that particular context. So for <code>glUniformMatrix4fv(projection_loc, 16, GL_TRUE, projection);</code> it intends to find sixteen matrices in an array called "Projection", yet you only defined <code>uniform mat4 Projection;</code>. This may or may not be a part of your problem, and it's possible I'm not even correct, especially if this is a known tutorial that other people have compiled/used.</p> <p>Also, glEnable(GL_TEXTURE_2D) isn't necessary (<a href="http://www.opengl.org/discussion_boards/showthread.php/171415-OpenGL-3-X-glEnable%28GL_TEXTURE_2D%29-GL_INVALID_ENUM" rel="nofollow">or even usable, i think?</a>) with an OpenGL context of version 3.2 core, which was set up here:</p> <pre><code>glutInitContextVersion( 3, 2 ); glutInitContextProfile( GLUT_CORE_PROFILE ); </code></pre> <p>If the compiler isn't giving you any errors, trying adding <code>glGetError()</code> after lines which you think may be problematic. The return value maps to an enum value in the header file for OpenGL (<a href="http://www.opengl.org/registry/#headers" rel="nofollow">glcorearb.h</a> will list them), and i think the documentation lists them as well.</p> <p>Other than that, you may just want to check that the "normals" 3-dimensional array is laid out in memory the way you expect it to be, as I've never tried manually constructing an array to be used as a texture myself (though images are basically strings of byte data anyways, so I don't see how it's a problem in this case).</p> <p>Hopefully this helped you, or at least pointed you in the right direction. Good luck.</p> <p><strong>Edit #1</strong>: I realized my comment about shader checking wasn't very complete, as I failed to mention some API calls. Here's an example of it though:</p> <pre><code> char * dataBuffer; struct _stat fileStat; long fLen; FILE * vSh; FILE * fSh; int desc; GLint status; GLint logLength; GLuint vShader = glCreateShader(GL_VERTEX_SHADER); //errort = glGetError(); GLuint fShader = glCreateShader(GL_FRAGMENT_SHADER); GLuint program = glCreateProgram(); /*__________________________________________________*/ vSh = fopen("vShader.vSh", "r"); desc = _fileno(vSh); _fstat(desc, &amp;fileStat); fLen = fileStat.st_size; dataBuffer = (char *) calloc((fLen + 1), sizeof(char)); if (dataBuffer == NULL) { MessageBox(NULL, "Malloc failure: VS", "Create Program", MB_OK | MB_ICONINFORMATION); return 1; } if(feof(vSh) == 0) { MessageBox(NULL, "Did not reach EoF for VS", "Create Program", MB_OK | MB_ICONINFORMATION); return 2; } fclose(vSh); glShaderSource(vShader, 1, &amp;dataBuffer, NULL); glCompileShader(vShader); //Error checking glGetShaderiv(vShader, GL_COMPILE_STATUS, &amp;status); if (status == GL_FALSE) { glGetShaderiv(vShader, GL_INFO_LOG_LENGTH, &amp;logLength); char resultV[logLength+1]; glGetShaderInfoLog(vShader, logLength, NULL, resultV); MessageBox(NULL, resultV, "Vertex Compile Error", MB_OK); } free(dataBuffer); </code></pre> <p>The way I get my shader isn't the real important part, so hopefully that doesn't confuse you. The part labelled <code>//Error checking</code> is the stuff I meant, when talking about checking your shader for errors.</p>
    singulars
    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.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. COThanks for giving this thought. Good find for the matrix calls, it seems the author mistook the second the parameter for element count rather than matrix count. I thought this must be the issue, but I changed all of the 16's in these calls to 1's and still nothing! I also tried getting rid of the glEnable. Strange thing about error checking: I get error 1282 no matter where I check (even in working code), EXCEPT for a check that I put below glTexImage2D() in, where I get 1280 (GL_INVALID_ENUM?). I can't put much more time into this at the moment, but I appreciate your help.
      singulars
    2. COJust looked at the reference pages, and apparently more than one error flag can be raised, but only one flag gets returned at a time per call. So you need to loop until you see `GL_NO_ERROR`, to be sure there aren't other errors hiding around. If it is _always_ 1282, then I'm not sure what's going on... it's possibly that the flag values are OR'd together, so you're getting a combination of errors. On the other hand, it might be gibberish? I really don't know. I'll take a look at the code another time, perhaps. No time at the moment.
      singulars
    3. COAlso take a look at glGetShaderInfoLog and glGetProgramInfoLog from the reference pages. I use those to debug my shaders, and they work fairly well. I can edit my answer with an example if you'd like. Or does InitShader take care of that?
      singulars
 

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