Going deeper - damn/moon GitHub Wiki

project.clj

(defproject moon "-SNAPSHOT"
  :repositories ["jitpack" "https://jitpack.io"](/damn/moon/wiki/"jitpack"-"https://jitpack.io")
  :dependencies [
                 ; libgdx java libs
                 [com.badlogicgames.gdx/gdx                   "1.14.2"]
                 [com.badlogicgames.gdx/gdx-backend-lwjgl3    "1.14.2"]
                 [com.badlogicgames.gdx/gdx-freetype          "1.14.2"]
                 [com.badlogicgames.gdx/gdx-freetype-platform "1.14.2" :classifier "natives-desktop"]
                 [com.badlogicgames.gdx/gdx-platform          "1.14.2" :classifier "natives-desktop"]
                 [space.earlygrey/shapedrawer "2.6.0"]
                 ;

                 ; clojure libs
                 [com.github.cdorrat/reduce-fsm "fe1c914d68"]
                 [fr.reuz/qrecord "0.1.0"]
                 [metosin/malli "0.13.0"]
                 [org.clj-commons/pretty "3.2.0"]
                 ;

                 ; clojure
                 [org.clojure/clojure "1.12.0"]
                 ;

                 ; development only
                 [nrepl "0.9.0"]
                 [org.clojure/tools.namespace "1.3.0"]
                 ;
                 ]
  :java-source-paths ["java-src"]
  :source-paths ["src"]
  :resource-paths ["resources/"]
  :aliases {"dev"      ["run" "-m" "dev.loop" "((requiring-resolve 'start/-main))"]
            "levelgen" ["run" "-m" "dev.loop" "((requiring-resolve 'levelgen-test.app/-main))"]
            "editor"   ["run" "-m" "dev.loop" "((requiring-resolve 'editor.app/-main))"]
            "nsgraph"  ["run" "-m" "dev.loop" "((requiring-resolve 'ns-graph.core/-main))"]
            "app-test" ["run" "-m" "dev.loop" "((requiring-resolve 'moon.backends.lwjgl-test/-main))"]
            "ns"       ["hiera" ":layout" ":horizontal"]}
  :plugins [[lein-hiera "2.0.0"]
            [lein-codox "0.10.8"]]
  :target-path "target/%s/" ; https://stackoverflow.com/questions/44246924/clojure-tools-namespace-refresh-fails-with-no-namespace-foo
  :jvm-opts ["-Xms512m" ; 256 for game ok, lein hiera in repl needs more
             "-Xmx512m"
             "-Dvisualvm.display.name=CDQ"
             "-XX:-OmitStackTraceInFastThrow" ; disappeared stacktraces
             ]
  :codox {:source-uri "https://github.com/damn/moon/blob/main/{filepath}#L{line}"
          :metadata {:doc/format :markdown}}
  :global-vars {*warn-on-reflection* true
                ;*unchecked-math* :warn-on-boxed
                ;*assert* false
                *print-level* 3}
  :profiles {:uberjar {:aot [start]}}
  :uberjar-name "moon.jar"
  :main start)

Dependency Overview

lein deps :tree 

