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 GLuint arrayObj
, elementObj
;
36 static void Init( void )
41 static const char *prog1
=
43 "MOV result.color, vertex.color;\n"
44 "MOV result.position, vertex.position;\n"
47 glGenProgramsARB(1, &prognum
);
48 glBindProgramARB(GL_VERTEX_PROGRAM_ARB
, prognum
);
49 glProgramStringARB(GL_VERTEX_PROGRAM_ARB
, GL_PROGRAM_FORMAT_ASCII_ARB
,
50 strlen(prog1
), (const GLubyte
*) prog1
);
52 assert(glIsProgramARB(prognum
));
54 printf("glGetError = %d\n", errno
);
55 if (errno
!= GL_NO_ERROR
)
59 glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB
, &errorpos
);
60 printf("errorpos: %d\n", errorpos
);
61 printf("%s\n", (char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB
));
65 glEnableClientState( GL_VERTEX_ARRAY
);
66 glEnableClientState( GL_COLOR_ARRAY
);
68 glGenBuffersARB(1, &arrayObj
);
69 glBindBufferARB(GL_ARRAY_BUFFER_ARB
, arrayObj
);
70 glBufferDataARB(GL_ARRAY_BUFFER_ARB
, sizeof(verts
), verts
, GL_STATIC_DRAW_ARB
);
72 glVertexPointer( 3, GL_FLOAT
, sizeof(verts
[0]), 0 );
73 glColorPointer( 4, GL_UNSIGNED_BYTE
, sizeof(verts
[0]), (void *)(3*sizeof(float)) );
79 static void Display( void )
81 glClearColor(0.3, 0.3, 0.3, 1);
82 glClear( GL_COLOR_BUFFER_BIT
| GL_DEPTH_BUFFER_BIT
);
84 glEnable(GL_VERTEX_PROGRAM_ARB
);
86 /* glDrawArrays( GL_TRIANGLES, 0, 3 ); */
87 glDrawArrays( GL_TRIANGLES
, 1, 3 );
93 static void Reshape( int width
, int height
)
95 glViewport( 0, 0, width
, height
);
96 glMatrixMode( GL_PROJECTION
);
98 glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
99 glMatrixMode( GL_MODELVIEW
);
101 /*glTranslatef( 0.0, 0.0, -15.0 );*/
105 static void Key( unsigned char key
, int x
, int y
)
120 int main( int argc
, char *argv
[] )
122 glutInit( &argc
, argv
);
123 glutInitWindowPosition( 0, 0 );
124 glutInitWindowSize( 250, 250 );
125 glutInitDisplayMode( GLUT_RGB
| GLUT_SINGLE
| GLUT_DEPTH
);
126 glutCreateWindow(argv
[0]);
128 glutReshapeFunc( Reshape
);
129 glutKeyboardFunc( Key
);
130 glutDisplayFunc( Display
);