From 0005f4026424678042a5fbb1a9f13d78eff5be9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20=C4=8C=C3=AD=C5=BE?= Date: Sun, 21 Jun 2020 12:02:37 +0200 Subject: [PATCH] Update --- README.md | 29 +++++++++-------------------- programs/make.sh | 21 ++++++++++++++++++++- programs/test.c | 8 +++----- programs/testTerminal.c | 6 +++--- todo.txt | 5 +++++ 5 files changed, 40 insertions(+), 29 deletions(-) create mode 100644 todo.txt diff --git a/README.md b/README.md index 3cf2c29..1ed4daf 100644 --- a/README.md +++ b/README.md @@ -48,18 +48,19 @@ features - **Pure C99**, tested to run as C++ as well. - Optional framework **functions that handle the whole rendering**. - Still **flexible** -- pixels are left for you to draw in any way you want. -- **Tested on multiple platforms**: +- **Tested on many platforms**: - PC (little endian, 64bit GNU) + - compilers: gcc, clang - Emscripten (web browser, JavaScript transpile) - - Arduboy - - Pokitto - - Gamebuino META + - Arduboy (only experimental) + - Pokitto (32bit resource-limited embedded ARM) + - Gamebuino META (32bit resource-limited embedded ARM) - TODO: - PowerPC emulator (big endian) - Android - Windows - **Many compile-time options** to tune the performance vs quality. -- **Well commented** and formatted code. Automatic documentation (comments + provided Doxyfile). +- **Well commented** and formatted code, with examples. Automatic documentation (comments + provided Doxyfile). - Completely **free of legal restrictions**, do literally anything you want. **NOTE**: Backwards compatibility isn't a goal of this libraray. It is meant to @@ -72,17 +73,14 @@ how to use **Don't forget to compile with -O3!** This drastically improves performance. -For start take a look at the [testTerminal.c](https://gitlab.com/drummyfish/raycastlib/blob/master/programs/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, -which contains some better documented example code, including a [very simple hello world](https://gitlab.com/drummyfish/Pokitto-Raycasting/blob/master/helloRay.cpp). +For start take a look at the [helloWorld.c](https://gitlab.com/drummyfish/raycastlib/blob/master/programs/helloWorld.c) program and other examples. +For more examples see my [Pokitto demos](https://gitlab.com/drummyfish/Pokitto-Raycasting) repository. 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. The basic philosophy is: -- The library implements only a rendering back-end, it doesn't perform any drawing to the actual screen, +- The library implements only a **rendering back-end**, it doesn't perform 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. - Before including the header, define `RCL_PIXEL_FUNCTION` to the name of a function you will use to @@ -101,15 +99,6 @@ The basic philosophy is: 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`. -TODO ----- - -- Transparency (conditional ray passing through). -- Doors in the middle of squares. -- Rolling doors for `RCL_renderComplex`. -- Possibly merge all rendering functions into one. -- Fix rendering bug that happens at the boundary of positive and negative square coords. - license ------- diff --git a/programs/make.sh b/programs/make.sh index 012f97e..b41a90b 100755 --- a/programs/make.sh +++ b/programs/make.sh @@ -1,8 +1,27 @@ #!/bin/bash +# Make script for raycastlib programs. +# by drummyfish +# released under CC0 1.0, public domain + if [ "$#" -ne 1 ]; then echo "ERROR: expecting one argument, the name of program without extension (e.g. \"helloWorld\")" exit 0 fi -clear; clear; g++ -x c -g -fmax-errors=5 -pedantic -Wall -Wextra -o $1 $1.c -lSDL2 2>&1 >/dev/null && ./$1 +link="" + +if [ "$1" = "testSDL" ]; then + link="-lSDL2" +fi + +clear +clear + +flags="-x c -g -O3 -pedantic -Wall -Wextra -o $1 $1.c ${link}" +compiler=gcc +#compiler=clang + +echo "making:" ${compiler} ${flags} + +${compiler} ${flags} > /dev/null 2>&1 && ./$1 diff --git a/programs/test.c b/programs/test.c index c60f8e8..54dee80 100644 --- a/programs/test.c +++ b/programs/test.c @@ -1,5 +1,6 @@ /** - Tests for raycastlib. + General tests for raycastlib, use to test new version, different platforms + etc. license: CC0 */ @@ -477,7 +478,7 @@ int main() RCL_Unit scaled = RCL_perspectiveScaleHorizontal(size,distance); RCL_Unit distance2 = RCL_perspectiveScaleHorizontalInverse(size,scaled); - if (RCL_absVal(distance - distance2 > 2)) + if (RCL_abs(distance - distance2 > 2)) printf("ERROR: distance: %d, distance inverse: %d\n",distance,distance2); } @@ -552,9 +553,6 @@ int main() t = measureTime(benchmarkRender); printf("render 100 times: %ld ms\n",t); - printf("\n"); - printProfile(); - printf("\n===== all OK =====\n"); return 0; diff --git a/programs/testTerminal.c b/programs/testTerminal.c index 2ea5a09..3ad3e58 100644 --- a/programs/testTerminal.c +++ b/programs/testTerminal.c @@ -1,5 +1,6 @@ /* - Raycasting terminal test. + Raycasting terminal test. Renders a raycasted animation in the terminal as + ASCII. author: Miloslav Ciz license: CC0 1.0, public domain @@ -79,8 +80,7 @@ void pixelFunc(RCL_PixelInfo *p) switch (p->hit.direction) { case 0: shade += 2; - case 1: shade += p->texCoords.y / 512; - c = asciiShades[shade]; + case 1: c = asciiShades[shade]; break; case 2: c = 'o'; break; case 3: diff --git a/todo.txt b/todo.txt new file mode 100644 index 0000000..856313c --- /dev/null +++ b/todo.txt @@ -0,0 +1,5 @@ +- Transparency (conditional ray passing through). +- Doors in the middle of squares. +- Rolling doors for `RCL_renderComplex`. Or perhaps remove rolling doors (KISS) +- Possibly merge all rendering functions into one. +- Fix rendering bug that happens at the boundary of positive and negative square coords.