我的核心页面上有这个。它会创建窗口,但不会绘制任何内容
(deftype Program []
GLEventListener
(display [this drawable] (in-ns 'game-c.drawtriangle))
(init [this drawable] "init")
(dispose [this drawable] "dispose")
(reshape [this drawable x y width height] "reshape")
)
;set up and start window methods/functions
(def glp (GLProfile/getDefault))
(def caps (GLCapabilities. glp))
(def window (GLWindow/create caps))
(def ani (FPSAnimator. window 60 true))
(doto window
(.addGLEventListener (Program.))
(.setSize 600 600)
(.setTitle "CloGame")
(.setVisible true)
(.start ani)
)
这是在窗口上绘制三角形的部分。但它没有做到这一点。我只是启动repl,它显示空白窗口,函数返回值和错误消息(详见下文)
(ns game-c.drawtriangle)
(def gl (.getGL4 (.getGL window)))
(def tri [ [0.0 0.0] [0.5 0.0] [0.5 0.5] ])
(doto gl
(.glCreateVertexArrays 1 tri)
)
这是repl输出
#object[clojure.lang.Namespace 0x49db0a8e "game-c.core"]
CompilerException java.lang.RuntimeException:
com.jogamp.opengl.GLException: Caught IllegalStateException: Can't
change/establish root binding of: *ns* with set on thread nREPL-worker-
1-Display-.x11_:0-1-EDT-1, compiling:(game-c/core.clj:33:2)
我认为可能有另一种方法使用位于drawtriangle的代码,但我不确定你会怎么做
答案 0 :(得分:1)
试试这个:
(ns game-c.core
(:require [game-c.drawtriangle :as tri] ))
...
(display [this drawable] (tri/drawtriangle))
...
和
(ns game-c.drawtriangle
(:require [game-c.core :as core] ))
(def gl (.getGL4 (.getGL core/window)))
...