【发布时间】:2017-03-25 23:00:58
【问题描述】:
我的核心页面上有这个。创建窗口但不绘制任何东西
(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 中的代码,但我不确定你会如何做到这一点
【问题讨论】:
-
是的,我看过其他类似的问题,但它们似乎是特定的