3

So I've recently started making a simple 2-D java game using jlwgl and slick-util. I ran into a problem when trying to load in textures to place on my tiles. I am using slick util to try and load textures in. This is the method I am using to do so.

 public static Texture loadTex(String path, String fileType) {
    Texture tex = null;
    InputStream in = ResourceLoader.getResourceAsStream(path);

    try {
        tex = TextureLoader.getTexture(fileType, in);
    } catch (IOException e) {
        e.printStackTrace();
    }
    return tex;
}

I then set a variable "t" to store a variable to check if the texture loading works.

     Texture t = loadTex("res/grass64.png","PNG");

I use a glQUADS method to draw a textured square.

public static void drawQuadTex(Texture tex, float x, float y, float width,
        float height) {
    tex.bind();
    glTranslatef(x, y, 0);

    glBegin(GL_QUADS);
    glTexCoord2f(0, 0);
    glVertex2f(0, 0);
    glTexCoord2f(1, 0);
    glVertex2f(width, 0);
    glTexCoord2f(1, 1);
    glVertex2f(width, height);
    glTexCoord2f(0, 1);
    glVertex2f(0, height);
    glLoadIdentity();
    glEnd();
}

Calling drawQuadTex...

drawQuadTex(t,0,0,64,64);

I encountered an error:

"Exception in thread "main" java.lang.NoSuchMethodError: org.lwjgl.opengl.GL11.glGetInteger(ILjava/nio/IntBuffer;)V "

I'm not sure what quite is going on. Any assistance would be appreciated as this is my first attempt at any java that's not a simple school assignment. If I need to post anything else, please let me know.

javac
  • 2,431
  • 4
  • 17
  • 26

1 Answers1

1

The slick-util library is part of slick2d, which is now deprecated and no longer compatible with recent LWJGL versions such as the one which you appear to be using. This is why you are getting this error.

AppleDash
  • 1,544
  • 2
  • 13
  • 27
  • Are there any other libraries or built-in methods of loading in texture assets for lwjgl? – user2430428 May 14 '15 at 19:16
  • 1
    Make your own texture loader instead, it is quite easy if you use Java's inbuilt API: `ImageIO.read(file)` Then, grabbing the data from the returned BufferedImage by using `BufferedImage.getRGB()` and storing it in an integer array. You can then pretty much use the standard OpenGL way of generating textures which can pretty much be found anywhere. The integer array contains that data which can be sent in to OpenGL via a IntBuffer. – SporreKing May 14 '15 at 22:42