gallium: change remaining util functions to use cso sampler views
[mesa/mesa-lb.git] / progs / trivial / vp-clip.c
blob267b927b93f4d4367078df370363c893cab58b8d
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.color, vertex.color;\n"
19 "MOV result.position, vertex.position;\n"
20 "END\n";
22 glGenProgramsARB(1, &prognum);
24 glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prognum);
25 glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
26 strlen(prog1), (const GLubyte *) prog1);
28 assert(glIsProgramARB(prognum));
29 errno = glGetError();
30 printf("glGetError = %d\n", errno);
31 if (errno != GL_NO_ERROR)
33 GLint errorpos;
35 glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorpos);
36 printf("errorpos: %d\n", errorpos);
37 printf("%s\n", (char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB));
41 static void Display( void )
43 glClearColor(0.3, 0.3, 0.3, 1);
44 glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
46 glEnable(GL_VERTEX_PROGRAM_NV);
48 glBegin(GL_TRIANGLES);
49 glColor3f(0,0,1);
50 glVertex3f( 2.0, -2.0, 0.0);
51 glColor3f(0,1,0);
52 glVertex3f( 2.0, 2.0, 0.0);
53 glColor3f(1,0,0);
54 glVertex3f(-2.0, 0.0, 0.0);
55 glEnd();
58 glFlush();
62 static void Reshape( int width, int height )
64 glViewport( 0, 0, width, height );
65 glMatrixMode( GL_PROJECTION );
66 glLoadIdentity();
67 glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
68 glMatrixMode( GL_MODELVIEW );
69 glLoadIdentity();
70 /*glTranslatef( 0.0, 0.0, -15.0 );*/
74 static void Key( unsigned char key, int x, int y )
76 (void) x;
77 (void) y;
78 switch (key) {
79 case 27:
80 exit(0);
81 break;
83 glutPostRedisplay();
89 int main( int argc, char *argv[] )
91 glutInit( &argc, argv );
92 glutInitWindowPosition( 0, 0 );
93 glutInitWindowSize( 250, 250 );
94 glutInitDisplayMode( GLUT_RGB | GLUT_SINGLE | GLUT_DEPTH );
95 glutCreateWindow(argv[0]);
96 glewInit();
97 glutReshapeFunc( Reshape );
98 glutKeyboardFunc( Key );
99 glutDisplayFunc( Display );
100 Init();
101 glutMainLoop();
102 return 0;