View Full Version : How does glutReshapeFunc work?

05-07-2013, 11:49 AM
I found this piece of code:


void reshape (int w, int h) {
glViewport (0, 0, (GLsizei)w, (GLsizei)h);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gluPerspective (60, (GLfloat)w / (GLfloat)h, 0.1, 100.0);
glMatrixMode (GL_MODELVIEW);

int main (int argc, char **argv) {
glutInit (&argc, argv);
glutInitDisplayMode (GLUT_DOUBLE);
glutInitWindowSize (640, 480);
glutInitWindowPosition (100, 100);
glutCreateWindow ("Ellipses");

glutDisplayFunc (display);
glutIdleFunc (display);
glutReshapeFunc (reshape);
glutMainLoop ();
return 0;

how does the call to reshape work, what are the values of w and h in this case ???

carsten neumann
05-07-2013, 12:40 PM
See documentation for glutReshapeFunc (http://www.opengl.org/documentation/specs/glut/spec3/node48.html). Like all the glut*Func() functions this registers a callback function, a function that is called in response to a window system/OS event, so that your application has a chance to handle it appropriately.

Please use [ code]/[ /code] (without space after '[') around source code snippets, see also Forum Posting Guidelines (http://www.opengl.org/discussion_boards/showthread.php/176139-Forum-Posting-Guidelines), thanks.