package require tcl3d proc tclDisplayFunc { toglwin } { #BEGIN OF MAIN LOOP # Clear color and depth buffer glClear [expr $::GL_COLOR_BUFFER_BIT | $::GL_DEPTH_BUFFER_BIT] glLoadIdentity ; # Reset the current modelview matrix glTranslatef 0.0 0.0 -5.0 ; # Transformations glRotatef $::xrot 1.0 0.0 0.0 glRotatef $::yrot 0.0 1.0 0.0 glRotatef $::zrot 0.0 0.0 1.0 drawGeometry ; # Draw the actual geometry $toglwin swapbuffers ; # Swap front and back buffer #END OF MAIN LOOP } proc tclCreateFunc { toglwin } { glShadeModel GL_SMOOTH ; # Enable smooth shading glClearColor 0.0 0.0 0.0 0.5 ; # Black background glClearDepth 1.0 ; # Depth buffer setup glEnable GL_DEPTH_TEST ; # Enable depth testing } proc tclReshapeFunc { toglwin w h } { glViewport 0 0 $w $h ; # Reset the current viewport glMatrixMode GL_PROJECTION ; # Select the projection matrix glLoadIdentity ; # Reset the projection matrix # Calculate the aspect ratio of the window gluPerspective 45.0 [expr double($w)/double($h)] 0.1 100.0 glMatrixMode GL_MODELVIEW ; # Select the modelview matrix glLoadIdentity ; # Reset the modelview matrix }