View Full Version : glNormalPointer glDrawElements, tables structure

10-20-2010, 04:28 AM
Let's say I have:

GLfloat vertices[] = {...}; // 8 of vertex coords
GLubyte indices[] = {0,1,2,3, // 24 of indices

I use glDrawElements() function to render GL_QUADS and everything is ok.
But what if I want to add normal array to my object? What structure does it have to be?
3 floats for every index (one Normal for every Vertex)?
or 3 floats for every 4 of indexes (one Normal for every Quad) ?
Or should I use glDrawElements() function not once, but for every Quad separetely, giving property amount of indices?

10-20-2010, 05:02 AM
If I understand your question well.
One normal per vertex is best (enables nicest viewing).
See http://www.lighthouse3d.com/opengl/terrain/index.php3?normals for an excellent explanation.

10-20-2010, 05:08 AM
The usual thing to do is send 3 floats per normal, per vertex.

10-20-2010, 06:09 AM
I want to have one normal per polygon. In your description there is one normal per every vertex.

For example:
Polygon A consists of vertex indexes: 0, 1, 2, 3
Polygon B consists of vertex indexes: 1, 4, 5, 6
All vertices in polygon A should have normal nA, and all vertices in polygon B should have normal nB.

We can see, that vertex number 1 is common to Polygon A and Polygon B. I would like to set normal nA to vertex number 1 when I render polygon A, and normal nB to vertex number 1 when I render polygon B.

Is there any possibilty to set different normal to every element of Index Array?