Texture Crashing bug

I’m not an expert on lwjgl exceptions, but I’ve noticed a small bug that occurs sometimes and I caught it again.

https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcQ2rEUoOK662HhZkTso0cPD8EuznHnFt7dFw7-ODcaezP6bCoBs

So here I am, working on my incredibly sexy game and running it. Then I get an exception that goes to my bind syntax for one of my textures. I’m not sure what the exception means, but the image is loaded and works fine. I think it’s the first image loaded and I do stretcch it by 1000 pixels when I draw it. Could that be the problem?

Exception :

Exception in thread "main" 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.glEnable(GL11.java:1012)
	at org.newdawn.slick.opengl.renderer.ImmediateModeOGLRenderer.glEnable(ImmediateModeOGLRenderer.java:159)
	at org.newdawn.slick.opengl.TextureImpl.bind(TextureImpl.java:142)

You are trying to access OpenGL on a separate thread, which is not allowed. Are you using a seperate thread or something?

You cant use “glGenTextures()” or any openGL methods before you create the display. Which is probably the problem.

Usually if you google the error message you find a solution:

No OpenGL context found in the current thread

I think it might be the fact that I gave the background a z of 5. I was trying to be cool by making the glOrtho Z -10.

Not in that class, but I do have some other threads running in other classes.

The only thing I do before I create the display is initialize variables.

I did, but I just copied and pasted the whole exception. Google chrome couldn’t handle it :p.

It has nothing to do with what you set your variables to. It’s about OpenGL not being initialized when called upon.

If it happens only sometimes then it is almost certainly a race condition or similar multithreading issue. Why are you using threads anyway? Seriously, you very rarely need more than 1 thread for anything.

Why would you search with irrelevant information? Only the message delivered by the exception is relevant when searching, the rest (the stack trace) is specific to your project and literally no one has ever had the same trace if your project/packages name(s) are a unique combination and thus you are narrowing the chance of google finding the information you want.
Google Fu is one of the most powerful arts in programming :stuck_out_tongue:

Ha, Google Fu. I use threads because I’m too lazy to learn how to use Timers. I’ll do some research on it tonight though.

Being a lazy programmer is only going to cause you headaches. Slow down and actually learn the languages/APIs you are using. Making games is fun but you need to know what you’re doing!