#include #include #include struct logger_point { float x,y,z; struct { unsigned char r, g, b, a; } c; } p[] = { {0,0,0, {255,255,255,0}}, {1,0,0, {255,255,255,0}}, }; void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnableClientState(GL_COLOR_ARRAY); glEnableClientState(GL_VERTEX_ARRAY); printf("A: glGetError() -> "); printf("%d\n", glGetError()); glVertexPointer(3, GL_FLOAT, sizeof(struct logger_point), &p[0].x); printf("B: glGetError() -> "); printf("%d\n", glGetError()); glColorPointer(3, GL_UNSIGNED_BYTE, sizeof(struct logger_point), &p[0].c); printf("C: glGetError() -> "); printf("%d\n", glGetError()); glDrawArrays(GL_LINE_STRIP, 0, 2); printf("D: glGetError() -> "); printf("%d\n", glGetError()); glutSwapBuffers(); } int main(int argc, char** argv) { // GLUT Window Initialization: glutInit (&argc, argv); glutInitWindowSize (400, 300); glutInitDisplayMode ( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); glutCreateWindow ("GLUT example"); // Register callbacks: glutDisplayFunc (display); // Turn the flow of control over to GLUT glutMainLoop (); return 0; }