[SOLVED] SimpleApplication.update() throws java.nio.BufferOverflowException

Hi all!
I started to learn jMonkeyEngine, so far so good! But I have a problem when I use SimpleApplication.update() manually. I use the engine in Clojure programming language.

Here is the problem;

SEVERE: Uncaught exception thrown in Thread[jME3 Main,5,main]
	at java.base/java.nio.DirectFloatBufferU.put(DirectFloatBufferU.java:457)
	at java.base/java.nio.FloatBuffer.put(FloatBuffer.java:1040)
	at com.jme3.font.BitmapTextPage.assemble(BitmapTextPage.java:208)
	at com.jme3.font.BitmapText.assemble(BitmapText.java:429)
	at com.jme3.font.BitmapText.updateLogicalState(BitmapText.java:421)
	at com.jme3.scene.Node.updateLogicalState(Node.java:241)
	at com.jme3.app.SimpleApplication.update(SimpleApplication.java:243)
	at jm_clj.core.proxy$com.jme3.app.SimpleApplication$ff19274a.update(Unknown Source)
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:151)
	at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:197)
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:232)
	at java.base/java.lang.Thread.run(Thread.java:832)

Execution error at org.lwjgl.opengl.GLContext/getCapabilities (GLContext.java:124).
No OpenGL context found in the current thread.

I think OpenGL wants me to run the code in his scope, is there any method that I could use for that?

Also, created a Github Gist for the source code: jmonkey.clj · GitHub

You can’t do that. It needs to be run on the lwjgl thread.

I don’t understand how or why you bypass lwjgl initialization. It has nothing to do with language, really.

1 Like

I’m able to run a snippet of code in libGDX (OpenGL thread) when I get this error and works really fine. The reason I’m trying to do is, I can get the updated frame/app-state without stopping-starting app.

There’s something I miss here. I don’t know why you’d have to stop/start the app to do that.

When you check this gist there is (.setColor mat "Color" ColorRGBA/Green) and when my REPL is on, I’d like to change ColorRGBA/Green to ColorRGBA/Red (re-compile my-logic function) and it applies immediately. It’s like hot reloading so I don’t have to restart the game. I was playing with libGDX for the last couple of days, it provides postRunnable that you could run your code inside OpenGL thread. My main goal is just hot reloading :slight_smile:

I found the solution, after changing my-logic function, I ran this (my-logic app) and everything reloaded (hot reload), so I did not have to restart the game. Here is the final gist: jMonkeyEngine Clojure example with hot reload in REPL · GitHub