The opengl red book refers to a “magic number” 0.375
(Quote from: )
http://glprogramming.com/red/appendixg.html#name1
or http://msdn.microsoft.com/en-us/library/ms537007(VS.85).aspx
An optimum compromise that allows all primitives to be specified at integer positions, while still ensuring predictable rasterization, is to translate x and y by 0.375, as shown in the following code sample. Such a translation keeps polygon and pixel image edges safely away from the centers of pixels, while moving line vertices close enough to the pixel centers.
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity( );
gluOrtho2D(0, width, 0, height);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity( );
glTranslatef(0.375, 0.375, 0.0);
/* render all primitives at integer positions */
I have had a look to find out what the magic number “0.375” actually is.
After a lot of searching, the only suggestion that I can think of is that it has something to do with floating point to integer rounding errors.
Does anyone know why it is 0.375? (and not 0.374 or 0.376 etc)