#include #include #include #include #define WINDSIZEX 100 #define WINDSIZEY 100 void init(void) { GLfloat sizeRange[2], sizeStep; glClearColor(0.0, 0.0, 0.0, 0.0); glColor4f(1.0, 0.0, 0.0, 1.0); glDisable(GL_DITHER); glEnable(GL_POINT_SMOOTH); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE); // Get min and max point sizes glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE, sizeRange); if (glGetError() != GL_NO_ERROR) { glGetFloatv(GL_POINT_SIZE_RANGE, sizeRange); } // Get granularity between min and max glGetFloatv(GL_POINT_SIZE_GRANULARITY, &sizeStep); printf("size range: %f %f; size step: %f \n", sizeRange[0], sizeRange[1], sizeStep); } static void test(void) { GLfloat buf[25]; int row, col; glPointSize(3); glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_POINTS); glVertex2f(2.5, 2.5); glEnd(); glReadPixels(0, 0, 5, 5, GL_RED, GL_FLOAT, buf); for (row = 0; row < 5; row++) for (col = 0; col < 5; col++) printf("draw pixel at (%d, %d): %f\n", row, col, buf[row*5+col]); } 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; }