10-11-2005, 09:51 PM
i'm a beginner of computer graphics. i cant figure out why i cant reshape my image in the screen window. that is whenever i resize the screen window, the screen in the window becomes black in color and the image previously drawn disappear. is this a problem related the reshaping function or other functions?
here is my reshaping function:
void
myReshape(GLsizei width, GLsizei height)
{
WinHeight = height;
WinWidth = width;
glViewport(0,0, WinWidth, WinHeight);
// set current viewport, ie. the portion of the window to which
// everything will be clipped
glMatrixMode(GL_PROJECTION);
// set current matrix mode to the given mode
glLoadIdentity();
// load identity matrix to matrix stack so that current matrix
// is the identity matrix
gluOrtho2D(0, WinWidth , 0, WinHeight);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glutSwapBuffers();
}
here is my reshaping function:
void
myReshape(GLsizei width, GLsizei height)
{
WinHeight = height;
WinWidth = width;
glViewport(0,0, WinWidth, WinHeight);
// set current viewport, ie. the portion of the window to which
// everything will be clipped
glMatrixMode(GL_PROJECTION);
// set current matrix mode to the given mode
glLoadIdentity();
// load identity matrix to matrix stack so that current matrix
// is the identity matrix
gluOrtho2D(0, WinWidth , 0, WinHeight);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glutSwapBuffers();
}