So I'm playing around with OpenGL and drawing bitmaps and it seems at times glRasterPos is off by a pixel. When I get the GL_CURRENT_RASTERPOSITION I can see that rouding (floor) is causing this error. For example when I set the x-pos to 110 it results in 109.9998 which leads the bitmap to be drawn on pixel 109. Any ideas why I can't draw to pixel 110? See example and output below:
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0, 800, 800, 0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glViewport(0, 0, 800, 800);
glRasterPos2f (100.0, 12);
glGetFloatv(GL_CURRENT_RASTER_POSITION, pos);
printf("%f\n",pos[0]);
glRasterPos2f (110.0, 30.0);
glGetFloatv(GL_CURRENT_RASTER_POSITION, pos);
printf("%f\n",pos[0]);
glRasterPos2f (111.0, 45);
glGetFloatv(GL_CURRENT_RASTER_POSITION, pos);
printf("%f\n",pos[0]);
Console Output:
100.000000
109.999992
111.000015
UPDATE: It seems to have to do with the Ortho2D and the glViewport values I am using.