1 /* Test glGenProgramsNV(), glIsProgramNV(), glLoadProgramNV() */
8 #define GL_GLEXT_PROTOTYPES
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
);
22 glRotatef(Zrot
, 0, 0, 1);
26 glVertexAttrib3fARB(3, 1, 0.5, 0.25);
27 glBegin(GL_TRIANGLES
);
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);
48 static void Reshape( int width
, int height
)
50 glViewport( 0, 0, width
, height
);
51 glMatrixMode( GL_PROJECTION
);
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
);
57 /*glTranslatef( 0.0, 0.0, -15.0 );*/
61 static void Key( unsigned char key
, int x
, int y
)
80 static void Init( void )
85 static const char *prog1
=
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"
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
)
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
);