What happens if I don't call glNormal for some vertices?

Let's say I have an object where some vertices will have the same normal and some won't. Are these two equivalent? Note I'm working with an old OpenGL version (2.3 I think).

Option 1

``````glNormal3f(0.0, 0.0, 1.0);
glVertex3f(-1.0, -1.0, 1.0);
glVertex3f( 1.0, -1.0, 1.0);
glVertex3f( 1.0,  1.0, 1.0);
glVertex3f(-1.0,  1.0, 1.0);

glNormal3f(0.1, 0.0, -1.0);
glVertex3f( 1.0, -1.0, -1.0);
glNormal3f(0.2, 0.0, -1.0);
glVertex3f(-1.0, -1.0, -1.0);
glNormal3f(0.3, 0.0, -1.0);
glVertex3f(-1.0,  1.0, -1.0);
``````

Option 2

``````glNormal3f(0.0, 0.0, 1.0);
glVertex3f(-1.0, -1.0, 1.0);
glNormal3f(0.0, 0.0, 1.0);
glVertex3f( 1.0, -1.0, 1.0);
glNormal3f(0.0, 0.0, 1.0);
glVertex3f( 1.0,  1.0, 1.0);
glNormal3f(0.0, 0.0, 1.0);
glVertex3f(-1.0,  1.0, 1.0);

glNormal3f(0.1, 0.0, -1.0);
glVertex3f( 1.0, -1.0, -1.0);
glNormal3f(0.2, 0.0, -1.0);
glVertex3f(-1.0, -1.0, -1.0);
glNormal3f(0.3, 0.0, -1.0);
glVertex3f(-1.0,  1.0, -1.0);
``````
-

What happens if I don't call glNormal for some vertices?

It will use the last `glNormal` value that you have set when you call `glVertex3f`.

You can view OpenGL as a state machine. Calling `glNormal` will change the state of the 'current normal', and that's all. As it can be read in MSDN documentation:

The current color, normal, and texture coordinates are associated with the vertex when glVertex is called.

Are these two equivalent?

You'll achieve the same effect, so effect-wise, yes, they are equivalent.

However, if this situation will occur often during the run-time, it would be wise to reduce the number of unnecessary calls to OpenGL to increase performance. Thus they're not equivalent efficiency-wise; you should use Option 1 as much as possible.

-
If you really cared about performance, you'd go with Option 3: Use Vertex Buffer Objects. – Colonel Thirty Two Mar 6 at 6:23

`glNormal` just sets the current normal, just like `glColor` sets the current color, et cetera. When you call `glVertex`, the current normal, color, texture coordinates, and so on are associated with the specified vertex.

So you don't need to call `glNormal` for every vertex if you want your vertices to reuse whatever the current normal is.

(In other words, yes, those two options you posted are equivalent.)

-