Question

People have been telling me that "GPU renders triangles only".

But how do you explain GPU rendering a quad with 4 lines only in the wireframe mode, shouldnt it be rendering it with 5 lines since GPU cannot understand quads ?

On the other hand, how can i emulate quads in the future where GL_QUADS is banned ? do i need a shader for it, do i need to generate new array of lines for each object and i cant just simply switch from GL_FILL to GL_LINE ?

Was it helpful?

Solution

Lines are something different than filled primitives. When switching to glPolygonMode(…, GL_LINE) whenever a filled primitive is started (GL_TRIANGLES, GL_QUADS), OpenGL won't sent commands for filled primitives, but lines between the vertices of the filled primitive. So GL_TRIANGLES translates to tupled of 3 GL_LINES, GL_QUADS translates to tuples of 4 GL_LINES. GL_POLYGON is translated to a GL_LINE_LOOP. Of course those translations don't happen in terms of OpenGL, but the OpenGL driver will send commands to the GPU that are equivalent to what would have been sent; also there are some subtle differences between GL_LINE polygon mode and sending actual lines, most notably the evaluation of the edge flag.

OTHER TIPS

I din't understand your question fully but from what I understood here is the answer.

There are 2 concepts
1. Interpolation Used for figuring out which pixels are to be drawn on a line.
2. Rasterization Used for figuring out what properties (colors, texture etc.) to be assigned to the pixels lying inside a triangle. GPU can raster only triangles and interpolate only lines. So when you are in a wireframe model only interpolation of the boundary of polygons is done. But when we are in solid geometry model along with interpolation we also raster the polygon.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top