1 /* Test glGenProgramsNV(), glIsProgramNV(), glLoadProgramNV() */
11 static void Init( void )
16 static const char *prog1
=
18 "PARAM Diffuse = state.material.diffuse; \n"
19 "MOV result.color, Diffuse;\n"
20 "MOV result.position, vertex.position;\n"
23 const float Diffuse
[4] = { 0.0, 1.0, 0.0, 1.0 };
24 glMaterialfv(GL_FRONT_AND_BACK
, GL_DIFFUSE
, Diffuse
);
27 glGenProgramsARB(1, &prognum
);
29 glBindProgramARB(GL_VERTEX_PROGRAM_ARB
, prognum
);
30 glProgramStringARB(GL_VERTEX_PROGRAM_ARB
, GL_PROGRAM_FORMAT_ASCII_ARB
,
31 strlen(prog1
), (const GLubyte
*) prog1
);
33 assert(glIsProgramARB(prognum
));
34 errnum
= glGetError();
35 printf("glGetError = %d\n", errnum
);
36 if (errnum
!= GL_NO_ERROR
)
40 glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB
, &errorpos
);
41 printf("errorpos: %d\n", errorpos
);
42 printf("%s\n", (char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB
));
46 static void Display( void )
48 glClearColor(0.3, 0.3, 0.3, 1);
49 glClear( GL_COLOR_BUFFER_BIT
| GL_DEPTH_BUFFER_BIT
);
51 glEnable(GL_VERTEX_PROGRAM_NV
);
53 glBegin(GL_TRIANGLES
);
55 glVertex3f( 0.9, -0.9, -0.0);
57 glVertex3f( 0.9, 0.9, -0.0);
59 glVertex3f(-0.9, 0.0, -0.0);
67 static void Reshape( int width
, int height
)
69 glViewport( 0, 0, width
, height
);
70 glMatrixMode( GL_PROJECTION
);
72 glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
73 glMatrixMode( GL_MODELVIEW
);
75 /*glTranslatef( 0.0, 0.0, -15.0 );*/
79 static void Key( unsigned char key
, int x
, int y
)
94 int main( int argc
, char *argv
[] )
96 glutInit( &argc
, argv
);
97 glutInitWindowPosition( 0, 0 );
98 glutInitWindowSize( 250, 250 );
99 glutInitDisplayMode( GLUT_DEPTH
| GLUT_RGB
| GLUT_SINGLE
);
100 glutCreateWindow(argv
[0]);
102 glutReshapeFunc( Reshape
);
103 glutKeyboardFunc( Key
);
104 glutDisplayFunc( Display
);