https://github.com/angelogalav/raycastenstein-3d
A "3D" renderer in the style of 1992's Wolfenstein 3D, also known as a Raycast renderer. Made in SDL and C++.
https://github.com/angelogalav/raycastenstein-3d
cpp graphics raycasting renderer sdl2 wolfenstein-3d
Last synced: 3 months ago
JSON representation
A "3D" renderer in the style of 1992's Wolfenstein 3D, also known as a Raycast renderer. Made in SDL and C++.
- Host: GitHub
- URL: https://github.com/angelogalav/raycastenstein-3d
- Owner: AngeloGalav
- Created: 2023-11-03T11:10:17.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-05-18T13:33:50.000Z (about 1 year ago)
- Last Synced: 2025-02-05T04:32:32.455Z (4 months ago)
- Topics: cpp, graphics, raycasting, renderer, sdl2, wolfenstein-3d
- Language: C++
- Homepage:
- Size: 132 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# raycastenstein-3d
Software renderer that functions in a similar way as the renderer used in Wolfenstein 3D from 1992.
Compatible with both Linux and Windows.## How to play
- Move the camera using `A` and `D`
- Move forward and backward using `W` and `S`## Screenshots

## Compilation
#### Linux
To compile the project, simply use the provided `CMakeLists.txt` by typing the following commands:
```
mkdir build
cd build
cmake .. && make
./raycast-engine
```#### Windows
Provided that you've installed the `SDL2` and `SDL2_image` libraries properly, you can build the executable by using this commands:
```
mkdir build
cd build
cmake .. -G "MinGW Makefiles"; make -j8
./raycast-engine
```### Texture-less version
To compile the version of this project that does not use textures, simply define the flag `-DNO_TEXTURES=1` when generating the Makefile using CMake.## How it works
The rendering side of this program is rather simple.
You simply draw the world column by column (where each column is a vertical line on the framebuffer).
Each column of the framebuffer corresponds to a ray that goes from the camera to the object. When an object has been hit (i.e. a wall), the corresponding column is rendered using the color of the object.The size of the column depends on the distance between the player and the object, rather than the distance traveled by the ray from the center of the camera, otherwise we would get the so called "fisheye effect".
To detect when a wall has been hit, we make use of an algorithm called **DDA** (Digital Differential Analyzer). This allows the ray to travel very fast on the map, without needing to use a fixed step size that would either miss walls or take too many steps to hit a wall (thus resulting in a performance hit).
A more thorough explanation can be found [here](https://lodev.org/cgtutor/raycasting.html).