File -> New
Will this be the one that I finish? The stats are against me, but there is a certain joy in at least lying to myself again.
I'm always filled with a sense of dread when I setup a new project, I have a habit of starting stuff and not finishing them.
$ mkdir kaleidoscope && cd kaleidoscope
$ git init
$ git branch -m main
Will this be the one that I finish? The stats are against me, but there is a certain joy in at least lying to myself again.
So what do I need to get started?
$ mkdir runtime
$ touch runtime/main.c runtime/data.h
My mantra is start simple and expand, which is a good philosophy I think. Unfortunately my method is start simple, decide I need to reinvent DOTS or some other cool tech I read a paper/blog post on and get no where fast, then give up. Lets try not do that this time.
$ git submodule add https://github.com/raysan5/raylib.git ext/raylib

On no! Overthinking incoming; I've just added Raylib to help ignore some things I don't want to think about right now, but now I'm thinking about something else I don't want to think about. Cmake! So my choice is use Cmake, accept it, and integrate my stuff with Raylib and cry a little with every cmake -B ./build. Or, fight it ,ignore it, be happy with a bash script, and then re-write everything sometime down the road. Damn I hate Cmake! (Don't send me a link to that book, I've read it, it didn't change my mind on anything)
$ echo "fuck it!"
fuck it!
$ touch runtime/build_and_go.sh
$ vim runtime/build_and_go.sh
I'm in my 40's now, whats another regret.
cc main.c -I ./ -o k.out && ./k.out
Nice and simple, but like my un-diagnosed ADHD attention span it won't last.
int
main() {
__builtin_printf("Use an Engine you fool!\n");
return 0;
}
Sanity check ...
$ ./build_and_go.sh
Use an Engine you fool!Sanity check passed, well sorta I guess, I could use my Unity Pro license.
Wonders if my boss is reading this and wondering the same thing.
I'll add a little Cmake (maybe in preparation for my inevitable switch), which I can use to build Raylib into a specific place.
$ touch CMakeLists.txt
$ vim CMakeLists.txt
Random copy paste from another dead project, try not to puke in my mouth while looking at the Cmake syntax too long.
cmake_minimum_required(VERSION 3.16.2)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(INSTALL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/output)
set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_SOURCE_DIR}/output/)
get_filename_component(PROJ_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME)
project(${PROJ_NAME})
add_subdirectory(external/raylib)
I've likely not done this right or proper or something not quite Cmake'y enough.
Cmake is kinda like the baking section in the supermarket to me. I know I need flour to make a cake, but am I holding the correct flour in my hand? And is the person next to me internally laughing at me for picking up the wrong flour. The recipe just says flour. Now I need sugar ... urgh!!!
$ cmake -B ./build
$ cd build
$ make all
$ make install
$ cd ..
$ tree output/
output/
βββ include
βΒ Β βββ raylib.h
βΒ Β βββ raymath.h
βΒ Β βββ rlgl.h
βββ lib
βββ cmake
βΒ Β βββ raylib
βΒ Β βββ raylib-config.cmake
βΒ Β βββ raylib-config-version.cmake
βββ libraylib.a
βββ pkgconfig
βββ raylib.pc
So I can reference this now from my build script.
cc main.c -I ./ -I ../output/include -L ../output/lib -lraylib -o k.out && ./k.out
Update main.c by bastardizing some Raylib example.
#include "raylib.h"
int
main() {
InitWindow(800, 600, "win");
SetTargetFPS(60);
while(!WindowShouldClose()) {
BeginDrawing();
ClearBackground(RAYWHITE);
DrawText("Working?", 190, 200, 20, LIGHTGRAY);
EndDrawing();
}
CloseWindow();
return 0;
}
Woo! Getting excited a window incoming ... And of course!?!
$ ./build_and_go.sh
/usr/bin/ld: ../output/lib/libraylib.a(rcore.c.o): in function `rlRotatef':
rcore.c:(.text+0xb6c5): undefined reference to `sqrtf'
/usr/bin/ld: rcore.c:(.text+0xb739): undefined reference to `sinf'
/usr/bin/ld: rcore.c:(.text+0xb761): undefined reference to `cosf'
/usr/bin/ld: ../output/lib/libraylib.a(rcore.c.o): in function `rlGenTextureMipmaps':
rcore.c:(.text+0x10bc8): undefined reference to `log'
/usr/bin/ld: rcore.c:(.text+0x10bed): undefined reference to `floor'
/usr/bin/ld: ../output/lib/libraylib.a(rcore.c.o): in function `Wrap':
rcore.c:(.text+0x13bde): undefined reference to `floorf'
/usr/bin/ld: ../output/lib/libraylib.a(rcore.c.o): in function `FloatEquals':
rcore.c:(.text+0x13c62): undefined reference to `fmaxf'
/usr/bin/ld: rcore.c:(.text+0x13c79): undefined reference to `fmaxf'
/usr/bin/ld: ../output/lib/libraylib.a(rcore.c.o): in function `Vector2Length':
rcore.c:(.text+0x13e23): undefined reference to `sqrtf'
/usr/bin/ld: ../output/lib/libraylib.a(rcore.c.o): in function `Vector2Distance':
rcore.c:(.text+0x13f15): undefined reference to `sqrtf'
/usr/bin/ld: ../output/lib/libraylib.a(rcore.c.o): in function `Vector2Angle':
blah fucking blah ...
Anybody that's about to say 'shoulda just used cmake' can just zip it!
Sigh!
Ok whats the damage? I assume that missing m because having 'math' by default is such a dumb idea. There is some vector math there so maybe some other custom Raylib math lib? Oh stbtt_ so something with stb libs? Although that could just be one of those inline libraries right?
(Rust people rejoice at their fancy pants Cargo thingy ... I'm not bitter!)
Oh and some glfw things to round it off, so I guess when I ran Raylib via CMake its pulling in my system version of these things... I don't like hidden dependencies, but I don't want to dig up my old windowing/graphics code as I'll get sucked down some refactoring rabbit hole. Ok can we patch our build script?
(Ignores voice in my head ... 'just use cmake')
cc main.c -I ./ -I ../output/include -L ../output/lib -lraylib -lm -o k.out && ./k.out
I'm always unsure why I have to manually add -lm, I'm sure there is
some amazing Linux reason I don't care to know.
I know there are other errors but lets see if this reduces the noise.
$ ./build_and_go.sh
What about the other linker errors?!
Oh I don't care, I'm going to bed, to dream of something less confusing, although I had a dream about Aliens last night, I think I'm still bitter about the Prometheus movie and the other one that managed to be worse.
Game Over Man!
Maybe I should think about why I just did this? Was it to add another project to the wreckage that is my hobby code?
(Any hiring manager reading this I can finish stuff I swear!)
(Boss if you just read that, I'm not looking for a job! swear!)
Christ now my cat wants fed ...
$ exit