Compare commits
No commits in common. "master" and "gdx" have entirely different histories.
|
@ -21,16 +21,16 @@
|
||||||
:target-dir class-dir})
|
:target-dir class-dir})
|
||||||
(b/jar {:class-dir class-dir
|
(b/jar {:class-dir class-dir
|
||||||
:jar-file jar-file
|
:jar-file jar-file
|
||||||
:main 'ois.core}))
|
:main 'ois.launcher}))
|
||||||
|
|
||||||
(defn uber [_]
|
(defn uber [_]
|
||||||
(clean nil)
|
(clean nil)
|
||||||
(b/copy-dir {:src-dirs ["src" "resources"]
|
(b/copy-dir {:src-dirs ["src" "resources"]
|
||||||
:target-dir class-dir})
|
:target-dir class-dir})
|
||||||
(b/compile-clj {:basis basis
|
(b/compile-clj {:basis basis
|
||||||
:ns-compile '[ois.core]
|
:ns-compile '[ois.launcher]
|
||||||
:class-dir class-dir})
|
:class-dir class-dir})
|
||||||
(b/uber {:class-dir class-dir
|
(b/uber {:class-dir class-dir
|
||||||
:uber-file uber-file
|
:uber-file uber-file
|
||||||
:basis basis
|
:basis basis
|
||||||
:main 'ois.core}))
|
:main 'ois.launcher}))
|
||||||
|
|
15
deps.edn
15
deps.edn
|
@ -1,12 +1,15 @@
|
||||||
{
|
{
|
||||||
:paths ["src"]
|
:paths ["src"]
|
||||||
:deps {
|
:deps {
|
||||||
org.clojure/clojure { :mvn/version "1.11.1" }
|
com.badlogicgames.gdx/gdx { :mvn/version "1.11.0" }
|
||||||
metosin/malli { :mvn/version "0.13.0" }
|
com.badlogicgames.gdx/gdx-backend-lwjgl { :mvn/version "1.11.0" }
|
||||||
org.lwjgl/lwjgl { :mvn/version "3.3.3" }
|
com.badlogicgames.gdx/gdx-box2d { :mvn/version "1.11.0" }
|
||||||
org.lwjgl/lwjgl-glfw { :mvn/version "3.3.3" }
|
com.badlogicgames.gdx/gdx-box2d-platform$natives-desktop { :mvn/version "1.11.0" }
|
||||||
org.lwjgl/lwjgl-opengl { :mvn/version "3.3.3" }
|
com.badlogicgames.gdx/gdx-bullet { :mvn/version "1.11.0" }
|
||||||
nrepl/nrepl { :mvn/version "0.4.0" }
|
com.badlogicgames.gdx/gdx-bullet-platform$natives-desktop { :mvn/version "1.11.0" }
|
||||||
|
com.badlogicgames.gdx/gdx-platform$natives-desktop { :mvn/version "1.11.0" }
|
||||||
|
org.clojure/clojure { :mvn/version "1.7.0" }
|
||||||
|
play-clj/play-clj { :mvn/version "1.1.1" }
|
||||||
}
|
}
|
||||||
:aliases {
|
:aliases {
|
||||||
:build {
|
:build {
|
||||||
|
|
106
src/ois/core.clj
106
src/ois/core.clj
|
@ -1,81 +1,33 @@
|
||||||
(ns ois.core
|
(ns ois.core
|
||||||
(:gen-class)
|
(:import [com.badlogic.gdx Game Gdx Graphics Screen]
|
||||||
(:import (org.lwjgl Version)
|
[com.badlogic.gdx.graphics Color GL20]
|
||||||
(org.lwjgl.glfw GLFWErrorCallback GLFW GLFWKeyCallbackI Callbacks)
|
[com.badlogic.gdx.graphics.g2d BitmapFont]
|
||||||
(org.lwjgl.opengl GL GL33)
|
[com.badlogic.gdx.scenes.scene2d Stage]
|
||||||
(org.lwjgl.system MemoryStack)
|
[com.badlogic.gdx.scenes.scene2d.ui Label Label$LabelStyle]))
|
||||||
(java.lang IllegalStateException)))
|
|
||||||
|
|
||||||
(require '[nrepl.server :refer [start-server stop-server]])
|
(gen-class
|
||||||
(defonce server (start-server :port 7888))
|
:name ois.core.Game
|
||||||
|
:extends com.badlogic.gdx.Game)
|
||||||
|
|
||||||
(declare window)
|
(def main-screen
|
||||||
|
(let [stage (atom nil)]
|
||||||
|
(proxy [Screen] []
|
||||||
|
(show []
|
||||||
|
(reset! stage (Stage.))
|
||||||
|
(let [style (Label$LabelStyle. (BitmapFont.) (Color. 0 1 0 1))
|
||||||
|
label (Label. "Hello world!" style)]
|
||||||
|
(.addActor @stage label)))
|
||||||
|
(render [delta]
|
||||||
|
(.glClearColor (Gdx/gl) 0 0 0 0)
|
||||||
|
(.glClear (Gdx/gl) GL20/GL_COLOR_BUFFER_BIT)
|
||||||
|
(doto @stage
|
||||||
|
(.act delta)
|
||||||
|
(.draw)))
|
||||||
|
(dispose[])
|
||||||
|
(hide [])
|
||||||
|
(pause [])
|
||||||
|
(resize [w h])
|
||||||
|
(resume []))))
|
||||||
|
|
||||||
(declare init main-loop draw)
|
(defn -create [^Game this]
|
||||||
|
(.setScreen this main-screen))
|
||||||
(defn -main [& args]
|
|
||||||
(println (str "Hello LWJGL " (Version/getVersion) "!"))
|
|
||||||
|
|
||||||
(init)
|
|
||||||
(main-loop)
|
|
||||||
|
|
||||||
(Callbacks/glfwFreeCallbacks window)
|
|
||||||
(GLFW/glfwDestroyWindow window)
|
|
||||||
|
|
||||||
(GLFW/glfwTerminate)
|
|
||||||
(-> (GLFW/glfwSetErrorCallback nil) (.free)))
|
|
||||||
|
|
||||||
(defn init []
|
|
||||||
(-> (GLFWErrorCallback/createPrint System/err) (.set))
|
|
||||||
(when (not (GLFW/glfwInit))
|
|
||||||
(throw (IllegalStateException. "Failed to initialized GLFW.")))
|
|
||||||
|
|
||||||
(GLFW/glfwDefaultWindowHints)
|
|
||||||
(GLFW/glfwWindowHint GLFW/GLFW_VISIBLE GLFW/GLFW_FALSE)
|
|
||||||
(GLFW/glfwWindowHint GLFW/GLFW_RESIZABLE GLFW/GLFW_TRUE)
|
|
||||||
|
|
||||||
(def window (GLFW/glfwCreateWindow 300 300 "Hello World!" 0 0))
|
|
||||||
(when (zero? window)
|
|
||||||
(throw (RuntimeException. "Failed to create GLFW window.")))
|
|
||||||
|
|
||||||
(GLFW/glfwSetKeyCallback window
|
|
||||||
(reify GLFWKeyCallbackI
|
|
||||||
(invoke [this window key scancode action mods]
|
|
||||||
(when (and (= key GLFW/GLFW_KEY_ESCAPE)
|
|
||||||
(= action GLFW/GLFW_RELEASE))
|
|
||||||
(GLFW/glfwSetWindowShouldClose window true)))))
|
|
||||||
|
|
||||||
(let [stack (MemoryStack/stackPush)
|
|
||||||
p-width (.mallocInit stack 1)
|
|
||||||
p-height (.mallocInit stack 1)]
|
|
||||||
(GLFW/glfwGetWindowSize ^long window p-width p-height)
|
|
||||||
(let [vidmode (-> (GLFW/glfwGetPrimaryMonitor)
|
|
||||||
(GLFW/glfwGetVideoMode))
|
|
||||||
xpos (/ (- (.width vidmode)
|
|
||||||
(.get p-width 0))
|
|
||||||
2)
|
|
||||||
ypos (/ (- (.width vidmode)
|
|
||||||
(.get p-height 0))
|
|
||||||
2)]
|
|
||||||
(GLFW/glfwSetWindowPos window xpos ypos))
|
|
||||||
(MemoryStack/stackPop))
|
|
||||||
|
|
||||||
(GLFW/glfwMakeContextCurrent window)
|
|
||||||
(GLFW/glfwSwapInterval 1)
|
|
||||||
(GLFW/glfwShowWindow window))
|
|
||||||
|
|
||||||
(defn main-loop []
|
|
||||||
(GL/createCapabilities)
|
|
||||||
|
|
||||||
(GL33/glClearColor 1.0 0.0 0.0 0.0)
|
|
||||||
|
|
||||||
(while (not (GLFW/glfwWindowShouldClose window))
|
|
||||||
(draw)))
|
|
||||||
|
|
||||||
(defn draw []
|
|
||||||
(GL33/glClearColor 1.0 0.0 0.0 0.0)
|
|
||||||
(GL33/glClear (bit-or GL33/GL_COLOR_BUFFER_BIT
|
|
||||||
GL33/GL_DEPTH_BUFFER_BIT))
|
|
||||||
|
|
||||||
(GLFW/glfwSwapBuffers window)
|
|
||||||
(GLFW/glfwPollEvents))
|
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
(ns ois.launcher
|
||||||
|
(:require [ois.core :refer :all])
|
||||||
|
(:import [com.badlogic.gdx.backends.lwjgl LwjglApplication]
|
||||||
|
[org.lwjgl.input Keyboard])
|
||||||
|
(:gen-class))
|
||||||
|
|
||||||
|
(defn -main []
|
||||||
|
(LwjglApplication. (ois.core.Game.) "demo" 800 600)
|
||||||
|
(Keyboard/enableRepeatEvents true))
|
Loading…
Reference in New Issue