Simultaneous Solutions (GLAM part 1)
New York
Last week I went to visit my teen nephew and niece in New York. A wonderful city of contrasts, where opulence blends with poverty, with shops selling a margherita for 2 bucks a slice next to a place offering margaritas at 20 bucks a sip, and streets full of people either with pots of cash, or those blowing cash on pot. Likewise my nephew, (let’s call him Nathan) and my niece (pseudonymised here to Norma), present equally contrasting mindsets and approaches to life, yet manage to live semi-harmoniously in this subtly harsh environment.
Norma is an impossibly adorable individual, well mannered and courteous while being confident and sharp; were it not for a rather intense interest in the lives of serial killers and their victims, you’d imagine her as a Disney princess. Nathan on the other hand is a man who prefers solitude, gaming and basketball. While startling everyone now and then with his wit and intelligence, he is incredibly self-contained. I can imaging him walking down the corridors of school, leaning back at a gravity-defying angle, looking left and right, but never straight ahead, head tilted back but eyes downwards, enabling him to look down his nose at people much taller than him. While being devoted to each other in secret, they would never agree on anything, and never admit that the other has a point however similar it was to their own, deprecating common interest and amplifying minor differences.
If only one could rationalise their disagreements, prove that their by-and-large on the same side, then surely I would have missed out the entertainment their mini-battles provided. Indeed, while there is an inward joy when you see your sibling’s kids make their parents pull their hair out (as an uncle I am obliged to encourage this kind of behaviour), harmony between the two would indeed be a novel alternative experience in my sister’s household.
Such is the rational for the conflicts that plague the globe today, and indeed the world of Graphical Games programming.
Graphical Coding
I would like to be able to program some games. But I understand graphics so little. As an intermittent coder, each example one comes across appears to have paradigms which make perfect sense yet remain incompatible with each other. One day I am offered one magical example, the next, another day another one from a different book of incomprehensible incantations, both blending actual Game Logic with the alien hieroglyphics representing their respective backends. Hence, until now, I have mainly developed for the terminal, finding no easy entry into the land of graphics. Games require interaction as well as graphics. Examples available typically intertwine Game Logic, Interaction Handling, The Graphical outputs, The Game Loop within the code, the entanglement further complicating the journey into learning.
By some chance, one Redditor u/FirstAd8230 posted a GLFW/OpenGL demo. Within two hours SANKO or u/sthrowawayr posted an SDL3 equivalent yielding and identical output, down to the look and interaction purely because he had difficulty in installing GLFW on his setup. This was the Rosetta Stone I was looking for. Both bits of code had identical Game Logic. Treating these like one would treat simultaneous equations, one is able to extract the common code which represent the game engine easily. The residue then are backend specific code handling the other components mentioned above; still looking complicated but now manageable as it is possible to extract each call to the backends from the game logic.
From this, The Graphics Layer Abstraction Module or GLAM is born. A tool that transforms the complexity of the backends into simple calls, that can use either backend simply by changing one line of code. The simple demo above had all the components to make many possible games and utilities, but to add simplicity one has to have a tool that abstracts away the residual complexity altogether. How? GLAM offers two modules for now (GLAM::OpenGL and GLAM::SDL). These modules provide 1) A means to capture key board and mouse events that can change Game State 2) A means to represent the Game State graphically using only one capability (the ability to draw a triangle) to render all graphical output 3) A way to start and exit the Game Loop.

What is the benefit? Well the simplicity allows the occasional developer, like myself, developer to concentrate on the Game Logic, without remembering complex construction of graphical tools. It further permits those with difficulties in installing one backend for what ever reason, to easily swap in another (currently only two, but more imminently possible). The Rope Demo and the two different iterations with similar outputs, has all the parts required to make quite complex interactive tools. One can easily replicate this using GLAM.
A carrom board game, a South Asian game played on a boards with counters and pockets can be simulated relatively easily. To see how to create similar games using GLAM see Part 2.
Conclusion
By converting the backend specific, complex code into generic, agnostic code the developer can concentrate on the goals he has rather than the paradigm his principles and platforms force him to follow. The results is code for each backend that looks nearly identical and the differences hidden away.
As I witness Nathan and Norma, so similar in so many ways and yet so completely different in others, go through their daily conflicts with the remote, the best spot on the sofa, or who walks the dog, I see all our children; complex individuals we are able to love dearly despite their diversity, future leaders of industry, the world and a source of intense pride in parents (and uncles). Harmony would be a possible illusion if we could abstract out the differences. But failing that, one hopes one day they are blessed with children just like themselves.
Leave a comment