3 Public domain ray casting library for (not only) resource-limited computers.
5 If you like this, you may also like my similar project: [small3dlib](https://gitlab.com/drummyfish/small3dlib). These two libraries can very easily be combined together -- here is a proof-of-concept gif (environment rendered with raycastlib, cubes with small3dlib):
7 ![](https://gitlab.com/drummyfish/small3dlib/raw/master/media/rcl_plus_s3l.gif)
12 Pokitto (32bit embedded console, 48 MHz, 36 kB RAM):
14 ![](/media/pokitto1.gif)
15 ![](/media/pokitto2.gif)
16 ![](/media/pokitto3.gif)
22 Arduboy (8bit Arduino console, 16 MHz, 2.5 kB RAM):
24 ![](/media/arduboy.gif)
25 ![](/media/arduboy2.gif)
29 ![](/media/terminal.gif)
31 Gamebuino META (Arduino 32bit console, 48 MHz, 32 kB RAM):
33 ![](/media/gamebuino.gif)
38 - Very **fast, small and efficient**.
39 - Uses **only integer math** (32bit). The tiny version should only require 16bit, but isn't completed.
40 - **No dependencies** (uses only stdint standard library), extremely portable.
41 - **Single header**, KISS, suckless.
42 - Advanced rendering of **variable height floor and ceiling**.
43 - **Textured walls and floor**.
44 - **Depth information** (e.g. for fog or z-buffer rendering).
45 - **Camera shearing** (looking up/down).
46 - Camera movement with **collisions**.
47 - Partial support for **opening door**.
48 - **Pure C99**, tested to run as C++ as well.
49 - Optional framework **functions that handle the whole rendering**.
50 - Still **flexible** -- pixels are left for you to draw in any way you want.
51 - **Tested on many platforms**:
52 - PC (little endian, 64bit GNU)
53 - PowerPC emulator (big endian)
54 - compilers: gcc, clang, emscripten (web browser, JavaScript transpile)
55 - Arduboy (only experimental)
56 - Pokitto (32bit resource-limited embedded ARM)
57 - Gamebuino META (32bit resource-limited embedded ARM)
61 - **Many compile-time options** to tune the performance vs quality.
62 - **Well commented** and formatted code, with examples. Automatic documentation (comments + provided Doxyfile).
63 - Completely **free of legal restrictions**, do literally anything you want.
65 **NOTE**: Backwards compatibility isn't a goal of this libraray. It is meant to
66 be an as-is set of tools that the users is welcome to adjust for their
67 specific project. So new features will be preferred to keeping the same
73 **Don't forget to compile with -O3!** This drastically improves performance.
75 For start take a look at the [helloWorld.c](https://gitlab.com/drummyfish/raycastlib/blob/master/programs/helloWorld.c) program and other examples.
76 For more examples see my [Pokitto demos](https://gitlab.com/drummyfish/Pokitto-Raycasting) repository.
78 Also see **the library code itself**, it is meant to be self-documenting -- you'll find the description of a lot of things at the start of the file.
80 The basic philosophy is:
82 - The library implements only a **rendering back-end**, it doesn't perform any drawing to the actual screen,
83 hence there is no dependency on any library such as OpenGL or SDL. It just calls your front-end function
84 and tells you which pixels you should write. How you do it is up to you.
85 - Before including the header, define `RCL_PIXEL_FUNCTION` to the name of a function you will use to
86 draw pixels. It is basically a fragment/pixel shader function that the library will call. You will
87 be passed info about the pixel and can decide what to do with it, so you can process it, discard it,
88 or simply write it to the screen.
89 - Call `RCL_renderSimple` or `RCL_renderComplex` to perform the frame rendering. This will cause the
90 library to start calling the `RCL_PIXEL_FUNCTION` in order to draw the frame. You can optionally write
91 a similar function of your own using the more low-level functions which are also provided.
92 - The library gets info about the world (such as floor or ceiling height) via *array* functions
93 (`RCL_ArrayFunction` type) -- functions that take *x* and *y* coordinates of a square and return given
94 information. This way you are free to not only fetch the map data from an array, but also generate
95 the world procedurally if that is what you want.
96 - Fixed point arithmetics is used as a principle, but there is no abstraction above it, everything is simply
97 an integer (`RCL_Unit` type). The space is considered to be a dense grid, where each world square
98 has a side length of `RCL_UNITS_PER_SQUARE` units. Numbers are normalized by this constant, so e.g.
99 the sin function returns a value from `-RCL_UNITS_PER_SQUARE` to `RCL_UNITS_PER_SQUARE`.
104 Everything is CC0 1.0 (public domain, https://creativecommons.org/publicdomain/zero/1.0/) + a waiver of all other IP rights (including patents).
106 The art used in demos is either my own released under CC0 or someone else's released under CC0.
108 Please support free software and free culture by using free licenses and/or waivers.
110 If you'd like to support me or just read something about me and my projects, visit my site: [www.tastyfish.cz](http://www.tastyfish.cz/).