Result:

 [com.badlogicgames.gdx/gdx-backend-lwjgl3 "1.14.2"]
   [com.badlogicgames.jlayer/jlayer "1.0.1-gdx"]
   [org.jcraft/jorbis "0.0.17"]
   [org.lwjgl/lwjgl-glfw "3.3.3"]
   [org.lwjgl/lwjgl-glfw "3.3.3" :classifier "natives-linux-arm32"]
   [org.lwjgl/lwjgl-glfw "3.3.3" :classifier "natives-linux-arm64"]
   [org.lwjgl/lwjgl-glfw "3.3.3" :classifier "natives-linux"]
   [org.lwjgl/lwjgl-glfw "3.3.3" :classifier "natives-macos-arm64"]
   [org.lwjgl/lwjgl-glfw "3.3.3" :classifier "natives-macos"]
   [org.lwjgl/lwjgl-glfw "3.3.3" :classifier "natives-windows-x86"]
   [org.lwjgl/lwjgl-glfw "3.3.3" :classifier "natives-windows"]
   [org.lwjgl/lwjgl-jemalloc "3.3.3"]
   [org.lwjgl/lwjgl-jemalloc "3.3.3" :classifier "natives-linux-arm32"]
   [org.lwjgl/lwjgl-jemalloc "3.3.3" :classifier "natives-linux-arm64"]
   [org.lwjgl/lwjgl-jemalloc "3.3.3" :classifier "natives-linux"]
   [org.lwjgl/lwjgl-jemalloc "3.3.3" :classifier "natives-macos-arm64"]
   [org.lwjgl/lwjgl-jemalloc "3.3.3" :classifier "natives-macos"]
   [org.lwjgl/lwjgl-jemalloc "3.3.3" :classifier "natives-windows-x86"]
   [org.lwjgl/lwjgl-jemalloc "3.3.3" :classifier "natives-windows"]
   [org.lwjgl/lwjgl-openal "3.3.3"]
   [org.lwjgl/lwjgl-openal "3.3.3" :classifier "natives-linux-arm32"]
   [org.lwjgl/lwjgl-openal "3.3.3" :classifier "natives-linux-arm64"]
   [org.lwjgl/lwjgl-openal "3.3.3" :classifier "natives-linux"]
   [org.lwjgl/lwjgl-openal "3.3.3" :classifier "natives-macos-arm64"]
   [org.lwjgl/lwjgl-openal "3.3.3" :classifier "natives-macos"]
   [org.lwjgl/lwjgl-openal "3.3.3" :classifier "natives-windows-x86"]
   [org.lwjgl/lwjgl-openal "3.3.3" :classifier "natives-windows"]
   [org.lwjgl/lwjgl-opengl "3.3.3"]
   [org.lwjgl/lwjgl-opengl "3.3.3" :classifier "natives-linux-arm32"]
   [org.lwjgl/lwjgl-opengl "3.3.3" :classifier "natives-linux-arm64"]
   [org.lwjgl/lwjgl-opengl "3.3.3" :classifier "natives-linux"]
   [org.lwjgl/lwjgl-opengl "3.3.3" :classifier "natives-macos-arm64"]
   [org.lwjgl/lwjgl-opengl "3.3.3" :classifier "natives-macos"]
   [org.lwjgl/lwjgl-opengl "3.3.3" :classifier "natives-windows-x86"]
   [org.lwjgl/lwjgl-opengl "3.3.3" :classifier "natives-windows"]
   [org.lwjgl/lwjgl-stb "3.3.3"]
   [org.lwjgl/lwjgl-stb "3.3.3" :classifier "natives-linux-arm32"]
   [org.lwjgl/lwjgl-stb "3.3.3" :classifier "natives-linux-arm64"]
   [org.lwjgl/lwjgl-stb "3.3.3" :classifier "natives-linux"]
   [org.lwjgl/lwjgl-stb "3.3.3" :classifier "natives-macos-arm64"]
   [org.lwjgl/lwjgl-stb "3.3.3" :classifier "natives-macos"]
   [org.lwjgl/lwjgl-stb "3.3.3" :classifier "natives-windows-x86"]
   [org.lwjgl/lwjgl-stb "3.3.3" :classifier "natives-windows"]
   [org.lwjgl/lwjgl "3.3.3"]
   [org.lwjgl/lwjgl "3.3.3" :classifier "natives-linux-arm32"]
   [org.lwjgl/lwjgl "3.3.3" :classifier "natives-linux-arm64"]
   [org.lwjgl/lwjgl "3.3.3" :classifier "natives-linux"]
   [org.lwjgl/lwjgl "3.3.3" :classifier "natives-macos-arm64"]
   [org.lwjgl/lwjgl "3.3.3" :classifier "natives-macos"]
   [org.lwjgl/lwjgl "3.3.3" :classifier "natives-windows-x86"]
   [org.lwjgl/lwjgl "3.3.3" :classifier "natives-windows"]
 [com.badlogicgames.gdx/gdx-freetype-platform "1.14.2" :classifier "natives-desktop"]
 [com.badlogicgames.gdx/gdx-freetype "1.14.2"]
 [com.badlogicgames.gdx/gdx-platform "1.14.2" :classifier "natives-desktop"]
 [com.badlogicgames.gdx/gdx "1.14.2"]
   [com.badlogicgames.gdx/gdx-jnigen-loader "2.5.2"]
 [com.github.cdorrat/reduce-fsm "fe1c914d68"]
   [dorothy "0.0.6"]
   [org.clojure/core.match "1.1.0"]
 [fr.reuz/qrecord "0.1.0"]
 [metosin/malli "0.13.0"]
   [borkdude/dynaload "0.3.5"]
   [borkdude/edamame "1.3.23"]
   [fipp "0.6.26"]
     [org.clojure/core.rrb-vector "0.1.2"]
   [mvxcvi/arrangement "2.1.0"]
   [org.clojure/test.check "1.1.1"]
 [nrepl "0.9.0"]
 [org.clj-commons/pretty "3.2.0"]
 [org.clojure/clojure "1.12.0"]
   [org.clojure/core.specs.alpha "0.4.74"]
   [org.clojure/spec.alpha "0.5.238"]
 [org.clojure/tools.namespace "1.3.0"]
   [org.clojure/java.classpath "1.0.0"]
   [org.clojure/tools.reader "1.3.6"]
 [org.nrepl/incomplete "0.1.0" :exclusions [org.clojure/clojure](/damn/moon/wiki/org.clojure/clojure)]
 [space.earlygrey/shapedrawer "2.6.0"]

