1
0
Fork 0
mirror of https://git.coom.tech/drummyfish/raycastlib.git synced 2024-11-21 20:29:59 +01:00
raycastlib/README.md

97 lines
3.9 KiB
Markdown
Raw Normal View History

2018-09-21 20:00:08 +02:00
# raycastlib
2018-10-04 13:50:25 +02:00
Ray casting library for (not only) limited-resource computers.
2018-09-21 20:00:08 +02:00
2018-09-29 20:30:07 +02:00
eye-candy previews
------------------
2018-09-21 20:00:08 +02:00
Pokitto:
![](/media/pokitto1.gif)
![](/media/pokitto2.gif)
![](/media/pokitto3.gif)
SDL:
![](/media/sdl.gif)
Arduboy:
![](/media/arduboy.gif)
2018-09-25 08:17:07 +02:00
![](/media/arduboy2.gif)
2018-09-21 20:00:08 +02:00
terminal:
![](/media/terminal.gif)
2018-10-23 13:10:58 +02:00
Gamebuino META:
2018-10-23 08:28:36 +02:00
![](/media/gamebuino.gif)
2018-09-29 20:30:07 +02:00
features
--------
- Very fast, small and efficient.
2019-06-01 18:35:12 +02:00
- Uses only integer math (32bit).
2018-10-23 13:12:48 +02:00
- No dependencies (uses only stdint standard library), extremely portable.
2018-09-29 20:30:07 +02:00
- Single header, KISS.
- Advanced rendering of variable height floor and ceiling.
- Textured walls and floor.
2019-06-01 18:36:40 +02:00
- Depth information (e.g. for fog or z-buffer rendering).
2018-09-29 20:30:07 +02:00
- Camera shearing (looking up/down).
- Camera movement with collisions.
2018-12-21 08:38:40 +01:00
- Partial support for opening door.
2019-06-01 18:36:40 +02:00
- Pure C99, tested to run as C++ as well.
2018-09-29 20:30:07 +02:00
- Optional framework functions that handle the whole rendering.
- Still flexible -- pixels are left for you to draw in any way you want.
2018-10-27 20:49:21 +02:00
- Tested on multiple platforms (PC, Arduboy, Pokitto, Gamebuino META).
2018-09-29 20:30:07 +02:00
- Many compile-time options to tune the performance vs quality.
2019-06-02 01:37:50 +02:00
- Well commented and formatted code.
2018-09-29 20:30:07 +02:00
2018-09-30 12:23:07 +02:00
**NOTE**: Backwards compatibility isn't a goal of this libraray. It is meant to
be an as-is set of tools that the users is welcome to adjust for their
specific project. So new features will be preferred to keeping the same
interface.
2018-12-21 08:28:06 +01:00
how to use
----------
For start take a look at the [testTerminal.c](https://gitlab.com/drummyfish/raycastlib/blob/master/testTerminal.c) program.
It is only a little bit more complex than a simple hello world.
For more examples see the other files, plus my [Pokitto demos](https://gitlab.com/drummyfish/Pokitto-Raycasting) repository,
2018-12-21 08:29:35 +01:00
which contains some better documented example code, including a [very simple hello world](https://gitlab.com/drummyfish/Pokitto-Raycasting/blob/master/helloRay.cpp).
2018-12-21 08:28:06 +01:00
The basic philosophy is:
2019-06-02 01:37:50 +02:00
- The library implements only a rendering back-end, it doesn't permorm any drawing to the actual screen,
hence there is no dependency on any library such as OpenGL or SDL. It just calls your front-end function
and tells you which pixels you should write. How you do it is up to you.
2018-12-21 08:28:06 +01:00
- Before including the header, define `RCL_PIXEL_FUNCTION` to the name of a function you will use to
draw pixels. It is basically a fragment/pixel shader function that the library will call. You will
be passed info about the pixel and can decide what to do with it, so you can process it, discard it,
or simply write it to the screen.
- Call `RCL_renderSimple` or `RCL_renderComplex` to perform the frame rendering. This will cause the
2019-06-02 01:37:50 +02:00
library to start calling the `RCL_PIXEL_FUNCTION` in order to draw the frame. You can optionally write
a similar function of your own using the more low-level functions which are also provided.
2018-12-21 08:28:06 +01:00
- The library gets info about the world (such as floor or ceiling height) via *array* functions
(`RCL_ArrayFunction` type) -- functions that take *x* and *y* coordinates of a square and return given
2019-06-02 01:37:50 +02:00
information. This way you are free to not only fetch the map data from an array, but also generate
the world procedurally if that is what you want.
2018-12-21 08:28:06 +01:00
- Fixed point arithmetics is used as a principle, but there is no abstraction above it, everything is simply
an integer (`RCL_Unit` type). The space is considered to be a dense grid, where each world square
has a side length of `RCL_UNITS_PER_SQUARE` units. Numbers are normalized by this constant, so e.g.
the sin function returns a value from `-RCL_UNITS_PER_SQUARE` to `RCL_UNITS_PER_SQUARE`.
2018-09-29 20:30:07 +02:00
TODO
----
2018-09-30 12:23:07 +02:00
- Transparency (conditional ray passing through).
- Doors in the middle of squares.
- Rolling doors for `RCL_renderComplex`.
- Possibly merge all rendering functions into one.
2018-09-29 20:30:07 +02:00
2018-09-21 20:00:08 +02:00
license
-------
2019-04-28 17:29:26 +02:00
Everything is CC0 1.0 + a waiver of all other IP rights (including patents). Please share your own software as free and open-source.