[QUOTE=giuseppe500;1244430]very thanks Praetorian.
Is properly as you described.
But my goal is to create a 2d camera for zooming and translating.
For this in another post i asked if glortho returns a matrix.
How i can get a matrix from an eye point that i can translate or go ahead(zoom in) or go far(zoom out)
I wish use only opengl function, not glut or other.
and I wish using matrixes,shader and vbo , is a project “like” acrobat reader , i use it for text drawing and other (lines and points)in opengl.
isn’t the same to multiply the points for the inverse of the modelview matrix (in this case the transpose of modelviewmatrix )
Thanks.[/QUOTE]
It sounds like you’re trying to do too many things at once. First focus on zooming.
I don’t see any problem using glOrtho to implement zooming/panning for 2d as it works fine for me.
glViewport( 0, 0, cx, cy);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho( xMin, xMax, yMin, yMax, -1.0, 1.0);
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
Just change the xmin,xMax,yMin,yMax to zoom in, zoom out and pan the view space. cx,cy are your window dimensions.
At any point call gluUnProject to convert local to project coordinates. I don’t use Qt but it should be same as Windows
// Given local coordinate return project coordinate
CPoint3D COGLView::CoordinateUnProject(CPoint3D *point)
{
CPoint3D result;
GLdouble modelMatrix[16];
GLdouble projMatrix[16];
GLint viewport[4];
GLdouble objx, objy, objz;
glGetDoublev(GL_MODELVIEW_MATRIX, modelMatrix);
glGetDoublev(GL_PROJECTION_MATRIX, projMatrix);
glGetIntegerv(GL_VIEWPORT, viewport);
gluUnProject(point->x, point->y, point->z, modelMatrix, projMatrix, viewport, &objx, &objy, &objz);
result.x = (double)objx;
result.y = (double)objy;
result.z = (double)objz;
return result;
}
Where CPoint3D is a point class defined by my vector math library. Now use the returned point to implement picking. No glut needed by I’m not familiar with vbo/shaders.