Sphere out of Triangle Strips (Please Help)
Well you are going to need to know trig for sure to do this. If you don't you should study up on it. Or just load a model mesh of a sphere that you either download for free or make yourself in your choice of modeler tools. Or as someone suggested use gluSphere. What is the reason why none of these suggested ideas will not work, if I may ask.
If he wants to deform the sphere he will have to have a set of vertices used to render from. Using this trig function supplies that. However, this is pretty much the worst possible way to render any primitive in OpenGL. Simple, flexible, but slow as can be.
There are a few ways to resolve this issue while retaining the flexibility of the sphere.
Assuming you don't want to deform, you can load the vertices on initialization into an array of floats. Then using glGenLists(), glNewList(), glEndList() and glCallList() you may utilize drawing that (static) array. You may use a multitude of functions in a display list, and even call other display lists. However, you are bound to a few rules. You must not create a new display list in a display list, you must use static memory, and you may not call openGL functions that read from the hard disk. Display lists are an easy and fast solution to optimizing static geometry.
Alternatives are vertex arrays and vertex buffer objects.
Vertex arrays are a bit more complicated than display lists, but still fairly simple to implement. For dynamic access to the vertices, vertex arrays are a good choice.
The best optimization, hands down, is to use VBO's. It actually loads all of the primitive data onto the GPU, making it absurdly fast to render. It is possible to load it as either static or dynamic (draw/stream) data, but you typically want to just leave it as static (draw).
There is a trick, have faith in the OGL gods! If you want to have deformation on (nearly) any static object, even in display lists, you may use *gasp* shaders! Using gl_Vertex in shaders, you are able to mutate the vertices on the GPU instead of on software.
In essence, by doing this you load the geometry AND the deformation algorithm onto the GPU, the only thing you're sending through the bus is "HEY YOU, DRAW!" Do this, and you should be able to render a high-poly geometric object with complex mutations essentially for free.
Enjoy!
PS. It's pretty late, so if there are any discrepancies with what I've said, feel free to call me on it. I am pretty tired so it's entirely possible I've made a semantic error somewhere.
There are a few ways to resolve this issue while retaining the flexibility of the sphere.
Assuming you don't want to deform, you can load the vertices on initialization into an array of floats. Then using glGenLists(), glNewList(), glEndList() and glCallList() you may utilize drawing that (static) array. You may use a multitude of functions in a display list, and even call other display lists. However, you are bound to a few rules. You must not create a new display list in a display list, you must use static memory, and you may not call openGL functions that read from the hard disk. Display lists are an easy and fast solution to optimizing static geometry.
Alternatives are vertex arrays and vertex buffer objects.
Vertex arrays are a bit more complicated than display lists, but still fairly simple to implement. For dynamic access to the vertices, vertex arrays are a good choice.
The best optimization, hands down, is to use VBO's. It actually loads all of the primitive data onto the GPU, making it absurdly fast to render. It is possible to load it as either static or dynamic (draw/stream) data, but you typically want to just leave it as static (draw).
There is a trick, have faith in the OGL gods! If you want to have deformation on (nearly) any static object, even in display lists, you may use *gasp* shaders! Using gl_Vertex in shaders, you are able to mutate the vertices on the GPU instead of on software.
In essence, by doing this you load the geometry AND the deformation algorithm onto the GPU, the only thing you're sending through the bus is "HEY YOU, DRAW!" Do this, and you should be able to render a high-poly geometric object with complex mutations essentially for free.
Enjoy!
PS. It's pretty late, so if there are any discrepancies with what I've said, feel free to call me on it. I am pretty tired so it's entirely possible I've made a semantic error somewhere.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement