glPrimitiveRestartIndex not present when writing code in Qt Creator



  • The glPrimitiveRestartIndex function is unknown by the compiler while glEnable(GL_PRIMITIVE_RESTART_INDEX) is valid.
    The <QOpenGLFunctions_4_3_Core> is included (and I have noticed in the documentation the existence of that function)
    Is this OpengL feature included in QT 5.4 or what must I do to activate it?
    Thank you for your answer


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Can you show how you are using QOpenGLFunctions_4_3_Core ?



  • I want to draw a cube as a pair of triangle strips separated by a primitive restart index.
    GLfloat cubePositions []={
    -1.0f, 1.0f, -1.0f // Summit 0
    , 1.0f, 1.0f, -1.0f // Summit 1
    , -1.0f,1.0f, 1.0f // Summit 2
    , 1.0f, 1.0f, 1.0f // Summit 3
    , -1.0f,-1.0f,-1.0f // Summit 4
    , 1.0f, -1.0f,-1.0f // Summit 5
    , -1.0f,-1.0f,1.0f // Summit 6
    , 1.0f,-1.0f,1.0f // Summit 7 };
    GLushort cube_indices[] =
    {
    1, 5, 0, 4, 2, 6, 3, 7 , // First strip
    0xFFFF, // <<- - This is the restart index
    6, 4, 7, 5, 3, 1, 2, 0 // Second strip
    };
    Normally when all is well defined and allocated we must do the following
    glEnable(GL_PRIMITIVE_RESTART); // OK it is working
    glPrimitiveRestartIndex(0xFFFF); // This procedure is not recognized by Qt although it is documented.
    glDrawElements(GL_TRIANGLE_STRIP, 17, GL_UNSIGNED_SHORT, NULL);

    Of course I can call 2 draw commands without primitive restart as follow:
    glDrawElements(GL_TRIANGLE_STRIP, 8, GL_UNSIGNED_SHORT, NULL);
    glDrawElements(GL_TRIANGLE_STRIP, 8, GL_UNSIGNED_SHORT, (const GLvoid *)(9 * sizeof(GLushort)));

    But I was testing advanced features and I have a problem with primitive restart when declaring which index is the restarting index
    Thank you for your help


  • Lifetime Qt Champion

    Sorry, I meant: how are you declaring/initializing your class with QOpenGLFunctions_4_3_Core ?



  • @SGaist
    Thank you your question solves the problem. In fact I have derived my new class with QOpenGLFunctions and not QOpenGLFunctions_4_3_Core. So now glPrimitiveRestartIndex appears.
    For the GL functions initialisation can I use initializeOpenGLFunctions(); or must I add something else?


  • Lifetime Qt Champion

    No, nothing else, that's the only thing you need to do to initialize QOpenGLFunctions


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.