Friday, May 22, 2009

Changing vertex processing inside glBegin()/glEnd()

It appears you CAN NOT change shaders in the middle of a glBegin()/glEnd() block. That is, the following code will not switch between vert_main and vert_shadow:

glBegin(GL_TRIANGLE_STRIP); {
for (int v = 0; v < 4; v ++) { cgGLBindProgram(vert_main); glVertex3fv(VERTS[FACES[f][v]].xyz); cgGLBindProgram(vert_shadow); glVertex3fv(VERTS[FACES[f][v]].xyz); } } glEnd();


Looks like I *should* have seen this in the documentation: "Only a subset of GL commands can be used between glBegin and glEnd."

No comments: