Polygon with more than 3 vertices?

I used OpenGL in the past, but I am just in the process of catching up on the later development with GL4. I understand the concept of VBO, etc. but it seems to me like the only way of drawing something to the screen now, is if the geometry is triangulated? Is this correct?

What I’d like to do, is display for example a ‘cube’ shaded but with the wireframe on top. So if define the cube by 8 vertices and 6 faces, I will need to triangulate the faces. If I render this in wireframe, I will see the triangles which I don’t want. I want to see the ORIGINAL cube faces.

How can I do this? It seems to me that the only solution is to render the mesh in fill mode, then draw the lines on top to show the original edges of the original model. Is that how it’s supposed to be done?

Thank you.

Yes, unless you use compatibillity profile where all the old cruft is still available.

[QUOTE=mast4as;1260861]What I’d like to do, is display for example a ‘cube’ shaded but with the wireframe on top. So if define the cube by 8 vertices and 6 faces, I will need to triangulate the faces. If I render this in wireframe, I will see the triangles which I don’t want. I want to see the ORIGINAL cube faces.

How can I do this? It seems to me that the only solution is to render the mesh in fill mode, then draw the lines on top to show the original edges of the original model. Is that how it’s supposed to be done?[/QUOTE]
Either that, or use a texture.

Thank you very much. Using a texture? How would that work more specifically. It seems to me that you need to know where the edges are in texture space, which requires your geometry to have texture coordinates? Is that what you were thinking about?

Thanks again.

You could map a texture to the cube with the texture coordinates set up in a way that the edges of the texture match the edges of the cube. The texture image itself has somehow highlighted edges (e.g. a white line on the edge and black every else).

okay yes sure. That would involve to have texture coordinates though. But yes it’s an idea;-) Thanks for your answers.

I have another related question, and I think it’s better if I don’t start another thread. So I draw the (triangulated) faces of the cube then I need to draw the lines for the faces. I have never used GL_LINES or GL_LINE_LOOP before. Is it possible to draw multiple line loops in one single glDrawElement calls or do I need 1 glDrawElement call per loop? Thanks.

[QUOTE=Agent D;1260865]You could map a texture to the cube with the texture coordinates set up in a way that the edges of the texture match the edges of the cube. The texture image itself has somehow highlighted edges (e.g. a white line on the edge and black every else).[/QUOTE] Do you mean ‘black’ everywhere else, or transparent every where else? ‘Black’ would result in a cube with white edges, but opaque faces. I assume that the OP wants a true wireframe effect, where you can see right through the cube.

You can do it with a single glDrawElements using primitive restart. You specify an index to be the restart index (typically -1 is chosen, which is equivalent to 0xffff if using unsigned short or 0xffffffff if using unsigned int indices), then fill your element array buffer with indices for your line loop, placing a restart index between each line loop. Then when you issue your glDrawElements call, each time it hits this restart index it will begin a new line loop. Don’t forget to enable primitive restart too.

And you could also do it procedurally in a fragment shader instead of wasting texture memory and so on and so forth…
Your mileage may vary…

Cool, thank you I didn’t know about the restart feature.