Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 5 of 5

Thread: is glViewport needed or used in OpenGL ES 2.0?

  1. #1
    Intern Newbie
    Join Date
    Nov 2010
    Posts
    40

    is glViewport needed or used in OpenGL ES 2.0?

    What does glViewport do when you are using OpenGLES 2.0? Isn't everything defined by the various matrices you use in the shaders?

    Bob

  2. #2
    Intern Newbie
    Join Date
    Nov 2012
    Posts
    33
    Hi Bob,

    Don't confuse glViewport with the transformation matrices (as I did not too long ago). All glViewport does is define the area of the drawing context that you will actually draw to.

    For example, let's assume your window is 800 by 600 pixels. Calling glViewport(0, 0, 800, 600) means you will draw to the whole screen. Calling glViewPort(0, 0, 400, 300) means you will only draw in the bottom left quadrant.

  3. #3
    Intern Newbie
    Join Date
    Nov 2010
    Posts
    40
    I still thought that somehow what the viewport call did ultimately boiled down to what the projection matrices did.

    So it is needed in OpenGLES 2?

  4. #4
    Intern Newbie
    Join Date
    Nov 2012
    Posts
    33
    I can't give you a 100% sure answer since I don't personally work with OpenGL ES 2.0, but you should still need it, if only just once during your initialization.

    Generally glViewport would help if you were trying to draw multiple views, like in 3D modeling software or multiplayer split-screen games. Half the window might use one set of projection matrices, like perspective; the other half may use another, like orthographic. A call to glViewport scales (and depending on your transformation matrices, possibly distorts) the drawing output/buffer to fit within the rectangle you set. If you use a fully symmetrical projection matrix, the vanishing point will be at the center of your specified viewport.
    Last edited by Aestivae; 12-17-2012 at 07:35 PM. Reason: redundancy: "center will be at the center"

  5. #5
    Advanced Member Frequent Contributor
    Join Date
    Dec 2007
    Location
    Hungary
    Posts
    985
    Yes, it is needed. glViewport sets the viewport that is used by the viewport transformation step which transforms NDCs (normalized device coordinates) to viewport coordinates. This is needed both in OpenGL ES 2.0+ and OpenGL Core 3.x+
    Disclaimer: This is my personal profile. Whatever I write here is my personal opinion and none of my statements or speculations are anyhow related to my employer and as such should not be treated as accurate or valid and in no case should those be considered to represent the opinions of my employer.
    Technical Blog: http://www.rastergrid.com/blog/

Posting Permissions

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