OpenGL Resources

OpenGL Tutorial

Sample Application

Description of the Source Code

  • void init( ); initialize the program before the main loop (load models or textures, preprocessing data, etc.)
  • void update(); update states before rendering for each frame (rotation angles for turntable animations, etc.)
  • void render(); render objects with meshes, textures, modelview and projection transformations, light sources and materials.
  • void glutPostRedisplay(void); call this function when you need to redraw the screen. the display callback render will be called in the next iteration of the main loop.
  • void keyboard( unsigned char key, int x, int y ); process key events for user inputs (move cameras, switch rendering modes, etc.)
  • void mouse( int button, int state, int x, int y ); process mouse events for user inputs (rotate or zoom cameras, select or move objects, etc.)
  • void reshape( int w, int h ); change viewport and projection matrix when the window is resized
  • and void glutTimerFunc(dt, timer, value); call timer function in dt milliseconds. you can make animations by calling this function in the timer function.