I have been trying to create a circle in OpenGL but I cannot use triangle fans because I have read they are not available in directx anymore and I will also be making directx calls.
I could not really understand how triangle strips work. All my implementations had holes or weird quirks, can anybody help me out here, how can I implement it in the best possible way?
Also is there really any performance difference between triangle strips and seperate triangles, for lets say 10 circles with 1000 triangles each. Will it make a lot of difference?
One way to specify a circle with a triangle strip is as follows:
This will include the circle's center position. Another way without including the center is this:
You may need to adjust the loops depending on your backface culling settings
The topologies require different numbers of vertices. For a triangle list 10 circles á 1000 triangles need 30,000 vertices. With a triangle strip you need 1002 vertices per circle, so overall 10,020 vertices. This is almost three times smaller, which should be a bit faster when transferring to the CPU. If this is reflected in the FPS depends on several things.
Instead zigging up and down on one side of the circle as above pseudo code shown, this one will zig zag across the center of the circle. This will have much fuller circle.
Here is code using VAO/VBO, and the minimum number of points. Unlike the other answers posted so far, it only needs one
cos()
and onesin()
call.Setup:
Draw: