#include #include #include #include #define WINDSIZEX 100 #define WINDSIZEY 100 #define X1 5.5 #define Y1 6.5 #define X2 10.5 #define Y2 12.5 void init(void) { GLfloat fragColor[] = {0.8, 0.5, 0.2, 1.0}; GLfloat fogColor[] = {0.1, 0.1, 0.8, 1.0}; glDisable (GL_DITHER); glEnable(GL_FOG); glFogfv (GL_FOG_COLOR, fogColor); glFogf (GL_FOG_START, 0.1); glFogf (GL_FOG_END, 0.9); glFogf (GL_FOG_COORDINATE_SOURCE, GL_FOG_COORDINATE); glColor4fv(fragColor); glFogf(GL_FOG_MODE, GL_LINEAR); } static void test(void) { GLfloat buf[3]; GLubyte bitmap[] = {0xFF}; glClear (GL_COLOR_BUFFER_BIT); glFogCoordf(0.2); glRasterPos2f (X1, Y1); glBitmap (1, 1, 0.0, 0.0, 0.0, 0.0, bitmap); glFogCoordf(0.8); glRasterPos2f (X2, Y2); glBitmap (1, 1, 0.0, 0.0, 0.0, 0.0, bitmap); glReadPixels(X1, Y1, 1, 1, GL_RGB, GL_FLOAT, buf); printf("pixel: %f %f %f\n", buf[0], buf[1], buf[2]); glReadPixels(X2, Y2, 1, 1, GL_RGB, GL_FLOAT, buf); printf("pixel: %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; }