Fixing the pixel drift.

One of things thats really irritated me for some time is the inability of OCC to display a point exactly where I want (exactly) aligned over a grid). It will always display it at least 1 pixel out in at least one screen direction, normally both.

Finally I found a simple fix - the problem is due to round-off error in computing the origin of the marker bitmap as a "float". Unsing pure "int" mathe gives a better result. In OpenGL_initelem.c, InitPMFont find the line (about 2210) that reads

glBitmap( w, h, (float)(array[k1][k2].width) / ( float )2.0,
(float)(array[k1][k2].height) / ( float )2.0,
( float )30.0, ( float )30.0, (const GLubyte *) &raster[offset]);

and change it to

glBitmap( w, h, (float) (w / 2), (float) (h / 2), 30.0f, 30.0f, (const GLubyte *) &raster[offset]);

the recompile the TKOpenGL library. I've tested on Win32 but it "should" work *nix as well as the problem is common.

Pete

P Dolbey's picture

OCCPATCH