Skip to content

Ill-specified interaction of display lists and primitive restart #74

Description

@ianromanick

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).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions