nvfx: expose GLSL
[mesa/mesa-lb.git] / progs / trivial / vp-tri-swap.c
bloba3ab1206fdf6d50b0bb7f442411bbae98d947de3
1 /* Test glGenProgramsNV(), glIsProgramNV(), glLoadProgramNV() */
3 #include <assert.h>
4 #include <string.h>
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <math.h>
8 #include <GL/glew.h>
9 #include <GL/glut.h>
11 static void Init( void )
13 GLint errno;
14 GLuint prognum;
16 static const char *prog1 =
17 "!!ARBvp1.0\n"
18 "MOV result.position, vertex.color;\n"
19 "MOV result.color, vertex.position;\n"
20 "END\n";
23 glGenProgramsARB(1, &prognum);
25 glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prognum);
26 glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
27 strlen(prog1), (const GLubyte *) prog1);
29 assert(glIsProgramARB(prognum));
30 errno = glGetError();
31 printf("glGetError = %d\n", errno);
32 if (errno != GL_NO_ERROR)
34 GLint errorpos;
36 glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorpos);
37 printf("errorpos: %d\n", errorpos);
38 printf("%s\n", (char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB));
42 static void Display( void )
44 glClearColor(0.3, 0.3, 0.3, 1);
45 glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
47 glEnable(GL_VERTEX_PROGRAM_NV);
49 glBegin(GL_TRIANGLES);
50 glColor3f(0,0,.7);
51 glVertex3f( 0.9, -0.9, -0.0);
52 glColor3f(.8,0,0);
53 glVertex3f( 0.9, 0.9, -0.0);
54 glColor3f(0,.9,0);
55 glVertex3f(-0.9, 0.0, -0.0);
56 glEnd();
59 glFlush();
63 static void Reshape( int width, int height )
65 glViewport( 0, 0, width, height );
66 glMatrixMode( GL_PROJECTION );
67 glLoadIdentity();
68 glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
69 glMatrixMode( GL_MODELVIEW );
70 glLoadIdentity();
71 /*glTranslatef( 0.0, 0.0, -15.0 );*/
75 static void Key( unsigned char key, int x, int y )
77 (void) x;
78 (void) y;
79 switch (key) {
80 case 27:
81 exit(0);
82 break;
84 glutPostRedisplay();
90 int main( int argc, char *argv[] )
92 glutInit( &argc, argv );
93 glutInitWindowPosition( 0, 0 );
94 glutInitWindowSize( 250, 250 );
95 glutInitDisplayMode( GLUT_DEPTH | GLUT_RGB | GLUT_SINGLE );
96 glutCreateWindow(argv[0]);
97 glewInit();
98 glutReshapeFunc( Reshape );
99 glutKeyboardFunc( Key );
100 glutDisplayFunc( Display );
101 Init();
102 glutMainLoop();
103 return 0;