#include #include #include #include #define WINDSIZEX 100 #define WINDSIZEY 100 void init(void) { glClearColor(0.0, 0.0, 0.0, 0.0); } static void test(void) { GLfloat buf[4]; GLubyte fillPattern[128]; int i; glClear(GL_COLOR_BUFFER_BIT); glColor3f(0.0, 1.0, 0.0); glEnable(GL_POLYGON_STIPPLE); for (i = 0; i < 128; i++) { fillPattern[i] = 0xFF; } glPolygonStipple(fillPattern); glBegin(GL_POLYGON); glVertex2f(1.0, 50.0); glVertex2f(70.0, 99.0); glVertex2f(80.0, 1.0); glEnd(); glReadPixels(50, 50, 1, 1, GL_RGB, GL_FLOAT, buf); printf("draw pixel at (50, 50): %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; }