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 3 of 3

Thread: glortho

  1. #1
    Junior Member Regular Contributor
    Join Date
    Apr 2010
    Posts
    112

    glortho

    hello.
    I have implemented a little engine for drawing in opengl(2d) inside a qt interface .
    Now i must implement something like at the acrobat reader's interface :
    A document area with zoom and scroll.
    I don't need perspective, but whats I use for the scrolling and the zoom?
    I must do all with glortho?
    I use shaders and the vbos , how i can get a matrix from glortho for send it to the shader param where is multiplied for each point?
    Is like the projection transformation and the 4x4 matrix MVP(model view projection)?

    and how i can translate the coordinates of qt opengl widget to the opengl viewport?
    thanks.

  2. #2
    Member Regular Contributor Rosario Leonardi's Avatar
    Join Date
    Aug 2008
    Location
    Italy
    Posts
    356
    glOrtho create a matrix as described in the documentation
    http://www.opengl.org/sdk/docs/man2/xhtml/glOrtho.xml

    so.. it's really easy to create a function that do the same exact matrix as glOrtho so you don't need to retrieve (that it's a slow operation that cause a flush of the command buffer).

    You can to all the pan and zoom by moving the glOrtho parameters.


    with = windowWidth * zoomFactor
    height = windowHeight * zoomFactor

    left = panX
    top = panY
    right = left + width
    bottom = top + height
    glOrtho(left, right, bottom, top, 0.0, 1.0);

    The matrix produced by glOrtho can be used as a projection matrix. In this case you don't have a "view" matrix cause the projection transformation also move the the "camera".

    If you are using a QGLWidget you don't have to translate any coordinates. Just assign the size to the viewport as showed in this tutorial
    http://qt-project.org/doc/qt-5.0/qglwidget.html
    By the way, why don't you use QGLView and QGLCamera?
    ~ ~ I tell you, realtime 3D is made of blood, sweat and screams! ~ ~

  3. #3
    Junior Member Regular Contributor
    Join Date
    Apr 2010
    Posts
    112
    very thanks.
    Now that i know that exist a qt camera i use it.
    But i would explain that i must do : i wish do a like acrobat reader application.
    I have an a4(sheet) that is a 2d texture(just a photo or a scansion)and some text on it, but if i resizes the glwidget changes the proportions that i wish maintain.
    Is possible add two scrollbars and overflow the entire sheet after the zoom?
    or select only a part of the sheet with a box zoom.
    thanks.

Posting Permissions

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