Question

Using PlayN, i am trying to change the image on a square layer. I am trying to create a flip effect to change the images. This i am doing by setting the origin of the layer to center of the image, then reducing the width and changing the image when the width is almost zero (image is not visible) and then increasing the width back to original size.

I am using a custom Timer task to play this transition.

Now I have one question and one issue.

Question is that is there a better way to acheive what i am trying to do

and the issue is that the image flips perfectly but when i click the image again to flip it back i get the following error

[java] Exception in thread "Timer-1" java.lang.RuntimeException: No OpenGL context found in the current thread.
 [java]   at org.lwjgl.opengl.GLContext.getCapabilities(GLContext.java:124)
 [java]   at org.lwjgl.opengl.GL11.glDeleteTextures(GL11.java:721)
 [java]   at playn.java.JavaGL20.glDeleteTextures(JavaGL20.java:1050)
 [java]   at playn.core.gl.GL20Context.destroyTexture(GL20Context.java:164)
 [java]   at playn.core.gl.ImageGL.clearTexture(ImageGL.java:60)
 [java]   at playn.core.gl.ImageGL.release(ImageGL.java:87)
 [java]   at playn.core.gl.ImageLayerGL.setImage(ImageLayerGL.java:74)
 [java]   at playn_poc.core.util.RotationTimerTask.run(RotationTimerTask.java:51)
 [java]   at java.util.TimerThread.mainLoop(Timer.java:512)
 [java]   at java.util.TimerThread.run(Timer.java:462)
Was it helpful?

Solution

you can only call draw methods in the main thread (the thread that calls the update()/paint() methods) - if you created a timer task, which i assume is run on a different thread, then it will not have the gl context. Don't use a timer task, or use a timer task, but throw events, and listen for events in the main update()/paint() method to perform your operations.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top