Reputation: 6679
I am new to the whole OpenGL ES scene, if that's even the direction to go with what I want to accomplish. I would like to create a pannable, scalable 3D space in iOS and am looking for a decent example, tutorial, or documentation to get me pointed in the right direction on designing this functionality.
My question: do you know of any good resources for figuring out how to accomplish this in iOS? I'm aware of the OpenGL ES programming guide as well as the native drawing capabilities, but I'm trying to learn how to put all that together. Any pointers would be much appreciated.
Thanks in advance!
Upvotes: 2
Views: 783
Reputation: 2931
I'd start with NeHe OpenGL Tutorials to get started learning OpenGL basics. Once you've read through the tutorials and have a basic understanding of how OpenGL works, (most of what NeHe has on their site still applies to OpenGL ES), then what you want to do is very simple. All you have to do is create a new OpenGL project, then handle touches. You need to keep track of a scene pan offset value. This will be modified by the user dragging their finger/fingers. Next you need to keep track of scale. This can be done at the same time as the dragging. In your OpenGL render loop, before you draw any geometry, call:
glPushMatrix();
glTranslatef(pan.x, pan.y, 0);
glScalef(scale, scale, scale);
//draw geometry here
glPopMatrix();
This will give you a basic OpenGL scene that you can pan and zoom. If you want to rotate, it gets a bit more complicated as you need to create an arcball implementation or use someone elses method for scene rotation, such as the molecules source code.
Upvotes: 2