Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: glPrimitiveRestartIndex()

  1. #1
    Junior Member Regular Contributor
    Join Date
    Jun 2012
    Posts
    123

    glPrimitiveRestartIndex()

    Hi ,
    I am trying to use glPrimitiveRestartIndex() to draw GL_LINES. Here is code :

    const GLfloat data[] =
    {
    -0.9f, -0.6f,
    -0.9f, -0.9f,
    -0.6f, -0.9f,
    -0.6f, -0.6f,

    -0.3f,-0.6f,
    -0.3f,-0.9f,
    0.0f,-0.9f,
    0.0f,-0.6f
    };

    GLuint indices [] = {0, 1, 2, 3 ,666, 4 , 5 ,6 , 7 };

    glPrimitiveRestartIndex(666);
    glDrawElements(GL_LINES, 9 , GL_UNSIGNED_INT ,(GLvoid *)0);

    Now, with this code it draws only 3 parallel lines instead of 4.
    But when i increase the count in glDraw to 10, it draws 4 lines correctly. Is it what expected?
    When i replace GL_LINES with GL_TRIANGLE_FAN with count=9, it correctly draws 2 quads.

    Please let me know where i am going wrong.

    Thanks in advance,

  2. #2
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    2,882
    Quote Originally Posted by debonair View Post
    I am trying to use glPrimitiveRestartIndex() to draw GL_LINES.
    LINES is not a strip primitive that needs broken. It's automatically broken every 2 verts. Why are you combining these? If you're just trying to support a wireframe mode, would:

    Code :
    glPolygonMode ( GL_FRONT_AND_BACK, do_wireframe ? GL_LINE : GL_FILL );
    work just as well?

    That said, not sure why what you're doing (LINES+restart) shouldn't work. I don't recall any language that limits the use of restart based on primitive type. Probably just a hardly if ever used combination.
    Last edited by Dark Photon; 06-27-2012 at 05:16 AM.

  3. #3
    Advanced Member Frequent Contributor
    Join Date
    Jan 2007
    Posts
    964

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •