I have a 3D world I have build and I am trying to implement a Zoom tool. The idea is to have the mouse pointing at the area I want to zoom in on, then have that area displayed in the bottom left corner of the window (fullscreen). Anyway, I have enclosed the code I am using: And as everyone says, thanks in advance for any help.
(In WinMain())…
if (keys[‘A’])
Zooming = 0;
if (keys[‘Z’])
Zooming = 1;
///////////////////////////////
In DrawGLScene()…
if (Zooming == 1)
{
CreateZoomWindowFrame();
glCallList(ZOOMSCREEN);
}
//////////////////////////////
void CreateZoomWindowFrame(void)
{
RECT ZoomWindow;
GLint viewport[4];
if (Zooming == 1)
{
glNewList(ZOOMSCREEN,GL_COMPILE);
//glPushMatrix();
glGetIntegerv(GL_VIEWPORT,viewport);
GetClientRect(hWnd,&ZoomWindow);
glViewport(0,0,viewport[2],viewport[3]);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0,
ZoomWindow.right,
0,
ZoomWindow.top,
-1.0,
1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glReadBuffer(GL_FRONT);
glDrawBuffer(GL_FRONT);
glPixelZoom(2.0,2.0);
glRasterPos2d(40,32);
glCopyPixels(mouseX-8,
mouseY-8,
16,
16,
GL_COLOR);
glReadBuffer(GL_BACK);
glDrawBuffer(GL_BACK);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0,
viewport[2]/viewport[3],
0.1,
10000.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
// glPopMatrix();
glEndList();
}
}