PS Tech

From PigaLore
Jump to navigationJump to search
PS Tech

System(s): GNU/Linux, Unix-like

Type(s): 3D rendering (First-person)

Designer(s): Graham L. Wilson

Coder(s): Graham L. Wilson, Tomasz Kolodziejczyk

Version: Revision Two beta 2

Games: Hedged, Piga 3D Easter Egg Hunt, "Glut"

First Release: November 2014

Latest Release: April 16, 2023

Code Base: Gambas

Middleware: SDL 2 (audio, previously windowing), Qt 5 (interfaces), OpenGL 2.1 variants (Mesa-tested; rendering)

License(s): GNU General Public License 3 or later

PS Tech, also known as the Gambas 3D Engine, is a three dimensional engine project by Piga Software. It is named in homage of the id Software rendering engines ("id tech" engines), a scheme earlier mimicked by other such as Lithtech. It is a 3D rendering and game engine for Gambas written in OpenGL 2.1.


Revision One development

See also: Gambas Tile System#Implementation

PS Tech is a 3D tile engine and works in a similar fashion as the 2D Gambas Tile System. It functions via a gird system inside a multidimensional data array. Unlike the modifiable pixel tile size of the 2D system, the 3D grid has a fixed comparative scale of 1x1 representing a single point (so that an object drawn with value of 1x1x1 will fill the entire point, with smaller dimensions specified in floating point). A height system is present wherein the player can ascend from 0.1 to 0.9 without entering a higher value on the Y axis; normal standing height is .5 units of a given point.

These grid points are populated with primitives, sprites, or MD2 models. Most architectural pieces are made up of texture mapped primitives or combinations of such. These pieces can then be scaled, translated or rotated. As with the 2D tile system, there are three basic types of objects used in the map specification. Tiles are accessible for each grid point with a roof and floor that can be adjusted by height position and texture for each. Attributes coexist with the grid points but are somewhat mutable in position and size. Agents are independent dynamic objects rendered at their own position free of the grid system.

Similar to the adaptive tile refresh used in the 2D tile system, a system of distance culling applies a similar principle here. Only a portion of the map is loaded at any given time depending on the player's position, which can be customized based on the user's hardware (by default in Hedged, this is ten points around the player in every direction). Other performance optimizations such as hidden surface determination and using smaller textures and level of detail at a distance have been prototyped, but have not produced much boosts in render speed.

Lighting is yet to be properly implemented, but is to be based on a selection of specific light emitting sources, such as fireplaces, torches or candelabra. The fog feature is utilized to mimic the "diminished lighting" seen so often in mid-1990s games, and also helps obscure the distance culling.

The objective of the engine is ease of use and performance (given the innate overhead of Gambas as a high-level language, as well as limited experience and manpower), and has no ambitions of photorealism or implementation of advanced features. It most aspires parity to certain retro engines of the 1990s.

All rendering is currently done in the antiquated immediate mode or with display lists within the fixed-function pipeline, so an eventual conversion to using modern and sleeker vertex buffer objects and shaders using GLSL may come later, depending on language support (potentially by using an external library as outlined here).

Revision Two[edit]

Piga 3D Easter Egg Hunt

A new implementation was started in December 2019. Although still a true 3D renderer, the actual level geometry is stored in a 2.5D fashion as a flat grid with an added height system (objects may still be translated up the y axis however, allowing for room-over-room). This is to reduce load (it takes less power to render a taller cuboid than a stack of individual cubes) and in order to make mapping as simple as possible (2.5D games have more vibrant mapping communities, on average). This optimization will also be available for walls, with the editor designed to make them single sets of elongated cuboids where possible. This 2.5D format allows it to follow the Gambas Map Format framework, which is based on a 2D grid and shares ideas with the Gambas Tile System.

