jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1 | |
| 2 | /* |
| 3 | * Test Linux 8-bit SVGA/Mesa color index mode |
| 4 | * |
| 5 | * Compile with: gcc vindex.c -I../include -L../lib -lMesaGL -lX11 -lXext |
| 6 | * -lvga -lm -o vindex |
| 7 | * |
| 8 | * This program is in the public domain. |
| 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( GL_FALSE ); |
| 57 | SVGAMesaMakeCurrent( vmc ); |
| 58 | |
| 59 | display(); |
| 60 | sleep(3); |
| 61 | |
| 62 | SVGAMesaDestroyContext( vmc ); |
| 63 | vga_setmode( TEXT ); |
| 64 | return 0; |
| 65 | } |