#include #include #include #include #define WINDSIZEX 100 #define WINDSIZEY 100 void init(void) { glClearColor(0.0, 0.0, 0.0, 1.0); } static void test(void) { GLfloat buf[4]; //glDrawBuffer(GL_FRONT); //glReadBuffer(GL_FRONT); glClear(GL_COLOR_BUFFER_BIT); glReadPixels(5, 6, 1, 1, GL_RGBA, GL_FLOAT, buf); printf("draw pixel at (5, 6): %f %f %f\n", buf[0], buf[1], buf[2]); } void display(void) { glViewport(0, 0, WINDSIZEX, WINDSIZEY); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(0, WINDSIZEX, 0, WINDSIZEY); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); test(); } int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); glutInitWindowSize(WINDSIZEX, WINDSIZEY); glutInitWindowPosition(100, 100); glutCreateWindow(argv[0]); init(); glutDisplayFunc(display); glutMainLoop(); return 0; }