The most major difference however is that it is now using Qt for rendering interfaces, rather than using SDL for window management, in order to better utilize the Gambas form designer and to make the engine more similar to all the other Piga Software engines. This also allows the minimization of OpenGL specific drawing code to aide in eventual refactoring should a more modern 3D API (later OpenGL versions or Vulkan) be supported, or software rendering be added (using SDL drawing commands is not compatible with OpenGL in Gambas). A beta version was included in the game Hedged created for the April 2021 LibreJam, and Piga 3D Easter Egg Hunt created for Easter 2023. It does not feature the final map system nor rendering framework, but is fully playable and uses the Qt 5 component. Proper mouselook is also implemented.

Revision One[edit]

"Glut" alpha

The original implementation built using the Simple DirectMedia Layer for windowing was actively worked on from December 2012 until November 2014 before being left largely dormant. Unlike the current 2.5D design for the maps, it was developed to store geometry in a fully 3D array. Each point in the array contains two values represented as 000|000. The first three characters slots are used to define object type (block wall, door, collectible item, etc), while the last three characters are meant to assign a texture value. Between Y grid points in the map data there are values available for deciding the existence and texture for world's skydome, or whether to give the X by Z gird area a textured floor or ceiling. Individual floor and roof tiles can also be added, specified in the map format in a range from 0x0|000 to 9x9|000 ("x" replaced with "f" for floor, "r" for roof and "b" for both). Regions were also to be able to be encased in a fluid tile of either low ("l"; only submerged when crouching), medium ("m"; can be escaped by jumping) or high height ("h"; must get out before drowning). For objects that have a static texture, the texturing portion of an entry was to be used to confer other information, such as objects to be placed atop of table.


An early alpha build for a game draft called Glut is available to download from the Piga Software file directory at, and represents the end of development of the first iteration as of November 2014. It features a functioning 3D world with basic movement, drawing and interactivity. Environmental clipping however is a major issue left not properly addressed. Support for lighting is also rudimentary, and can be turned on by pressing F4. Fog is accessible by pressing F3. The engine can be made full screen by pressing F1. Movement is done via the arrow keys, and basic mouselook (upon mouse click and drag) is active. All geometry is done in pure OpenGL immediate mode using geometric primitives, although MD2 model support is included in the source code.


As of the upcoming revision two beta three.

A guide through the most important subroutines and modules used in PS Tech.


This begins on form load and applies to the glarea control. It sets up our clear (background) colour, lighting (ambient, diffuse and specular), and the volumetric fog. It then sets up the depth testing and colour shading, before calling Render().


This subroutine sets up our essential rendering features. It first calls loadworld(), which reads our map data from file, and loadtexture(), which fills out our texture array. It then enables the depth testing and colour shading, then the blending for transparency, and then begins our projection matrix including the aspect ratio and field of view. Our lighting is then factored into this. Finally our MD2 models are loaded.


This is the subroutine that controls what is drawn frame to frame. Fog and lighting are enabled. The camera position is determined. The sky dome is produced. Then FillDisplay() is called to determine which portions of the map should be drawn in the current frame. Once this is loaded, the world array is rendered based on what is defined within it. This involves calling either primitives or sprites from the Objects module, or an MD2 model. As per the Gambas Tile System, these static objects are known as Attributes. Each grid point is also given a Tile, which in three dimensions has a roof and a floor. After this, dynamic Agents are drawn at their current coordinates. If in editing mode, a wireframe cube is drawn over the currently selected grid point. A culling blind is also drawn around the camera view to obscure the space beyond what is being culled. Finally, the frames per second is calculated.


Replaces the old culling system from beta two which would draw tiles from only within a certain radius around the player. This now loads which tiles to be shown in an array based on the current player and camera position.


The main module for 3D geometry, with each subroutine representing a 3D primitive such as cubes, spheres, cylinders, or flat transparent sprites. This includes texturing and material (lighting) coordinates.


See Also: Gambas Projection Engine#History

Game Maker[edit]

Office Drone, a prototype

