Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
318 posts
|
Hi,
I have a VBO storing a collection of polygons - i.e. triangle fans. I am willing to use glPrimitiveRestartIndex to declare when a polygon finishes and when a new one start. I draw with GL2 gl2 = gl.getGL2(); gl2.glEnable(GL2.GL_PRIMITIVE_RESTART); gl2.glPrimitiveRestartIndex(PRIMITIVE_RESTART_VALUE); // 0xffffffff ... gl2.glPolygonMode(GL.GL_FRONT_AND_BACK, GL2GL3.GL_FILL); gl2.glDrawElements(glGeometryType, elementSize, GL.GL_UNSIGNED_INT, firstCoordOffset); I generate VBO with a restart value every 4 point protected void append(int[] hexahedronPoints, int p1, int p2, int p3, int p4) { geometries[cursor++] = hexahedronPoints[p1]; geometries[cursor++] = hexahedronPoints[p2]; geometries[cursor++] = hexahedronPoints[p3]; geometries[cursor++] = hexahedronPoints[p4]; geometries[cursor++] = hexahedronPoints[p1]; if(DrawableVBO2.PRIMITIVE_RESTART) geometries[cursor++] = DrawableVBO2.PRIMITIVE_RESTART_VALUE; } OpenGL does not consider the restart value and instead see it as a vertex. This show a VBO fed with a closed loop p1, p2, p3, p4, p1, then p5, ... No primitive restart value is used, so OpenGL continue the line to point p5 when the loop is closed. (I am surprised to have the need to define the closing point, but anyway, the problem is mainly to see a line between p1 and p5 (which are labeled 3 and 0 in the chart). ![]() When activating primitive restart, OpenGL simply continue reading and seem to take the value as a coordinate. ![]() |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Administrator
6038 posts
|
I have never used this feature but I think that you have to pass a real index. You pass 4 vertices and you indicate that the 5th vertex is the primitive restart vertex by passing its index to glPrimitiveRestartIndex. Maybe I'm wrong.
Julien Gouesse | Personal blog | Website
|
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
318 posts
|
I got the explanation for the failure : I am using GL2 core profile. Primitive restart is only supported in core profiles as of OpenGL 3.1. Before 3.1, one should have the NV_primitive_restart extension available, which is not the case on my MacOS 10.12.3.
I indeed get these information Capabilities : GLCaps[rgba 8/8/8/8, opaque, accum-rgba 0/0/0/0, dp/st/ms 16/0/0, dbl, mono , hw, GLProfile[GL2/GL2.hw], offscr[fbo]] GL_VENDOR : NVIDIA Corporation GL_RENDERER : NVIDIA GeForce GT 650M OpenGL Engine GL_VERSION : 2.1 NVIDIA-10.17.5 355.10.05.45f01 GL_EXTENSIONS : GL_ARB_color_buffer_float GL_ARB_depth_buffer_float GL_ARB_depth_clamp GL_ARB_depth_texture GL_ARB_draw_buffers ... If you want to get the same information, use this GL gl = ... StringBuffer sb = new StringBuffer(); sb.append("Capabilities : " + caps + "\n"); sb.append("GL_VENDOR : " + gl.glGetString(GL.GL_VENDOR) + "\n"); sb.append("GL_RENDERER : " + gl.glGetString(GL.GL_RENDERER) + "\n"); sb.append("GL_VERSION : " + gl.glGetString(GL.GL_VERSION) + "\n"); String ext = gl.glGetString(GL.GL_EXTENSIONS); if(ext!=null) { sb.append("GL_EXTENSIONS : " + "\n"); for(String e: ext.split(" ")) { sb.append("\t" + e + "\n"); } } More detailed answers can be found here. |
Free forum by Nabble | Edit this page |