#include #include #include #include #define WINDSIZEX 100 #define WINDSIZEY 100 static void Draw() { GLubyte bitmap[] = {0xff, 0xff, 0xff}; glDepthFunc(GL_ALWAYS); glColor4f(0.0, 0.0, 0.0, 1.0); glRasterPos3f(0.2, 0.2, 0.6); glBitmap(3, 1, 0, 0, 0, 0, bitmap); glDepthFunc(GL_LESS); glColor4f(1.0, 0.0, 0.0, 1.0); glRasterPos3f(0.2, 0.2, 0.0); glBitmap(1, 1, 0, 0, 0, 0, bitmap); glRasterPos3f(1.2, 0.2, 0.5); glBitmap(1, 1, 0, 0, 0, 0, bitmap); glRasterPos3f(2.2, 0.2, 1.0); glBitmap(1, 1, 0, 0, 0, 0, bitmap); } void init(void) { glDisable(GL_DITHER); glEnable(GL_DEPTH_TEST); } static void test(void) { GLfloat buf[9]; glClear(GL_COLOR_BUFFER_BIT); Draw(); glReadPixels(0, 0, 3, 1, GL_RGB, GL_FLOAT, buf); printf("draw pixel at (0, 0): %f %f %f\n", buf[0], buf[1], buf[2]); printf("draw pixel at (1, 0): %f %f %f\n", buf[3], buf[4], buf[5]); printf("draw pixel at (2, 0): %f %f %f\n", buf[6], buf[7], buf[8]); } void display(void) { glViewport(0, 0, WINDSIZEX, WINDSIZEY); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, WINDSIZEX, 0, WINDSIZEY, 2.0, -2.0); 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; }