blob: 29329773143b92c2ea62e4ee76bf97358e020890 [file] [log] [blame]
Keith Whitwellb4517522006-06-22 16:32:19 +00001/* Test glGenProgramsNV(), glIsProgramNV(), glLoadProgramNV() */
2
3#include <assert.h>
4#include <string.h>
5#include <stdio.h>
6#include <stdlib.h>
7#include <math.h>
José Fonseca479ea7d2009-01-23 14:35:36 +00008#include <GL/glew.h>
Keith Whitwellb4517522006-06-22 16:32:19 +00009#include <GL/glut.h>
10
11static void Init( void )
12{
13 GLint errno;
14 GLuint prognum;
15
16 static const char *prog1 =
17 "!!ARBvp1.0\n"
18 "MOV result.color, vertex.color;\n"
19/* "MOV result.color, {0,0,0,1};\n" */
20 "MOV result.position, vertex.position;\n"
21 "END\n";
22
23
24 glGenProgramsARB(1, &prognum);
25
26 glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prognum);
27 glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
28 strlen(prog1), (const GLubyte *) prog1);
29
30 assert(glIsProgramARB(prognum));
31 errno = glGetError();
32 printf("glGetError = %d\n", errno);
33 if (errno != GL_NO_ERROR)
34 {
35 GLint errorpos;
36
37 glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorpos);
38 printf("errorpos: %d\n", errorpos);
39 printf("%s\n", (char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB));
40 }
41}
42
43static void Display( void )
44{
45 glClearColor(0.3, 0.3, 0.3, 1);
Keith Whitwell2c8e50c2007-12-19 13:13:42 +000046 glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
Keith Whitwellb4517522006-06-22 16:32:19 +000047
48 glEnable(GL_VERTEX_PROGRAM_NV);
49
50 glBegin(GL_TRIANGLES);
Keith Whitwellded6ce22007-12-19 15:13:20 +000051 glColor3f(0,0,.7);
52 glVertex3f( 0.9, -0.9, -0.0);
53 glColor3f(.8,0,0);
54 glVertex3f( 0.9, 0.9, -0.0);
55 glColor3f(0,.9,0);
56 glVertex3f(-0.9, 0.0, -0.0);
Keith Whitwellb4517522006-06-22 16:32:19 +000057 glEnd();
58
59
60 glFlush();
61}
62
63
64static void Reshape( int width, int height )
65{
66 glViewport( 0, 0, width, height );
67 glMatrixMode( GL_PROJECTION );
68 glLoadIdentity();
69 glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
70 glMatrixMode( GL_MODELVIEW );
71 glLoadIdentity();
72 /*glTranslatef( 0.0, 0.0, -15.0 );*/
73}
74
75
76static void Key( unsigned char key, int x, int y )
77{
78 (void) x;
79 (void) y;
80 switch (key) {
81 case 27:
82 exit(0);
83 break;
84 }
85 glutPostRedisplay();
86}
87
88
89
90
91int main( int argc, char *argv[] )
92{
93 glutInit( &argc, argv );
94 glutInitWindowPosition( 0, 0 );
95 glutInitWindowSize( 250, 250 );
Keith Whitwell2c8e50c2007-12-19 13:13:42 +000096 glutInitDisplayMode( GLUT_DEPTH | GLUT_RGB | GLUT_SINGLE );
Keith Whitwellb4517522006-06-22 16:32:19 +000097 glutCreateWindow(argv[0]);
José Fonseca479ea7d2009-01-23 14:35:36 +000098 glewInit();
Keith Whitwellb4517522006-06-22 16:32:19 +000099 glutReshapeFunc( Reshape );
100 glutKeyboardFunc( Key );
101 glutDisplayFunc( Display );
102 Init();
103 glutMainLoop();
104 return 0;
105}