PDA

View Full Version : window problem



srikirti
12-13-2002, 05:24 AM
when ever we move the mouse onto the cross button and move back onto the window the sceen is again drawn. if any change of shape or orientation is there they too change
though we dont really close the window or that particular event has occured. why is this happening?

mdog1234
12-13-2002, 08:47 AM
Your scene is redrawing itself for some reason. do you do a redraw in your mouse function by any chance?

Halcyon
12-15-2002, 10:17 PM
Every time you resize your window you need to resize your view port and reset your model and project matrices along with the perspective. Here is the code to do it. Put this under the windows WM_SIZE procedure. The width and height can be obtained by taking the LOWORD(lparam) and HIWORD (lparam) respectively. Cast them into ints and store then into variables width and height. Anyways...here is the code:




//resize viewport
glViewport(0,0,width,height);

//Load projection matrix
glMatrixMode(GL_PROJECTION);
//Clear projection matrix
glLoadIdentity();
//Reset perspective (from 0.1f to 100.0f)
gluPerspective(45.0f,(float)width/(float)height,0.1f,100.0f);

//Load Modelview Matrix
glMatrixMode(GL_MODELVIEW);
//Clear Modelview matrix
glLoadIdentity();