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.

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?

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.