Observation:

libgdx Application/Gdx makes no sense.

Make libgdx into libraries not framework.

The backend contains most of the code dependencies -> split into different libs.

Take over main loop in clojure.

1. Step

Replace [com.badlogicgames.gdx/gdx-backend-lwjgl3 "1.14.2"] by its dependencies listed above from lein deps :tree.

New project.clj:

(defproject moon "-SNAPSHOT"
  :repositories ["jitpack" "https://jitpack.io"](/damn/moon/wiki/"jitpack"-"https://jitpack.io")
  :dependencies [
                 ; libgdx java libs
                 [com.badlogicgames.gdx/gdx                   "1.14.2"]
                 [com.badlogicgames.jlayer/jlayer "1.0.1-gdx"]
                 [org.jcraft/jorbis "0.0.17"]
                 [org.lwjgl/lwjgl-glfw "3.3.3"]
                 [org.lwjgl/lwjgl-glfw "3.3.3" :classifier "natives-linux-arm32"]
                 [org.lwjgl/lwjgl-glfw "3.3.3" :classifier "natives-linux-arm64"]
                 [org.lwjgl/lwjgl-glfw "3.3.3" :classifier "natives-linux"]
                 [org.lwjgl/lwjgl-glfw "3.3.3" :classifier "natives-macos-arm64"]
                 [org.lwjgl/lwjgl-glfw "3.3.3" :classifier "natives-macos"]
                 [org.lwjgl/lwjgl-glfw "3.3.3" :classifier "natives-windows-x86"]
                 [org.lwjgl/lwjgl-glfw "3.3.3" :classifier "natives-windows"]
                 [org.lwjgl/lwjgl-jemalloc "3.3.3"]
                 [org.lwjgl/lwjgl-jemalloc "3.3.3" :classifier "natives-linux-arm32"]
                 [org.lwjgl/lwjgl-jemalloc "3.3.3" :classifier "natives-linux-arm64"]
                 [org.lwjgl/lwjgl-jemalloc "3.3.3" :classifier "natives-linux"]
                 [org.lwjgl/lwjgl-jemalloc "3.3.3" :classifier "natives-macos-arm64"]
                 [org.lwjgl/lwjgl-jemalloc "3.3.3" :classifier "natives-macos"]
                 [org.lwjgl/lwjgl-jemalloc "3.3.3" :classifier "natives-windows-x86"]
                 [org.lwjgl/lwjgl-jemalloc "3.3.3" :classifier "natives-windows"]
                 [org.lwjgl/lwjgl-openal "3.3.3"]
                 [org.lwjgl/lwjgl-openal "3.3.3" :classifier "natives-linux-arm32"]
                 [org.lwjgl/lwjgl-openal "3.3.3" :classifier "natives-linux-arm64"]
                 [org.lwjgl/lwjgl-openal "3.3.3" :classifier "natives-linux"]
                 [org.lwjgl/lwjgl-openal "3.3.3" :classifier "natives-macos-arm64"]
                 [org.lwjgl/lwjgl-openal "3.3.3" :classifier "natives-macos"]
                 [org.lwjgl/lwjgl-openal "3.3.3" :classifier "natives-windows-x86"]
                 [org.lwjgl/lwjgl-openal "3.3.3" :classifier "natives-windows"]
                 [org.lwjgl/lwjgl-opengl "3.3.3"]
                 [org.lwjgl/lwjgl-opengl "3.3.3" :classifier "natives-linux-arm32"]
                 [org.lwjgl/lwjgl-opengl "3.3.3" :classifier "natives-linux-arm64"]
                 [org.lwjgl/lwjgl-opengl "3.3.3" :classifier "natives-linux"]
                 [org.lwjgl/lwjgl-opengl "3.3.3" :classifier "natives-macos-arm64"]
                 [org.lwjgl/lwjgl-opengl "3.3.3" :classifier "natives-macos"]
                 [org.lwjgl/lwjgl-opengl "3.3.3" :classifier "natives-windows-x86"]
                 [org.lwjgl/lwjgl-opengl "3.3.3" :classifier "natives-windows"]
                 [org.lwjgl/lwjgl-stb "3.3.3"]
                 [org.lwjgl/lwjgl-stb "3.3.3" :classifier "natives-linux-arm32"]
                 [org.lwjgl/lwjgl-stb "3.3.3" :classifier "natives-linux-arm64"]
                 [org.lwjgl/lwjgl-stb "3.3.3" :classifier "natives-linux"]
                 [org.lwjgl/lwjgl-stb "3.3.3" :classifier "natives-macos-arm64"]
                 [org.lwjgl/lwjgl-stb "3.3.3" :classifier "natives-macos"]
                 [org.lwjgl/lwjgl-stb "3.3.3" :classifier "natives-windows-x86"]
                 [org.lwjgl/lwjgl-stb "3.3.3" :classifier "natives-windows"]
                 [org.lwjgl/lwjgl "3.3.3"]
                 [org.lwjgl/lwjgl "3.3.3" :classifier "natives-linux-arm32"]
                 [org.lwjgl/lwjgl "3.3.3" :classifier "natives-linux-arm64"]
                 [org.lwjgl/lwjgl "3.3.3" :classifier "natives-linux"]
                 [org.lwjgl/lwjgl "3.3.3" :classifier "natives-macos-arm64"]
                 [org.lwjgl/lwjgl "3.3.3" :classifier "natives-macos"]
                 [org.lwjgl/lwjgl "3.3.3" :classifier "natives-windows-x86"]
                 [org.lwjgl/lwjgl "3.3.3" :classifier "natives-windows"]
                 [com.badlogicgames.gdx/gdx-freetype          "1.14.2"]
                 [com.badlogicgames.gdx/gdx-freetype-platform "1.14.2" :classifier "natives-desktop"]
                 [com.badlogicgames.gdx/gdx-platform          "1.14.2" :classifier "natives-desktop"]
                 [space.earlygrey/shapedrawer "2.6.0"]
                 ;

                 ; clojure libs
                 [com.github.cdorrat/reduce-fsm "fe1c914d68"]
                 [fr.reuz/qrecord "0.1.0"]
                 [metosin/malli "0.13.0"]
                 [org.clj-commons/pretty "3.2.0"]
                 ;

                 ; clojure
                 [org.clojure/clojure "1.12.0"]
                 ;

                 ; development only
                 [nrepl "0.9.0"]
                 [org.clojure/tools.namespace "1.3.0"]
                 ;
                 ]
  :java-source-paths ["java-src"]
  :source-paths ["src"]
  :resource-paths ["resources/"]
  :aliases {"dev"      ["run" "-m" "dev.loop" "((requiring-resolve 'start/-main))"]
            "levelgen" ["run" "-m" "dev.loop" "((requiring-resolve 'levelgen-test.app/-main))"]
            "editor"   ["run" "-m" "dev.loop" "((requiring-resolve 'editor.app/-main))"]
            "nsgraph"  ["run" "-m" "dev.loop" "((requiring-resolve 'ns-graph.core/-main))"]
            "app-test" ["run" "-m" "dev.loop" "((requiring-resolve 'moon.backends.lwjgl-test/-main))"]
            "ns"       ["hiera" ":layout" ":horizontal"]}
  :plugins [[lein-hiera "2.0.0"]
            [lein-codox "0.10.8"]]
  :target-path "target/%s/" ; https://stackoverflow.com/questions/44246924/clojure-tools-namespace-refresh-fails-with-no-namespace-foo
  :jvm-opts ["-Xms512m" ; 256 for game ok, lein hiera in repl needs more
             "-Xmx512m"
             "-Dvisualvm.display.name=CDQ"
             "-XX:-OmitStackTraceInFastThrow" ; disappeared stacktraces
             ]
  :codox {:source-uri "https://github.com/damn/moon/blob/main/{filepath}#L{line}"
          :metadata {:doc/format :markdown}}
  :global-vars {*warn-on-reflection* true
                ;*unchecked-math* :warn-on-boxed
                ;*assert* false
                *print-level* 3}
  :profiles {:uberjar {:aot [start]}}
  :uberjar-name "moon.jar"
  :main start)

