I am working with a basically 2D application that does zoom by scaling X&Y and applying a translate to keep the cursor point steady. This works at lower scale factors, but as the scale factor gets larger it gets jittery. The numbers computed on the CPU look fine using float or double. But when drawn the display can be off by 10s or more pixels. The idea is when applying a zoom the user space coordinates X,Y should display at the same screen coordinate before and after. I use the following to apply the zoom and translation:
gl.glTranslatef(xTran, yTran, 0.0f);
gl.glScalef(zoom, zoom, 1.0f);
The problem is that from one frame to the next the point that should be stable is moving around. I presume this is some type of rounding error using floating point numbers, but have yet to find it. The following is example debug output for complementary (zoom in/out) from the CPU side:
Before. Zoom: 6687.519 xt: -6.052199E8 yt: -1.27062797E9 xformed x: 512.0 y: 384.0
Zooming by: 1.010025 inverse: 0.99007446 about: 500.0,441.0
After. Zoom: 6754.5615 xt: -6.1128723E8 yt: -1.28336602E9 xformed x: 512.0 y: 384.0
Before. Zoom: 6754.5615 xt: -6.1128723E8 yt: -1.28336602E9 xformed x: 512.0 y: 384.0
Zooming by: 0.99007446 inverse: 1.010025 about: 500.0,441.0
After. Zoom: 6687.519 xt: -6.052199E8 yt: -1.27062797E9 xformed x: 512.0 y: 384.0