Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 7th, 2012  |  syntax: None  |  size: 0.75 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Absolute positioning in OpenGL with C
  2. glutSolidCube (2.0);
  3.        
  4. glTranslatef()
  5. glRotatef()
  6. glScalef()
  7.        
  8. glPushMatrix()
  9. glPopMatrix()
  10.        
  11. void draw()
  12. {
  13.     /* Viewport and projection really should be set in the
  14.        drawing handler. They don't belong into the reshape. */
  15.     glViewport(...);
  16.  
  17.     glMatrixMode(GL_PROJECTION);
  18.     glLoadIdentity();
  19.     your_projection();
  20.  
  21.  
  22.     glMatrixMode(GL_MODELVIEW);
  23.     glLoadIdentity();
  24.     gluLookAt(5, 5, 20, 0, 0, 0, 0, 1, 0);
  25.  
  26.     glPushMatrix();
  27.     glTranslatef(5, 2, 10);
  28.     draw_cube();
  29.     glPopMatrix();
  30.  
  31.     glPushMatrix();
  32.     glTranslatef(-5, -2, 20);
  33.     draw_cube();
  34.     glPopMatrix();
  35.  
  36.     glPushMatrix();
  37.     glTranslatef(-5, -2, 20);
  38.     glScalef(20, 5, 10);
  39.     draw_cube();
  40.     glPopMatrix();
  41. }