iphone - OpenGL to OpenGL-ES - glBegin(); -
I am trying to learn to write OpenGL apps for the iPhone. How do I close the following code to work with OpenGL-ES? I know that I have to store the corner in the array and then call glDrawArrays (), but is there an optimal way of doing this? I think create a very large array and keep a counter of just how many spaces are filled. Is this a better way? What about using NSArray and then converting back into a C array?
glBegin (GL_LINE_STRIP); Z = -50.0f; (Angle = 0.0 f; angle & lt; = (2.0f * 3.1415f) * 3.0f; angle + = 0.1f) {x = 50.0f * sin (angle); Y = 50.0f * cos (angle); // Specify the point and move the Z value to a small glVertex3f (x, y, z); Z + = 0.5f; } // drawing points Glenad ();
If you have enough space and know the maximum size of the array, then this simple Use a large static array allocated and just keep an eye on your current logical size.
If the memory is low but the processor resources are too large, then pack the array on the fly and then register the arrays and call glDrawArrays ().
The hybrid approach will be to use a dynamic allocated array that can be updated (if necessary). When you complete a dynamic array or by using any type of NSMutableArray you can manually do it manually (NB NSARRA is for static arrays; NSMutableArrays (subclasses) are dynamic.) < / P>
Hope this helps :)
Comments
Post a Comment