How to zoom to a point

Hallo,
I have a project in which I want to zoom to the point which is in the middle of the OpenGL window.

My commands are as followed:

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(x1, x2,y1,y2,-z1,z2);

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glMatrixMode(GL_MODELVIEW);
glLoad Identity();

//! zoom
glScalef(scale,scale,1);

//! pan
glTranslated( xShift*shiftResX/scale, -yShift*shiftResY/scale, 0);

//! rotate
glRotated(xRot / rotRes, 1.0, 0.0, 0.0);
glRotated(yRot / rotRes, 0.0, 1.0, 0.0);

//! achsen zeichnen
drawAxis();

These commands have as result a zoom to the coordinate origin.

I tried so many things and the best result I got was a zoom to the “middle” of the data with the following code

// shift to the middle of the window
glTranslated(range/2, range/2, 0);

// zoom
glScalef(scale,scale,1);

// shift back
glTranslated(-range/2, -range/2, 0);

//! pan
glTranslated( xShift*shiftResX/scale, -yShift*shiftResY/scale, 0);

//! rotate
glRotated(xRot / rotRes, 1.0, 0.0, 0.0);
glRotated(yRot / rotRes, 0.0, 1.0, 0.0);

//! achsen zeichnen
drawAxis();

Now I don’t know what to do that I can zoom to the point in the middle of the window.

Please help…

Pedde

The solution is quite simple.
I just had to make the viewing volume, which is set with glOrtho, symmetric, because glScale just “zooms” to the point 0,0 of the viewing volume.

Pedde