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

  1. /* vindex.c */
  2.  
  3. /*
  4.  * Test Linux 8-bit SVGA/Mesa color index mode
  5.  *
  6.  * Compile with:  gcc vindex.c -I../include -L../lib -lMesaGL -lX11 -lXext
  7.  *   -lvga -lm -o vindex
  8.  *
  9.  * Brian Paul, January 1996
  10.  */
  11.  
  12.  
  13.  
  14. #include <vga.h>
  15. #include "GL/svgamesa.h"
  16. #include "GL/gl.h"
  17.  
  18.  
  19.  
  20. static GLint width = 640, height = 480;
  21.  
  22.  
  23.  
  24. static void display( void )
  25. {
  26.    int i, j;
  27.    int w, h;
  28.  
  29.    glViewport( 0, 0, width, height );
  30.    glMatrixMode( GL_PROJECTION );
  31.    glLoadIdentity();
  32.    glOrtho( 0.0, (GLfloat) width, 0.0, (GLfloat) height, -1.0, 1.0 );
  33.  
  34.    glClear( GL_COLOR_BUFFER_BIT );
  35.  
  36.    w = width / 16;
  37.    h = height / 16;
  38.    for (i=0;i<16;i++) {
  39.       for (j=0;j<16;j++) {
  40.          glIndexi( i*16+j );
  41.          glRecti( i*w, j*h, i*w+w, j*h+h );
  42.       }
  43.    }
  44. }
  45.  
  46.  
  47.  
  48. int main( int argc, char *argv[] )
  49. {
  50.    SVGAMesaContext vmc;
  51.    int i;
  52.  
  53.    vga_init();
  54.    vga_setmode( G640x480x256 );
  55.  
  56.    vmc = SVGAMesaCreateContext();
  57.    SVGAMesaMakeCurrent( vmc );
  58.  
  59.    display();
  60.    sleep(3);
  61.  
  62.    SVGAMesaDestroyContext( vmc );
  63.    vga_setmode( TEXT );
  64.    return 0;
  65. }
  66.