gifLegacy OpenGL Issues

Geodesica-SFX comes in two builds: Geodesica-SFX-OpenGL and Geodesica-SFX-MesaGL.


Geodesica-SFX-OpenGL uses a fixed function pipeline. All data is rendered using Immediate Mode and nothing is cached on the graphics card. This legacy approach allows thousands of hubs and struts to be drawn without choking vertex buffer RAM on the graphics card. On modern PC’s the width of the memory bus between the motherboard RAM and the graphics card is so wide and fast that drawing in Immediate Mode does not incur a speed penalty. Further, not all modern cards have enough memory to store the required vertex shaders for large hub and strut quantities without slowing the view to crawl. Yes, Immediate Mode is faster.

Geodesica-SFX-OpenGL Rendering Bugs

The main OpenGL rendering bug with some graphics drivers concerns OpenGL text and the Fog depth cue. Labels on the far side of the sphere should be dimmed by the Fog colour. The MesaGL version does not have this bug. See the two images below; the first image shows the OpenGL bug, the second image shows the MesaGL fix…


OpenGL text rendering bug: labels on far side of sphere unaffected by fog depth cue.


MesaGL text rendering bug fix: labels on far side of sphere are correctly mixed with the fog colour.


Geodesica-SFX-MesaGL uses software rendering as opposed to the hardware rendering of the graphics card and its driver. Of course, software rendering is much slower, but it allows the program to run on the latest graphics cards, some of which fail to render a legacy fixed function pipeline.

Geodesica-SFX-MesaGL links to its own software equivalents of opengl32.dll and glu32.dll which are kept inside the Geodesica-SFX root directory. These libraries must not be moved. If you remove the opengl32.dll library, Geodesica-SFX-MesaGL will link back to the system opengl32.dll instead, thus restoring accelerated hardware rendering. However, in order to solve various software rendering bugs, Geodesica-SFX-MesaGL has been compiled specifically for its own version of opengl32.dll. For example, the Fog Depth Cue and Ground Plane cannot be shown simultaneously.

To keep Geodesica-SFX-MesaGL working as fast as possible, keep the following points in mind:

  1. Do not show the ground plane as this uses a texture.
  2. Only show hub and strut meshes when necessary; alternatively, bring up the Attrributes window and change their GL_POLYGON_MODE from GL_FILL (which uses lighting) to GL_LINE or GL_POINT (which do not use lighting). This speeds up screen redraw but is only an issue with higher frequency spheres (eg 10V and above).
  3. When rotating the trackball or moving the camera, the GL_POLYGON_MODE for Cells, Struts and Hubs is temporarily changed to the settings on the OpenGL tab of the Preferences window. This speeds up screen redraw whilst the scene is in motion. When the mouse is released, the GL_POLYGON_MODE is restored to the setting on the Attributes window.


Geodesica-SFX-MesaGL Rendering Bugs

There are some glitches for which there is no workaround at the present time:

Why use a fixed function pipeline?

There are many reasons why I have chosen to keep the fixed function pipeline in my code, not least of which is the ability to draw in Immediate Mode which is most favourable for rendering, picking and modelling a Quad-Edge data structure. Speed is not an issue in Geodesica-SFX except when tumbling the view with large quanties of hub and strut meshes; but hubs and struts are only generated when a dome is finalized, and they can easiliy be hidden using the Attributes window, thus speeding the view back up again.

Consider a 16V icosahedron with its dual. The vertex, edge and face data is:

MODE: QuadEdge. Primal Data.
Primal lattice:
   Total Vertices  = 2562
     Non Degenerate vertices = 2562
     Degenerate vertices     = 0
     Truncation bisectors    = 0
   Total Edges = 7680
     Non Degenerate edges = 7680
     Degenerate edges     = 0
   TotalCells = 5120
     Non Degenerate cells      = 5120
     Degenerate cells          = 0
     Cells on truncation plane = 0
Primal lattice satisfies Euler's formula V - E + F = 2
MODE: QuadEdge. Dual Data.
Dual lattice:
   Total Vertices  = 5120
     Non Degenerate vertices = 5120
     Degenerate vertices     = 0
     Truncation bisectors    = 0
   Total Edges = 7680
     Non Degenerate edges = 7680
     Degenerate edges     = 0
   TotalCells = 2562
     Non Degenerate cells      = 2562
     Degenerate cells          = 0
     Cells on truncation plane = 0
Dual Lattice satisfies Euler's formula V - E + F = 2

Now consider the amount vertices required for a single cylindrical hub with 24 sides:

 int iSideNum = 24;
 int iVQuantity = (iSideNum*2) + 2;                
 int iTQuantity = (iSideNum*2) + (iSideNum*2);      
 int iIQuantity = 3*iTQuantity;                    
 // 50 vertices
 // 96 triangles + 2x24 (top and bottom) = 144;
 // 288 indices
 // Primal Hub quantity    =   2562
                           = 128100 vertices
                           = 368928 triangles
 // Dual Hub quantity      =   5120
                           = 256000 vertices
                           = 491520 triangles
                             256000 +
 // Total Hub vertices     = 384100
                             491520 +
 // Total Hub triangles    = 860448

That’s just for the hubs. If cylindrical struts are generated for both Primal and Dual, the triangle count jumps to:

 // Primal Edge quantity   =  7680
 // Dual Edge quantity     =  7680
                           =  7680 +
 // Total Edges            = 15360
                                96 x
 // Total Edge triangles = 1474560     
 // Total triangles        1474560
                            860448 +
                         = 2335008

Only Immediate Mode can draw this quantity of data this without choking mid-range graphics cards. At the time of writing, implementing a CLOD system for hubs and struts is not an option as the vertices are used for hub export.

Lastly, because double precision is required for dimensional accuracy, all my vertex data uses doubles instead of floats. Modern vertex shaders operate on floats; if you send some GPUs doubles, they get ‘chopped’ into a floats. The consequence is a loss of precision when logging and exporting data.

I could wax lyrical for several pages on why I think OpenGL should have kept the fixed function pipeline as a mandatory option for drivers. The flexibility and power of Immediate Mode should never have been rescinded. I am also baffled why drawing functions like glVertex, glQuad, and glPolygon are now legacy code. All because vertex shaders (which were designed primarly for games) require triangles only. Of course, a new fangled graphics card generally requires a new fangled computer. I am reminded of the Phoebus lightbulb cartel of the early 19th century, who deliberately engineered a shorter-lived lightbulb and so gave rise to “planned obsolescence”.

Geodesica version 1.0 will use vertex shaders and the legacy fixed function pipeline will be removed from the code. Yet I fear the overall cost in program complexity will prove to be rather exhorbitant; further, the code will probably only run on very high-end graphics cards which are beyond the budget of most users. In the meantime, Geodesica-SFX-MesaGL seems like a good solution.