Jump to content
  • Advertisement
IsItSharp

OpenGL Creating Sphere with GL_TRIANGLE_STRIP

Recommended Posts

Posted (edited)

Afaik vertex- and an index buffers for opengl and d3d are built identically. Valid until correction 🙂

Suggesting to OP to tessellate an icosphere instead of slices. Triangles are almost equally distributed, no singularities, only the "terminator line" where textures meet needs some attention.

 

Edited by Green_Baron

Share this post


Link to post
Share on other sites
Advertisement
6 hours ago, Gnollrunner said:

Finally a third option is to sub-divide an icosahedron.  This is my goto sphere! It gives you far more even triangulation but it's trickier to generate algorithmically.

I submit that an icosphere is not particularly tricky to generate algorithmically. Once you have hardcoded the indexing of the base icosohedron, subdivision is fairly straightforward.

To put my money where my mouth is, here's a straightforward implementation ripped from a current project (feel free to use/adapt if you like).

I'd also say to the OP, that triangle strips aren't really a worthwhile optimisation here. It's quite tricky to generate a sliced sphere in a single triangle strip (typically requiring the introduction of degenerate triangles), so at best you'll save a (very small) amount of memory, and at worst you end up rendering using multiple strips which means multiple draw calls... and that's more expensive than just using a triangle list instead.

Share this post


Link to post
Share on other sites
8 hours ago, Gnollrunner said:

I would think you would have repeat each strip twice, except for the top and bottom, because you have to do a zig-zag between them.

I'm guessing you meant rows of vertices and not strips?

Share this post


Link to post
Share on other sites
9 hours ago, swiftcoder said:

I submit that an icosphere is not particularly tricky to generate algorithmically. Once you have hardcoded the indexing of the base icosohedron, subdivision is fairly straightforward.

To put my money where my mouth is, here's a straightforward implementation ripped from a current project (feel free to use/adapt if you like).

I'd also say to the OP, that triangle strips aren't really a worthwhile optimisation here. It's quite tricky to generate a sliced sphere in a single triangle strip (typically requiring the introduction of degenerate triangles), so at best you'll save a (very small) amount of memory, and at worst you end up rendering using multiple strips which means multiple draw calls... and that's more expensive than just using a triangle list instead.

Ha, ha, Rust looks like Greek to me :D but I think I got the gist of it. Kind of a breath first traversal type thing, although it's not really a tree per se.  I actually build a tree, and it has actual edges, but then I'm not using it strictly for graphics and it has to change at run time so I can't afford to search for edges.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!