Adjusting aspect-ratio

Hi,

I’m using GLES2, and I’d like to know how adjust aspect-ratio to match new window dimension.
usually, I’d write something like that in the ‘surfaceChange’ function:
glViewport(0, 0, width, height); //Reset The Current Viewport
glMatrixMode(GL_PROJECTION); //Select The Projection Matrix
glLoadIdentity();
//Calculate The Aspect Ratio Of The Window
gluPerspective(gl, 45.0f, (float)width / (float)height, 0.1f, 1000.0f);
glMatrixMode(GL_MODELVIEW); //Select The Modelview Matrix
glLoadIdentity();

But it seems like most of this code is not supported in GLES2 (I get many compilation error on missing declaration).
Am I missing some ‘include’ files? or maybe there’s a different way for setting the aspect-ratio in GLES2?

Thanks.

There is no matrix stack on an OpenGL ES 2.0 implementation, just as with OpenGL 3.x and newer, the fixed function pipeline has been removed and a lot of the initial functionality in OpenGL 2.0 shaders have also been removed.

Thus, gluPerspective is not being used anymore, nor any matrix operations at all.

What you’re probably looking for is using uniforms. You need to define your own uniform matrices in your shaders and supply them with your own calculated values. Google for gluPerspective and you’ll find the code used for the matrices in the specification.

If you’re looking for an implementation that do support all of this, and you do not plan to use shaders, i would recommend looking at OpenGL ES 1.x instead.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.