So I am making a game in LWJGL (2 I think) and I have been working on a tile grid. but when I am binding my textures I am getting an exception and the game won't open (obviously) so I have been trying to solve this for an hour but I can't seem to get it to work. here is my code, can someone correct it for me?
code: (main class) http://pastebin.com/GvxEyGRQ
code: (GridHandler class) http://pastebin.com/2fcwLXU5
code: (TileType class - it is an enum) http://pastebin.com/Dk0v3BRc
code: (Tile class) http://pastebin.com/TNATAjJW
code: (renderer class) http://pastebin.com/MBhReiAb
my error:
Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: 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.glGetError(GL11.java:1299)
at org.newdawn.slick.opengl.renderer.ImmediateModeOGLRenderer.glGetError(ImmediateModeOGLRenderer.java:384)
at org.newdawn.slick.opengl.InternalTextureLoader.getTexture(InternalTextureLoader.java:249)
at org.newdawn.slick.opengl.InternalTextureLoader.getTexture(InternalTextureLoader.java:200)
at org.newdawn.slick.opengl.TextureLoader.getTexture(TextureLoader.java:64)
at org.newdawn.slick.opengl.TextureLoader.getTexture(TextureLoader.java:24)
at Functions.renderer.loadTexture(renderer.java:58)
at Functions.renderer.quickLoad(renderer.java:67)
at Window.Tile.(Tile.java:20)
at Window.GridHandler.(GridHandler.java:30)
at Window.Main.(Main.java:31)
Thanks in advance, Bryan.
I think it might be because your static GridHandler grid = new GridHandler(map) is instantiated before the main method.
You create the context in the beginning of your main method but the GridHandler is instantiated before the main() and therefore the context hasn't been created yet and you try to load texture with quickload method from the renderer in your TileHandler class - map[i][j] = new Tile(i * 64, j * 64, 64, 64, TileType.stone);
In order to execute gl commands you need a context first(Display.create() creates the current context). What TextureLoader does is that it loads the texture on the GPU(therefore executing commands).