#include #include #include #include #include #define WINDSIZEX 100 #define WINDSIZEY 100 #define SIZEW 4 #define SIZEH 4 // Draw function used by many test casses static void Draw() { glBegin(GL_POLYGON); glVertex3f(25.0, 25.0, 0.0); glVertex3f(25.0, 75.0, 0.0); glVertex3f(75.0, 75.0, 0.0); glVertex3f(75.0, 25.0, 0.0); glEnd(); } void init(void) { glClearColor (1,1,1,1); glClearDepth(0.0); glDisable (GL_DITHER); } static void test(void) { GLfloat buf[40]; glColor3f(0.0, 1.0, 0.0); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); glEnable(GL_POLYGON_OFFSET_FILL); glEnable(GL_POLYGON_OFFSET_LINE); glPolygonOffset(0.0, 3000.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); Draw(); glReadPixels(25, 50, 1, 1, GL_RGBA, GL_FLOAT, &buf[0]); glReadPixels(24, 50, 1, 1, GL_RGBA, GL_FLOAT, &buf[4]); printf("get pixel values at (25,50): %f %f %f %f\n", buf[0], buf[1], buf[2], buf[3]); printf("get pixel values at (24, 50): %f %f %f %f\n", buf[4], buf[5], buf[6], buf[7]); } void display(void) { glViewport(0, 0, WINDSIZEX, WINDSIZEY); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, WINDSIZEX, 0, WINDSIZEY, 0, 1); //gluOrtho2D(0, WINDSIZEX, 0, WINDSIZEY); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); test(); } int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH); glutInitWindowSize(WINDSIZEX, WINDSIZEY); glutInitWindowPosition(100, 100); glutCreateWindow(argv[0]); init(); glutDisplayFunc(display); glutMainLoop(); return 0; }