Drawing outside the viewport in OpenGL ES 2.0
I was building a 2D project in OpenGL ES 1.1 but decided to switch to 2.0 since I was only going to be developing for the iPad.
In 1.1, when a viewport is set up, the notion seems to be that you are viewing only a part of the full 3D space e.g.
CGRect rect = view.bounds;
glOrthof(-1.0, // Left
1.0, // Right
-1.0 / (rect.size.width / rect.size.height), // Bottom
1.0 / (rect.size.width / rect.size.height), // Top
0.01, // Near
10000.0); // Far
glViewport(0, 0, rect.size.width, rect.size.height);
(Ta开发者_如何学JAVAken from Jeff LaMarche's tutorial on OpenGL ES)
From everything I've seen of 2.0, there is no GlOrthof method to specify what you're looking at, only the glViewport call, which is described as setting up the plane on which you're drawing.
My intention is to draw a 2D wireframe map that you can zoom into and pan around. I assumed to achieve this I would draw inside and outside of the viewport and then change the viewport coords as the user panned around.
How do you draw outside of the viewport in OpenGL ES 2.0?
Is this the correct way of achieving what I want to achieve?
Have I misunderstood everything entirely?
Thanks for your help with this!
You should use matrices to move around the world ( glOrthof is multipling current matrix by projection matrix created with specified parameters ), in OpenGL ES 2.0 you are responsible for using matrices in shaders ( mainly to calculate final position, you multiply position by ModelViewProjection matrix ), for example you can have big 2D plane parallel to screen and just move along Z axis ( View matrix ) to get ZoomIn ZoomOut functionality.
Good resources are avaiable:
powervr opengl es 2 sdk
or look through some gamedev pages like gamasutra gamedev.net
精彩评论