window problem

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?

Your scene is redrawing itself for some reason. do you do a redraw in your mouse function by any chance?

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();