I am trying to "fill" a surface of a sphere that I drew using this algorithm here:
http://paulbourke.net/miscellaneous/sphere_cylinder/, the first method.
I know that GL_QUADS
is no longer used in OpenGL 3+. SO I used GL_TRIANGLE_FAN
. Is it the same thing? The problem here is that my sphere facets are squares. So if I use GL_TRIANGLE
then I get a weird "filling", not all the surface is covered. Am I doing it the wrong way? How does GL_TRIANGLE_FAN
work exactly?
A triangle fan is a primitive in 3D computer graphics that saves on storage and processing time. It describes a set of connected triangles that share one central vertex (unlike the triangle strip that connects the next vertex point to the last two used vertices to form a triangle), possibly within a triangle mesh.
To draw a triangle strip using immediate mode OpenGL, glBegin() must be passed the argument GL_TRIANGLE_STRIP , which notifies OpenGL a triangle strip is about to be drawn. The glVertex*() family of functions specify the coordinates for each vertex in the triangle strip.
GL_TRIANGLES. Treats each triplet of vertices as an independent triangle. Vertices 3n - 2, 3n - 1, and 3n define triangle n. N/3 triangles are drawn.
How does GL_TRIANGLE_FAN works exactly?
The first vertex of a triangle fan acts like a hub. The vertices following connect with the previous non-starting vertex and the hub.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With