mesa-demos: NOTE! Default branch is now main
[mesa-demos.git] / src / trivial / vp-tri-imm.c
blobcb93c9c6c1783b3907c454f8a9df79151ba43c94
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 <glad/glad.h>
9 #include "glut_wrap.h"
11 static void Init( void )
13 GLint errnum;
14 GLuint prognum;
16 static const char *prog1 =
17 "!!ARBvp1.0\n"
18 "ADD result.color, vertex.color, {.5}.x;\n"
19 "MOV result.position, 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 errnum = glGetError();
31 printf("glGetError = %d\n", errnum);
32 if (errnum != 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,0);
51 glVertex3f( 0.9, -0.9, -0.0);
52 glVertex3f( 0.9, 0.9, -0.0);
53 glVertex3f(-0.9, 0.0, -0.0);
54 glEnd();
57 glFlush();
61 static void Reshape( int width, int height )
63 glViewport( 0, 0, width, height );
64 glMatrixMode( GL_PROJECTION );
65 glLoadIdentity();
66 glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
67 glMatrixMode( GL_MODELVIEW );
68 glLoadIdentity();
69 /*glTranslatef( 0.0, 0.0, -15.0 );*/
73 static void Key( unsigned char key, int x, int y )
75 (void) x;
76 (void) y;
77 switch (key) {
78 case 27:
79 exit(0);
80 break;
82 glutPostRedisplay();
88 int main( int argc, char *argv[] )
90 glutInit( &argc, argv );
91 glutInitWindowPosition( 0, 0 );
92 glutInitWindowSize( 250, 250 );
93 glutInitDisplayMode( GLUT_DEPTH | GLUT_RGB | GLUT_SINGLE );
94 glutCreateWindow(argv[0]);
95 gladLoadGL();
96 glutReshapeFunc( Reshape );
97 glutKeyboardFunc( Key );
98 glutDisplayFunc( Display );
99 Init();
100 glutMainLoop();
101 return 0;