jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame^] | 1 | /* $Id: vindex.c,v 1.1 1999/08/19 00:55:43 jtg Exp $ */ |
| 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 | * This program is in the public domain. |
| 10 | * Brian Paul, January 1996 |
| 11 | */ |
| 12 | |
| 13 | |
| 14 | |
| 15 | #include <vga.h> |
| 16 | #include "GL/svgamesa.h" |
| 17 | #include "GL/gl.h" |
| 18 | |
| 19 | |
| 20 | |
| 21 | static GLint width = 640, height = 480; |
| 22 | |
| 23 | |
| 24 | |
| 25 | static void display( void ) |
| 26 | { |
| 27 | int i, j; |
| 28 | int w, h; |
| 29 | |
| 30 | glViewport( 0, 0, width, height ); |
| 31 | glMatrixMode( GL_PROJECTION ); |
| 32 | glLoadIdentity(); |
| 33 | glOrtho( 0.0, (GLfloat) width, 0.0, (GLfloat) height, -1.0, 1.0 ); |
| 34 | |
| 35 | glClear( GL_COLOR_BUFFER_BIT ); |
| 36 | |
| 37 | w = width / 16; |
| 38 | h = height / 16; |
| 39 | for (i=0;i<16;i++) { |
| 40 | for (j=0;j<16;j++) { |
| 41 | glIndexi( i*16+j ); |
| 42 | glRecti( i*w, j*h, i*w+w, j*h+h ); |
| 43 | } |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | |
| 48 | |
| 49 | int main( int argc, char *argv[] ) |
| 50 | { |
| 51 | SVGAMesaContext vmc; |
| 52 | int i; |
| 53 | |
| 54 | vga_init(); |
| 55 | vga_setmode( G640x480x256 ); |
| 56 | |
| 57 | vmc = SVGAMesaCreateContext( GL_FALSE ); |
| 58 | SVGAMesaMakeCurrent( vmc ); |
| 59 | |
| 60 | display(); |
| 61 | sleep(3); |
| 62 | |
| 63 | SVGAMesaDestroyContext( vmc ); |
| 64 | vga_setmode( TEXT ); |
| 65 | return 0; |
| 66 | } |