18 { 0x00, 0x00, 0xff, 0x00 }
22 { 0x00, 0xff, 0x00, 0x00 }
26 { 0xff, 0x00, 0x00, 0x00 }
29 { { -0.9, -0.9, 0.0 },
30 { 0xff, 0xff, 0xff, 0x00 }
34 static void Init( void )
39 static const char *prog1
=
41 "MOV result.color, vertex.color;\n"
42 "MOV result.position, vertex.position;\n"
45 glGenProgramsARB(1, &prognum
);
46 glBindProgramARB(GL_VERTEX_PROGRAM_ARB
, prognum
);
47 glProgramStringARB(GL_VERTEX_PROGRAM_ARB
, GL_PROGRAM_FORMAT_ASCII_ARB
,
48 strlen(prog1
), (const GLubyte
*) prog1
);
50 assert(glIsProgramARB(prognum
));
51 errnum
= glGetError();
52 printf("glGetError = %d\n", errnum
);
53 if (errnum
!= GL_NO_ERROR
)
57 glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB
, &errorpos
);
58 printf("errorpos: %d\n", errorpos
);
59 printf("%s\n", (char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB
));
63 glEnableClientState( GL_VERTEX_ARRAY
);
64 glEnableClientState( GL_COLOR_ARRAY
);
66 glVertexPointer( 3, GL_FLOAT
, sizeof(verts
[0]), verts
[0].pos
);
67 glColorPointer( 4, GL_UNSIGNED_BYTE
, sizeof(verts
[0]), verts
[0].color
);
73 static void Display( void )
75 glClearColor(0.3, 0.3, 0.3, 1);
76 glClear( GL_COLOR_BUFFER_BIT
| GL_DEPTH_BUFFER_BIT
);
78 glEnable(GL_VERTEX_PROGRAM_ARB
);
80 /* glDrawArrays( GL_TRIANGLES, 0, 3 ); */
81 glDrawArrays( GL_TRIANGLES
, 1, 3 );
87 static void Reshape( int width
, int height
)
89 glViewport( 0, 0, width
, height
);
90 glMatrixMode( GL_PROJECTION
);
92 glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
93 glMatrixMode( GL_MODELVIEW
);
95 /*glTranslatef( 0.0, 0.0, -15.0 );*/
99 static void Key( unsigned char key
, int x
, int y
)
114 int main( int argc
, char *argv
[] )
116 glutInit( &argc
, argv
);
117 glutInitWindowPosition( 0, 0 );
118 glutInitWindowSize( 250, 250 );
119 glutInitDisplayMode( GLUT_RGB
| GLUT_SINGLE
| GLUT_DEPTH
);
120 glutCreateWindow(argv
[0]);
122 glutReshapeFunc( Reshape
);
123 glutKeyboardFunc( Key
);
124 glutDisplayFunc( Display
);