jtg | afb833d | 1999-08-19 00:55:39 +0000 | [diff] [blame] | 1 | |
| 2 | /* |
| 3 | * Test SVGA/Mesa interface in 32K color mode. |
| 4 | * |
| 5 | * Compile with: gcc vtest.c -I../include -L../lib -lMesaGL -lX11 -lXext |
| 6 | * -lvga -lm -o vtest |
| 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 | SVGAMesaContext vmc; |
| 20 | |
| 21 | |
| 22 | |
| 23 | void setup( void ) |
| 24 | { |
| 25 | vga_init(); |
| 26 | |
| 27 | vga_setmode(G800x600x32K); |
| 28 | /* gl_setcontextvga(G800x600x32K);*/ |
| 29 | |
| 30 | vmc = SVGAMesaCreateContext( GL_FALSE ); /* single buffered */ |
| 31 | SVGAMesaMakeCurrent( vmc ); |
| 32 | } |
| 33 | |
| 34 | |
| 35 | void test( void ) |
| 36 | { |
| 37 | glMatrixMode(GL_PROJECTION); |
| 38 | glLoadIdentity(); |
| 39 | glOrtho( -1.0, 1.0, -1.0, 1.0, -1.0, 1.0 ); |
| 40 | glMatrixMode(GL_MODELVIEW); |
| 41 | |
| 42 | glClear( GL_COLOR_BUFFER_BIT ); |
| 43 | |
| 44 | glBegin( GL_LINES ); |
| 45 | glColor3f( 1.0, 0.0, 0.0 ); |
| 46 | glVertex2f( -0.5, 0.5 ); |
| 47 | glVertex2f( 0.5, 0.5 ); |
| 48 | glColor3f( 0.0, 1.0, 0.0 ); |
| 49 | glVertex2f( -0.5, 0.25 ); |
| 50 | glVertex2f( 0.5, 0.25 ); |
| 51 | glColor3f( 0.0, 0.0, 1.0 ); |
| 52 | glVertex2f( -0.5, 0.0 ); |
| 53 | glVertex2f( 0.5, 0.0 ); |
| 54 | glEnd(); |
| 55 | |
| 56 | glBegin( GL_POLYGON ); |
| 57 | glColor3f( 1.0, 0.0, 0.0 ); |
| 58 | glVertex2f( 0.0, 0.7 ); |
| 59 | glColor3f( 0.0, 1.0, 0.0 ); |
| 60 | glVertex2f( -0.5, -0.5 ); |
| 61 | glColor3f( 0.0, 0.0, 1.0 ); |
| 62 | glVertex2f( 0.5, -0.5 ); |
| 63 | glEnd(); |
| 64 | |
| 65 | sleep(3); |
| 66 | } |
| 67 | |
| 68 | void end( void ) |
| 69 | { |
| 70 | SVGAMesaDestroyContext( vmc ); |
| 71 | |
| 72 | vga_setmode( TEXT ); |
| 73 | } |
| 74 | |
| 75 | |
| 76 | int main( int argc, char *argv[] ) |
| 77 | { |
| 78 | setup(); |
| 79 | test(); |
| 80 | end(); |
| 81 | return 0; |
| 82 | } |