I am facing with this exception when I using libgdx in Java:
Exception in thread "Thread-12" java.lang.RuntimeException: No OpenGL context found in the current thread.
at org.lwjgl.opengl.GLContext.getCapabilities(GLContext.java:124)
at org.lwjgl.opengl.GL11.glGenTextures(GL11.java:1403)
at com.badlogic.gdx.backends.lwjgl.LwjglGL20.glGenTexture(LwjglGL20.java:348)
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:120)
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:100)
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:92)
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:88)
at Utils.Player$2.run(Player.java:79)
at java.lang.Thread.run(Thread.java:748)
How can i solve this? I'm using libgdx. line 79 of Player.java:
TextureRegion textureRegion = new TextureRegion(new Texture("textures/Textures.png"), 50, 15, 4, 4);
You should not use Thread in libgdx actually, it is not recommended to use Thread. Html does not support threading and it will not work at Html. If you must use threading use,
Gdx.app.postRunnable(new Runnable() {
@Override
public void run() {
// process the result, e.g. add it to an Array<Result> field of the ApplicationListener.
results.add(result);
}
});
To understand what is going on here, check it official document https://github.com/libgdx/libgdx/wiki/Threading
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With