2. Step

Copy java source files/resource files and note down commit.

cd ~/projects/libgdx/
git pull
git log backends/gdx-backend-lwjgl3
commit 8f35bb0239a59587d200d1b9383d00532156e1f1
Author: Berstanio <[email protected]>
Date:   Thu Jun 4 22:18:48 2026 +0200

    Fix lwjgl3 OGG memory leak (#7808)

Create branch

git checkout -b integrate

10K LoC

Too much -> leave as is.

Is just forms, ... start with count _locs ...

find src/ -name '*.clj' | xargs wc -l | sort -n

   59 src//world_fns/uf_caves/last_steps.clj
      60 src//levelgen_test/create.clj
      60 src//moon/ui/inventory_window/create.clj
      60 src//world_fns/uf_caves.clj
      61 src//effect/target/damage.clj
      61 src//moon/ui/inventory_window/create_cell.clj
      62 src//dev/rename.clj
      62 src//gdx/scenes/scene2d/ui/data_viewer_window.clj
      62 src//moon/caves/helpers.clj
      62 src//world_fns/modules/last_steps.clj
      64 src//effect/target_all.clj
      65 src//editor/widget/one_to_one/add_one_to_one_rows.clj
      66 src//draw_on_world_viewport/draw_entities.clj
      66 src//editor/widget/one_to_many/add_one_to_many_rows.clj
      66 src//game/constants.clj
      68 src//clojure/grid2d.clj
      68 src//dev/loop.clj
      68 src//effect/target_entity.clj
      69 src//editor/window.clj
      70 src//editor/map_widget_table.clj
      71 src//gdx/draw_tiled_map/render_tile_layer.clj
      88 src//dev/migrations.clj
     113 src//gdx/draw_tiled_map/render_tile_layer/draw_tile.clj
    9899 total