home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Amiga 5 / MA_Cover_5.iso / ppc / mesa / util / glutskel.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-01-31  |  1.5 KB  |  99 lines

  1. /* glutskel.c */
  2.  
  3. /*
  4.  * A skeleton/template GLUT program
  5.  */
  6.  
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. #include <math.h>
  10. #include <GL/glut.h>
  11.  
  12.  
  13.  
  14. static void Idle( void )
  15. {
  16.    /* update animation vars */
  17.    glutPostRedisplay();
  18. }
  19.  
  20.  
  21. static void Display( void )
  22. {
  23.    glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
  24.  
  25.    glPushMatrix();
  26.    /* draw stuff here */
  27.  
  28.    glPopMatrix();
  29.  
  30.    glutSwapBuffers();
  31. }
  32.  
  33.  
  34. static void Reshape( int width, int height )
  35. {
  36.    glViewport( 0, 0, width, height );
  37.    glMatrixMode( GL_PROJECTION );
  38.    glLoadIdentity();
  39.    glFrustum( -1.0, 1.0, -1.0, 1.0, 5.0, 25.0 );
  40.    glMatrixMode( GL_MODELVIEW );
  41.    glLoadIdentity();
  42.    glTranslatef( 0.0, 0.0, -15.0 );
  43. }
  44.  
  45.  
  46. static void Key( unsigned char key, int x, int y )
  47. {
  48.    switch (key) {
  49.       case 27:
  50.          exit(0);
  51.          break;
  52.    }
  53.    glutPostRedisplay();
  54. }
  55.  
  56.  
  57. static void SpecialKey( int key, int x, int y )
  58. {
  59.    switch (key) {
  60.       case GLUT_KEY_UP:
  61.          break;
  62.       case GLUT_KEY_DOWN:
  63.          break;
  64.       case GLUT_KEY_LEFT:
  65.          break;
  66.       case GLUT_KEY_RIGHT:
  67.          break;
  68.    }
  69.    glutPostRedisplay();
  70. }
  71.  
  72.  
  73. static void Init( void )
  74. {
  75.    /* setup lighting, etc */
  76. }
  77.  
  78.  
  79. int main( int argc, char *argv[] )
  80. {
  81.    glutInit( &argc, argv );
  82.    glutInitWindowSize( 400, 400 );
  83.  
  84.    glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
  85.  
  86.    glutCreateWindow(argv[0]);
  87.  
  88.    Init();
  89.  
  90.    glutReshapeFunc( Reshape );
  91.    glutKeyboardFunc( Key );
  92.    glutSpecialFunc( SpecialKey );
  93.    glutDisplayFunc( Display );
  94.    glutIdleFunc( Idle );
  95.  
  96.    glutMainLoop();
  97.    return 0;
  98. }
  99.