Raycasting - 3D rendering engine


I have always been fascinated by 3D rendering techniques and I have to admit that, long time ago, I played a lot to Wolfenstein 3D, Doom, Quake and many other games providing an immersion in some 3D worlds.

After making my first steps in coding the 3D rendering engines like Render3D or Math3DView, I've decided to take a look at the raycasting technique and I've found an excellent tutorial written by F. Permadi:


When I've started coding my first 3D raycasting engine my goal was to learn a lot about such a technique and then to find by myself how to program the rendering engine. Starting with that tutorial, I've added the possibility to add grids, doors opening from the middle, and other things. Then I've decided to apply textures on floor and ceil (commonly called floor and ceil casting), the task was not so easy. My 3D rendering engine does not use the code that we can largely find on the Web, so I've written my own algorithm to perform such an operation (based on rotation of a virtual grid that represents the map). Day after day, I've added more features and finally I've reached my goal.

To develop that code, I've also made a basic map editor. This editor runs well but it has to be considered as a beta version.

All resources are available In the download section: project source code, map editor and so on.

System requirements

To run that code, your device must be equiped with:
  • PALM OSŪ 5.0 or higher.
  • ARM processor (≥ 400MHz for good frame rate).
  • Display: Double density and 65536 colors.
  • Heap memory: about 1.8Mb with music, about 1Mb without music.


The proposed 3D rendering engine using the raycasting technique does not include ennemies management, so the HB++ sample project provided with is an example of what you can do with such a code. Of course, it is possible to add features for making a full game.

To make the scene more realistic, I've added background midi music. So, the project uses my MIDI player code (see midsiku.net) that can slow down the frame rate on mid-range devices such as Tungsten E2 (with processor running at low frequency ≤ 200MHz). It is possible to disable background music.

Original resources

Most of textures and midi music are parts of ID Software products. I've found these resources on the Web, mainly from free ports of some games.