Alex Gwyn
Alex Gwyn

Reputation: 35

Loading texture - using OpenGl, LWJGL and SlickUtil

I get this error when I try to load a texture. Any ideas on why this has occured? or if the method has changed since I last used the libraries?

Exception in thread "main" java.lang.NoSuchMethodError: org.lwjgl.opengl.GL11.glGetInteger(ILjava/nio/IntBuffer;)V
at org.newdawn.slick.opengl.renderer.ImmediateModeOGLRenderer.glGetInteger(ImmediateModeOGLRenderer.java:194)
at org.newdawn.slick.opengl.InternalTextureLoader.getTexture(InternalTextureLoader.java:317)
at org.newdawn.slick.opengl.InternalTextureLoader.getTexture(InternalTextureLoader.java:254)
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 engine.Loader.loadTexture(Loader.java:39)
at game.Game.main(Game.java:51)

My code to load a texture is this.

public int loadTexture(String fileName){
    Texture texture = null;
    try {
        texture = TextureLoader.getTexture("PNG", new FileInputStream("res/" + fileName + ".png"));
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    int textureID = texture.getTextureID();
    textures.add(textureID);
    return textureID;
}

Upvotes: 3

Views: 1612

Answers (1)

javac
javac

Reputation: 2441

Slick-Util is not compatible with LWJGL 3 and it is unsure whether it will be continued. There seems to be a version that works with it, but I haven't tried it.

The LWJGL developers recommend using the included STB library for loading textures because it is still being developed, lightweight and quite good at loading simple files. You can have a look at the tests and the getting started guide for examples of how to use it.

Upvotes: 3

Related Questions