Convert libGL and DRI drivers to require libdrm.
[mesa-demos.git] / src / tests / arbvptest3.c
blob5f6d4f7e99d524099d08fdb1928fe0ead3ca0b52
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 #define GL_GLEXT_PROTOTYPES
9 #include <GL/glut.h>
11 static float Zrot = 0.0;
14 static void Display( void )
16 glClearColor(0.3, 0.3, 0.3, 1);
17 glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
19 glEnable(GL_VERTEX_PROGRAM_NV);
21 glLoadIdentity();
22 glRotatef(Zrot, 0, 0, 1);
24 glPushMatrix();
26 glVertexAttrib3fARB(3, 1, 0.5, 0.25);
27 glBegin(GL_TRIANGLES);
28 #if 1
29 glVertexAttrib3fARB(3, 1.0, 0.0, 0.0);
30 glVertexAttrib2fARB(0, -0.5, -0.5);
31 glVertexAttrib3fARB(3, 0.0, 1.0, 0.0);
32 glVertexAttrib2fARB(0, 0.5, -0.5);
33 glVertexAttrib3fARB(3, 0.0, 0.0, 1.0);
34 glVertexAttrib2fARB(0, 0, 0.5);
35 #else
36 glVertex2f( -1, -1);
37 glVertex2f( 1, -1);
38 glVertex2f( 0, 1);
39 #endif
40 glEnd();
42 glPopMatrix();
44 glutSwapBuffers();
48 static void Reshape( int width, int height )
50 glViewport( 0, 0, width, height );
51 glMatrixMode( GL_PROJECTION );
52 glLoadIdentity();
53 /* glFrustum( -2.0, 2.0, -2.0, 2.0, 5.0, 25.0 );*/
54 glOrtho(-2.0, 2.0, -2.0, 2.0, -2.0, 2.0 );
55 glMatrixMode( GL_MODELVIEW );
56 glLoadIdentity();
57 /*glTranslatef( 0.0, 0.0, -15.0 );*/
61 static void Key( unsigned char key, int x, int y )
63 (void) x;
64 (void) y;
65 switch (key) {
66 case 'z':
67 Zrot -= 5.0;
68 break;
69 case 'Z':
70 Zrot += 5.0;
71 break;
72 case 27:
73 exit(0);
74 break;
76 glutPostRedisplay();
80 static void Init( void )
82 GLint errno;
83 GLuint prognum;
85 static const char *prog1 =
86 "!!ARBvp1.0\n"
87 "MOV result.color, vertex.color;\n"
89 "DP4 result.position.x, vertex.position, state.matrix.modelview.row[0];\n"
90 "DP4 result.position.y, vertex.position, state.matrix.modelview.row[1];\n"
91 "DP4 result.position.z, vertex.position, state.matrix.modelview.row[2];\n"
92 "DP4 result.position.w, vertex.position, state.matrix.modelview.row[3];\n"
93 "END\n";
95 glGenProgramsARB(1, &prognum);
97 glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prognum);
98 glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
99 strlen(prog1), (const GLubyte *) prog1);
101 assert(glIsProgramARB(prognum));
102 errno = glGetError();
103 printf("glGetError = %d\n", errno);
104 if (errno != GL_NO_ERROR)
106 GLint errorpos;
108 glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorpos);
109 printf("errorpos: %d\n", errorpos);
110 printf("%s\n", (char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB));
115 int main( int argc, char *argv[] )
117 glutInit( &argc, argv );
118 glutInitWindowPosition( 0, 0 );
119 glutInitWindowSize( 250, 250 );
120 glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
121 glutCreateWindow(argv[0]);
122 glutReshapeFunc( Reshape );
123 glutKeyboardFunc( Key );
124 glutDisplayFunc( Display );
125 Init();
126 glutMainLoop();
127 return 0;