The closest thing Piga had previously ever done towards making an actual first-person shooter, was using the Direct3D integration of the Game Maker game creation tool. This for them made the usage of 2-Step obsolete beyond its novelty value. Work on this began in September 2005 when they finally acquired the full version of Game Maker 6.1. The first thing they tried was based on a 2.5D example downloaded from the Internet. The experiments took the form of a game called Castle Coyotestein, a Wolfenstein 3D spoof using the graphics from the famous early 1990s game. In the end, limitations to this implementation were discovered and a more easily usable demo (mirror) was found created by Mark Overmars.

A variety of game concepts were played around with. Some versions contained usable computers, key puzzles, a variety of weapons and other objects. Environments that were created were varied as well, from military bases, Gothic mansions, city locales, office blocks and such. One game featured limited squad AI while another featured limited bots. Other developers worked towards similar ends with the technology, while Piga bowed out shortly after switching to Linux and Gambas in 2007.

Other engines[edit]

Various other engines have been experimented with at different times. Malcolm Wilson Multimedia has experimented successfully with modifying ioquake3 models. Both Hamish and Graham L. Wilson have played with the Doom engine, (in both Doom Builder and Yadex, as well as its modern fork Eureka). Although having a personal liking for the id Tech family of engines, they admit that its lack of modern scripting languages such as Python or Lua is a disadvantage (not having an inclination towards learning QuakeC or similar). This makes an engine like OGRE or Irrlicht more attractive; a long-term conception for PS Tech is the eventual inclusion of a lower-level C++-written renderer, with Gambas used as a high-level scripting system. The most interesting alternative engines at the moment are the Godot engine, which provides Unity-type simplicity while still being properly free software, the GameMaker-like 3D mode added to GDevelop in May 2023, or else use the GZDoom engine that is increasingly popular for commercial projects.

Gambas Development[edit]

MetaMetal draft

PS Tech proper was first conceived after learning of the OpenGL component added in for Gambas 2 in the summer of 2007. Attempts by Graham L. Wilson to study from provided examples were eventually jump-started in late 2010, when Tomasz "tommyline" Kolodziejczyk ported over more complete examples by NeHe Productions, which have since been mainlined into Gambas. Kolodziejczyk continued to push the support for OpenGL in Gambas until switching to C++ in May 2013 in order to take advantage of later versions of the OpenGL specification, and receive performance boosts.

By this time, he had shared much of his code and imparted much of his knowledge to Wilson, who has taken up the banner of finishing a Gambas-made grid-based 3D engine. Wilson had waited to see how far Kolodziejczyk would take things, but eventually started learning the system himself first starting in August 2011, but more properly in December 2012, which culminated in the 2014 alpha.

A new draft with fixed collisions and with interfaces written in Qt 5 rather than SDL (to take advantage of the Gambas form designer) is in the works as of the end of 2019. It is to use a 2.5D height map, somewhat similar to the original Rise of the Triad, in order to reduce geometrical complexity and overhead while promoting ease of mapping; as well as using sprites for dynamic elements. A beta version of this revision was included in the game Hedged released on April 7, 2021 for LibreJam contest, further updated in version 1.2.0 released on May 31, 2021. A second beta version was used for Piga 3D Easter Egg Hunt for Easter 2023.

See Also[edit]

External links[edit]



Note: only useful for OpenGL 2.1 or earlier. Seek out shader tutorials for contemporary versions! Or move on to Vulkan

"If you prefer in book form the OpenGL Programming Guide ( Red Book ) has long been viewed as “The OpenGL Bible”, the one book all OpenGL programmers should own. That said, in recent years OpenGL has changed quite a bit and the old cruft and obsolete instructions haven’t been pruned out of this book yet. The NeHe tutorials have long been the goto resource for new OpenGL developers, although in some ways they suffer the same problem as the Red Book, time waits for no docs!" - GameFromScratch