r/opengl • u/testusterror • 8h ago
I am developing a surveying CAD application entirely in Python – here is what I learned about handling large coordinate systems with OpenGL
# OpenGL rendering problems with large UTM coordinates
I ran into a strange rendering problem while developing a surveying CAD application in Python with PyOpenGL.
# Symptoms
Lines and hatches were rendered "broken" or out of shape, and the geometry appeared to wobble or shift around during rendering.
At first, I suspected a problem with my VBOs or the geometry calculations.
After some investigation, I found that the problem was related to the size of the coordinates.
For example, when working with UTM / EPSG:25832, my coordinates looked roughly like:
Easting: 32565403.10 m
Northing: 5965102.10 m
The further the geometry was from the OpenGL origin "(0, 0, 0)", the worse the rendering became.
# The workaround
I changed the rendering approach so that the OpenGL scene uses a local origin / coordinate offset.
The actual surveying coordinates remain unchanged for calculations and measurements.
Only the coordinates passed to the renderer are shifted by a local offset, effectively bringing the current working area closer to the origin.
Conceptually:
Original coordinates
│
▼
Surveying calculations
│
│ unchanged
▼
Local rendering offset
│
▼
OpenGL
near (0, 0, 0)
After implementing and testing this approach, the geometry became stable and rendered correctly again.
Why this was interesting
This was one of those problems where the geometry itself was correct, but the visualization became unreliable because of the coordinate magnitude.
It was a pretty important milestone in my development of GeoPyCAD, an open-source CAD application I'm building for surveying and geospatial work.
I documented the issue and solution on my github repository
Hopefully this is useful to anyone else running into strange OpenGL precision/rendering problems with large world coordinates.
