From: Tim R. <ti...@us...> - 2004-07-14 17:02:58
|
Update of /cvsroot/csdopenglnet/tutorials/lesson01 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6826/lesson01 Modified Files: lesson01glut.cs Log Message: additional documentation Index: lesson01glut.cs =================================================================== RCS file: /cvsroot/csdopenglnet/tutorials/lesson01/lesson01glut.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** lesson01glut.cs 14 Jul 2004 08:26:54 -0000 1.5 --- lesson01glut.cs 14 Jul 2004 17:02:49 -0000 1.6 *************** *** 68,72 **** glutReshapeFunc( new cb0_glutReshapeFunc( reshape ) ); ! // sets the visibility callback / delegate for the current window glutVisibilityFunc( new cb0_glutVisibilityFunc( visible ) ); --- 68,79 ---- glutReshapeFunc( new cb0_glutReshapeFunc( reshape ) ); ! /* ! sets the visibility callback / delegate for the current window ! glutVisibilityFunc sets the visibility callback (e.g. visible) for the current window. The visibility ! callback for a window is called when the visibility of a window changes. The state ! callback parameter is either GLUT_NOT_VISIBLE or GLUT_VISIBLE depending on the current ! visibility of the window. GLUT_VISIBLE does not distinguish a window being otally ! versus partially visibile. GLUT_NOT_VISIBLE means no part of he window is visible. ! */ glutVisibilityFunc( new cb0_glutVisibilityFunc( visible ) ); *************** *** 82,85 **** --- 89,108 ---- protected void visible( int state ) { if ( state==GLUT_VISIBLE ) { + /* + sets te global idle callback. + glutIdleFunc sets the global idle callback to be func (e.g. redraw) so a GLUT programm + can perform background processing tasks or continuous animation when window system events + are not being received. If enabled, the idle callback is continuously called when events + are not being received. The callback routine has no parameters. The currend window and + current menu will not bechanged before the idle callback. Programs with + multiple windows and/or menus should explicitly se the current window and/or current menu + and not rely on its current setting + + The amount of computation and rendering done in an idle callback should be minimized to + avoid affecting the program's interactive respone. In general, not more than a single + frame of rendering should be done in an idle callback. + + Passing null to glutIdleFunc disables the generation of the idle callback. + */ glutIdleFunc( new cb0_glutIdleFunc( redraw ) ); } else { *************** *** 89,117 **** protected void redraw() { glutPostRedisplay(); } protected void initGL() { glShadeModel( GL_SMOOTH ); glClearColor( 0.0f, 0.0f, 0.0f, 0.0f ); glClearDepth( 1.0f ); glEnable( GL_DEPTH_TEST ); glDepthFunc( GL_LEQUAL ); glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST ); } protected void reshape( int width, int height ) { ! float h = ((float)height) / ((float)width); glViewport (0, 0, width, height); glMatrixMode (GL_PROJECTION); glLoadIdentity (); glFrustum (-1.0, 1.0, -h, h, 5.0, 5.0); glMatrixMode (GL_MODELVIEW); glLoadIdentity (); } protected void draw() { glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); /* swaps the buffers of the current window if double buffered. --- 112,173 ---- protected void redraw() { + /* + marks the current window as needing to be redisplayed. + Mark the normal plane of current window as needing to be redisplayed. The next + iteration through glutMainLoop, the window's display callback will be called to + redisplay the window's normal plane. Multiple calls to glutPostRedisplay before the + next display callback opportunity generates only a single redisplay call. + glutPostRedisplay may be called within a window's display or overlay display + callback to re-mark that window for redisplay. + */ glutPostRedisplay(); } protected void initGL() { + /* enables smooth shading. Smooth shading blends colors nicely across a polygon, and smoothes out lighting. */ glShadeModel( GL_SMOOTH ); + /* sets the clear color in RGBA for the screen */ glClearColor( 0.0f, 0.0f, 0.0f, 0.0f ); + /* depth buffer setup */ glClearDepth( 1.0f ); + /* enables depth testing */ glEnable( GL_DEPTH_TEST ); + /* the type of the depth test */ glDepthFunc( GL_LEQUAL ); + /* enables best perspective correction; causes performance hit, but makes the perspevtive view + look better */ glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST ); } + /* + This methode resizes the OpenGL scene whenever the window has been resized. This method is + at least called once when the program is first run to set the perspective view. + */ protected void reshape( int width, int height ) { ! if (height==0) height = 1; // prevent division by zero ! float h = ((float)height) / ((float)width); ! glViewport (0, 0, width, height); + + /* indicates that the next lines affect the projection matrix */ glMatrixMode (GL_PROJECTION); + /* reset projection matrix */ glLoadIdentity (); + glFrustum (-1.0, 1.0, -h, h, 5.0, 5.0); + + /* indicates that the next lines affect the modelview matrix */ glMatrixMode (GL_MODELVIEW); + /* reset modelview matrix */ glLoadIdentity (); } protected void draw() { + /* clear screen and depth buffer */ glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + /* reset the current model view matrix to EINHEITSMATRIX */ + glLoadIdentity(); + /* swaps the buffers of the current window if double buffered. |