View Full Version : glPrimitiveRestartIndex()

06-27-2012, 01:07 AM
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,


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

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,

Dark Photon
06-27-2012, 05:05 AM
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:

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.

06-27-2012, 05:20 AM
Sigh - cross-post: http://www.opengl.org/discussion_boards/showthread.php/178078-glPrimitiveRestartIndex%28%29?p=1239362