10 static float Zrot
= 0.0;
13 static void Display( void )
15 glClearColor(0.3, 0.3, 0.3, 1);
16 glClear( GL_COLOR_BUFFER_BIT
| GL_DEPTH_BUFFER_BIT
);
18 glEnable(GL_VERTEX_PROGRAM_ARB
);
21 glRotatef(Zrot
, 0, 0, 1);
25 glVertexAttrib3fARB(3, 1, 0.5, 0.25);
26 glBegin(GL_TRIANGLES
);
28 glVertexAttrib3fARB(3, 1.0, 0.0, 0.0);
29 glVertexAttrib2fARB(0, -0.5, -0.5);
30 glVertexAttrib3fARB(3, 0.0, 1.0, 0.0);
31 glVertexAttrib2fARB(0, 0.5, -0.5);
32 glVertexAttrib3fARB(3, 0.0, 0.0, 1.0);
33 glVertexAttrib2fARB(0, 0, 0.5);
47 static void Reshape( int width
, int height
)
49 glViewport( 0, 0, width
, height
);
50 glMatrixMode( GL_PROJECTION
);
52 /* glFrustum( -2.0, 2.0, -2.0, 2.0, 5.0, 25.0 );*/
53 glOrtho(-2.0, 2.0, -2.0, 2.0, -2.0, 2.0 );
54 glMatrixMode( GL_MODELVIEW
);
56 /*glTranslatef( 0.0, 0.0, -15.0 );*/
60 static void Key( unsigned char key
, int x
, int y
)
79 static void Init( void )
84 static const char *prog1
=
86 "MOV result.color, vertex.attrib[3];\n"
88 "DP4 result.position.x, vertex.position, state.matrix.modelview.row[0];\n"
89 "DP4 result.position.y, vertex.position, state.matrix.modelview.row[1];\n"
90 "DP4 result.position.z, vertex.position, state.matrix.modelview.row[2];\n"
91 "DP4 result.position.w, vertex.position, state.matrix.modelview.row[3];\n"
94 glGenProgramsARB(1, &prognum
);
96 glBindProgramARB(GL_VERTEX_PROGRAM_ARB
, prognum
);
97 glProgramStringARB(GL_VERTEX_PROGRAM_ARB
, GL_PROGRAM_FORMAT_ASCII_ARB
,
98 strlen(prog1
), (const GLubyte
*) prog1
);
100 assert(glIsProgramARB(prognum
));
101 errno
= glGetError();
102 printf("glGetError = %d\n", errno
);
103 if (errno
!= GL_NO_ERROR
)
107 glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB
, &errorpos
);
108 printf("errorpos: %d\n", errorpos
);
109 printf("%s\n", (char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB
));
114 int main( int argc
, char *argv
[] )
116 glutInit( &argc
, argv
);
117 glutInitWindowPosition( 0, 0 );
118 glutInitWindowSize( 250, 250 );
119 glutInitDisplayMode( GLUT_RGB
| GLUT_DOUBLE
| GLUT_DEPTH
);
120 glutCreateWindow(argv
[0]);
122 glutReshapeFunc( Reshape
);
123 glutKeyboardFunc( Key
);
124 glutDisplayFunc( Display
);