bermainis an indonesian word forplay
prereq:
- jank
- babashka
- Vulkan SDK to precompile shaders
- and more listed in
bb prepsection
this jank project uses deps.edn via tools.bbuild (this deps should be automatically fetched by bb on the first call)
preparation (need to run only once)
bb prep
# this does
bb lets prep-kondo # this shells out to clj-kondo (optional, this fetch the configs from dependencis via --copy-configs)
bb lets download-sdl3 # download SDL3 release to a local `.libs` folder, then unzip
bb lets compile-shaders # this shells out to Vulkan SDK's `glslc`, and compile everything in `shaders` folderdevel
# run-main
bb jank
# repl-dev
bb repl-dev
# and calva connect
# aot compile
bb compile
./target/bermain.exe
# ayo bermain jank!cleaning
bb lets clean
bb lets clean-shadersjank print-binary-version x86_64-w64-windows-gnu-a20d44e2d447c35eb9da21888fdf1b2b152d81a3591594cd1b2610c1123c7da4
when building we encountered error on running ./bin/compile
compiler+runtime/src/cpp/clojure/data/json_native.cpp:1:10: fatal error: 'nlohmann/json.hpp' file not found
1 | #include <nlohmann/json.hpp>
solution: pacman -S mingw-w64-clang-x86_64-nlohmann-json
we wanted to try out raylib but blocked by: raysan5/raylib#1217
(defmacro must-be-true
([form] (must-be-true form nil))
([form callback]
(let [first-sym (str (first form))]
`(when (not ~form)
~callback
(throw-sdl-error (str "Error on " ~first-sym))))))internal error
JIT session error: Symbols not found: [ bermain_sdl3_common_must_be_true_12_2 ]
─ analyze/macro-expansion-exception ────────────────────────────────────────────────────────────────
error: Uncaught exception while expanding macro.
─────┬──────────────────────────────────────────────────────────────────────────────────────────────
│ src\bermain\sdl3\sdl3.jank
─────┼──────────────────────────────────────────────────────────────────────────────────────────────
8 │ (declare poll-events cleanup)
9 │
10 │ (defn main []
│ ^ Expanded from this macro.
11 │ (must-be-true (cpp/SDL_Init (bit-or cpp/SDL_INIT_VIDEO cpp/SDL_INIT_GAMEPAD)))
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Found here.
─────┴──────────────────────────────────────────────────────────────────────────────────────────────
─ internal/failure ─────────────────────────────────────────────────────────────────────────────────
error: Failed to find symbol: 'bermain_sdl3_common_must_be_true_12_4'
source: https://opengameart.org/content/animated-horse
magick HorseRun_4.gif -coalesce +append horserun.png(cpp/SDL_FRect (cpp/float 0) (cpp/float 0) (cpp/float 60) (cpp/float 33))
above makes the sdl program hangs and exit, no error message or any exception thrown running that in repl however
clj꞉bermain.sdl3.sdl3꞉>
(cpp/SDL_FRect (cpp/float 0) (cpp/float 0) (cpp/float 60) (cpp/float 33))
This function is returning a native object of type 'SDL_FRect', which is not convertible to a jank runtime object.
no problem
and below works
(cpp/SDL_FRect (cpp/float 0.0) (cpp/float 0.0) (cpp/float 60.0) (cpp/float 33.0))
isolating above to just
(cpp/raw "struct RandomRect {float x, y, w, h;};")
(let [src (cpp/RandomRect (cpp/float 0) (cpp/float 0) (cpp/float 60) (cpp/float 33))]
(println (.-x src)))
;; ERROR
;; libunwind: pc not in table, pc=0x37
;; Exception caught while destructing timerlibunwind: pc not in table, pc=0x37
;; libc++abi: terminating due to uncaught exception of type std::runtime_error: invalid object type (expected real found small_integer)or this (but the error isnt descriptive)
(cpp/float 0)
;; ERROR
;; libunwind: pc not in table, pc=0x799E5FF868