A few bits of the OpenGL 3.1+ specification combine to generate an interaction that may be impossible to satisfy.
- Starting in OpenGL 3.1, primitive restart enable became server state.
glPrimitiveRestartIndex cannot be compiled into a display list.
- From section 21.4 (Display Lists) of the OpenGL 4.6 Compatibility Profile spec:
Vertex array pointers are dereferenced when the commands ArrayElement, DrawArrays, DrawElements, or DrawRangeElementsare accumulated into a display list.
Based on that, what should the following code do?
glDisable(GL_PRIMITIVE_RESTART);
glPrimitiveRestartIndex(0x7fffffff);
glNewList(1, GL_COMPILE);
glBegin(GL_TRIANGLES);
glArrayIndex(0); glArrayIndex(1); glArrayIndex(2);
glArrayIndex(0x7fffffff);
glArrayIndex(3); glArrayIndex(4); glArrayIndex(5);
glEnd();
glEndList();
glEnable(GL_PRIMITIVE_RESTART);
glCallList(1);
glPrimitiveRestartIndex(0x12345678);
glCallList(1);
The difficulty is that glArrayIndex(0x7fffffff) is supposed to dereference the vertex array at the time it is called. However, the state of GL_PRIMITIVE_RESTART and the primitive restart index aren't known until glCallList. It is impossible for the implementation to know if 0x7fffffff should start a new primitive or dereference a very large memory address.
On at least one implementation, it crashes inside glArrayIndex(0x7fffffff).
A few bits of the OpenGL 3.1+ specification combine to generate an interaction that may be impossible to satisfy.
glPrimitiveRestartIndexcannot be compiled into a display list.Based on that, what should the following code do?
The difficulty is that
glArrayIndex(0x7fffffff)is supposed to dereference the vertex array at the time it is called. However, the state ofGL_PRIMITIVE_RESTARTand the primitive restart index aren't known untilglCallList. It is impossible for the implementation to know if0x7fffffffshould start a new primitive or dereference a very large memory address.On at least one implementation, it crashes inside
glArrayIndex(0x7fffffff).