
March 2024

This project began with the intent of communicating detailed methods for working with OpenGL from Ada. But the code has grown ugly and complex because Ada protects so well against illogical addenda. And the addenda just kept on accumulating because the game always needed just 1 more feature.

So rather than immediately addressing the formidable task of code simplification, FTTB I am going to try to explain some of the more obscure tricks being used.

See thru doorways.==========================================

The Temple uses a box-interior room with a cutout on the one side with a door to allow see-thru, but that complicates the interior texture mapping.

Most other see-thru doors are accomplished using the magical "discard" statement in a frag shader. Door texture images have a central opening and a door frame. The discard statement is used to make all but the door frame disappear. Uniforms are used to communicate the location & extent of area to be discarded.

A subtle problem that can hinder the frag shader discard is that it can only make items disappear that it draws itself. It cannot discard items drawn in the next room by some other frag shader. Normally the objects drawn in the next room are 1-sided, like walls, pictures & doors, and only show inside the other room. But I originally created 2-sided doors, with outward normals in both directions and textures on both sides. This precluded using frag shader discards until I discovered that 2-sided textures were a bad idea.

Now to complete the task, the room on the other side of the door must be drawn as well, but BEFORE drawing the current room. Finally, to get the proper view into the next room, all the other-room objects must be translated into the coordinates of the current-room. Most rooms here use the same coordinate range in the X & Z directions: [-10..+10], with +Y being upward. So most room changes involve either X or Z changing by 20 units when passing thru a doorway.


