Results 1 to 2 of 2

Thread: Adjusting aspect-ratio

  1. #1
    Junior Member
    Join Date
    Mar 2012
    Posts
    2

    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.

  2. #2
    Junior Member
    Join Date
    Jul 2011
    Posts
    17

    Re: Adjusting aspect-ratio

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •