glNormalPointer question

Hey all, me again. I’m having a problem with glNormalPointer/glEnableClientState(GL_NORMAL_ARRAY). Here’s what’s up:

I’m using glNormalPointer along with glVertexPointer and glTexCoordPointer. When filling the function, however, my Microsoft VC++ 6 compiler complains that glNormalPointer doesn’t take 4 params. Even though I just specified 4 params for the other two, it only takes 3 (no stride), as follows:

glVertexPointer(3, GL_FLOAT, 0, verts);
glNormalPointer(3, GL_FLOAT, normals);
glTexCoordPointer(2, GL_FLOAT, 0, tex);

It’ll only compile when I use the above. When I run the program, it crashes, dumping me to some asm code.

I used the above vertex, normal, and texcoord arrays with glBegin/glEnd GL_TRIANGLES and GL_TRIANGLE_STRIP and it works fine. If I comment out the glNormalPointer call it also works fine (albeit without normals .

Does anyone have any idea why this is happening, why glNormalPointer is acting differently? This is somewhat annoying, please tell me it is something stupid that I’m overlooking so I can change it and go on.

Thanks in advance.

NormalPointer takes no size, not no stride. The size is always 3. Check your gl.h whenever you aren’t sure.

  • Matt


void glNormalPointer(
GLenum type,
GLsizei stride,
const GLvoid *pointer
The data type of each coordinate in the array using the following symbolic constants: GL_BYTE, GL_SHORT, GL_INT, GL_FLOAT, and GL_DOUBLE.
The byte offset between consecutive normals. When stride is zero, the normals are tightly packed in the array.
A pointer to the first normal in the array.

As Matt said, there is a stride, but no size. You took out the wrong parameter in your function call.

Change it to
glNormalPointer(GL_FLOAT, 0, normals);

Hahaha… Excellent, it was something stupid. Thanks for showing me my oversight Serves me right for trying to code late at night when I can barely keep my eyes open.