home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / coders / mesa-1.2.8 / demos / test0.c < prev    next >
C/C++ Source or Header  |  1996-05-27  |  1KB  |  97 lines

  1. /* test0.c */
  2.  
  3.  
  4.  
  5. #include <stdio.h>
  6. #include <string.h>
  7. #include <stdlib.h>
  8. #include "glaux.h"
  9.  
  10.  
  11.  
  12.  
  13. static void Init( void )
  14. {
  15.    /* one-time init (clearColor, set palette, etc) */
  16.  
  17.    glClearIndex( 0.0 );
  18.    glShadeModel( GL_FLAT );
  19. }
  20.  
  21.  
  22. static void Reshape( int width, int height )
  23. {
  24.    glViewport(0, 0, (GLint)width, (GLint)height);
  25.  
  26.    glMatrixMode(GL_PROJECTION);
  27.    glLoadIdentity();
  28.    glOrtho( -1.0, 1.0, -1.0, 1.0, -1.0, 1.0 );
  29.    glMatrixMode(GL_MODELVIEW);
  30. }
  31.  
  32.  
  33. static void key_up()
  34. {
  35.    printf("AUX_UP\n");
  36. }
  37.  
  38.  
  39. static void key_down()
  40. {
  41.    printf("AUX_DOWN\n");
  42. }
  43.  
  44.  
  45. static void key_esc()
  46. {
  47.    auxQuit();
  48. }
  49.  
  50.  
  51. static void display( void )
  52. {
  53.    /* clear viewport */
  54.    glClear( GL_COLOR_BUFFER_BIT );
  55.  
  56.    /* draw stuff */
  57.    glIndexi( 1 );
  58.    glBegin( GL_LINES );
  59.    glVertex3f( 0.0, 0.0, 0.0 );
  60.    glVertex3f( 1.0, 0.0, 0.0 );
  61.    glEnd();
  62.  
  63.    glBegin( GL_LINES );
  64.    glVertex3f( 0.0, 0.0, 0.0 );
  65.    glVertex3f( 0.0, 0.5, 0.0 );
  66.    glEnd();
  67.  
  68.  
  69.    /* flush / swap buffers */
  70.    glFlush();
  71.    auxSwapBuffers();
  72. }
  73.  
  74.  
  75.  
  76. int main( int argc, char **argv )
  77. {
  78.    auxInitDisplayMode( AUX_INDEX );
  79.  
  80.    auxInitPosition( 50, 50, 400, 300 );
  81.  
  82.    if (auxInitWindow("test0") == GL_FALSE) {
  83.       auxQuit();
  84.    }
  85.  
  86.    Init();
  87.  
  88.    auxExposeFunc(Reshape);
  89.    auxReshapeFunc(Reshape);
  90.    auxKeyFunc( AUX_UP, key_up );
  91.    auxKeyFunc( AUX_DOWN, key_down );
  92.  
  93.    auxMainLoop( display );
  94.  
  95.    return 0;
  96. }
  97.