aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/extras/Mesa_6.4.2/progs/xdemos/vindex.c
blob: 991fce2a5917541d6054d0783cc9f6bc1b1d1944 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65

/*
 * Test Linux 8-bit SVGA/Mesa color index mode
 *
 * Compile with:  gcc vindex.c -I../include -L../lib -lMesaGL -lX11 -lXext
 *   -lvga -lm -o vindex
 *
 * This program is in the public domain.
 * Brian Paul, January 1996
 */



#include <vga.h>
#include "GL/svgamesa.h"
#include "GL/gl.h"



static GLint width = 640, height = 480;



static void display( void )
{
   int i, j;
   int w, h;

   glViewport( 0, 0, width, height );
   glMatrixMode( GL_PROJECTION );
   glLoadIdentity();
   glOrtho( 0.0, (GLfloat) width, 0.0, (GLfloat) height, -1.0, 1.0 );

   glClear( GL_COLOR_BUFFER_BIT );

   w = width / 16;
   h = height / 16;
   for (i=0;i<16;i++) {
      for (j=0;j<16;j++) {
         glIndexi( i*16+j );
         glRecti( i*w, j*h, i*w+w, j*h+h );
      }
   }
}



int main( int argc, char *argv[] )
{
   SVGAMesaContext vmc;
   int i;

   vga_init();
   vga_setmode( G640x480x256 );

   vmc = SVGAMesaCreateContext( GL_FALSE );
   SVGAMesaMakeCurrent( vmc );

   display();
   sleep(3);

   SVGAMesaDestroyContext( vmc );
   vga_setmode( TEXT );
   return 0;
}