I am developing a game in Java using LWJGL2 and Slick, and I am encountering an issue when rendering a graphic. Instead of filling the quad with the texture, it appears to be partly repeating it. The image is simply a white box, but this is how it is appearing when the program is run: How the texture appears I am loading the image using Slick:

this.texture = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("Res\\image.png"));

and I am using this code to render it:

            GL11.glVertex2f(position.x + size.x,position.y);
            GL11.glVertex2f(position.x + size.x,position.y + size.y);
            GL11.glVertex2f(position.x,position.y + size.y);

If I remove all the code for textures and just render a coloured quad, it displays as expected. Could you please point me in the right direction as to where I am going wrong?

  • \$\begingroup\$ You shouldn't use legacy OpenGL versions (GL1), it is deprecated and some drivers don't support it \$\endgroup\$
    – Bálint
    Feb 17, 2018 at 16:02
  • \$\begingroup\$ So this is a problem with my drivers as opposed to my code? Also, what should I be using instead? \$\endgroup\$
    – Alex
    Feb 17, 2018 at 16:18
  • 1
    \$\begingroup\$ @Bálint: There are no OpenGL drivers that don't support legacy OpenGL. Even MacOSX and Linux open-source drivers still support legacy OpenGL. \$\endgroup\$ Feb 17, 2018 at 16:38
  • 1
    \$\begingroup\$ @NicolBolas that’s what I would have thought - I’m pretty sure games such as Minecraft use legacy OpenGL, and they work fine on my PC \$\endgroup\$
    – Alex
    Feb 17, 2018 at 16:58
  • \$\begingroup\$ @Nicol Tell that to mine. I just tried it and got the "Legacy OpenGL not supported message" \$\endgroup\$
    – Bálint
    Feb 17, 2018 at 21:08

1 Answer 1


I'm aware that this is not exactly the answer to your question, but it can lead you to the solution of your problem.

As @Bálint mentioned in the comments section, you shouldn't use legacy OpenGL anymore, which are all version before OpenGL 3.0. Although the OpenGL 2.0 was the first version to switch from Fixed Function Pipeline to Programmable Pipeline, it was the OpenGL 3.0, that marked Fixed Function Pipeline and most of the previous OpenGL functions and constants as deprecated, thus, really switching into the modern standard graphical API.

I strongly encourage you then, to also switch from the old OpenGL into the modern one. There are a lot of good tutorials on the internet regarding modern OpenGL.

One of them, that I find really interesting and essential is this YouTube series created by ThinMatrix. He introduces all of the modern OpenGL aspects in the easy and transparent way and he uses Java and LWJGL. (And he also of course shows how to use textures! :) )

I also recommend these tutorials. Although they are written using C++, the idea of the OpenGL constructs remains the same regardless the language.

Modern OpenGL might look a little bit overwhelmingly at the beginning, compering to legacy OpenGL, but as you follow the learning process, you'll find it fun and - most importantly - you will find a lot of advantages in using Modern OpenGL over the old one.

Also, if you'd like to read more about differences in OpenGL versions and about OpenGL itself, I recommend these links:

  1. https://www.khronos.org/opengl/wiki
  2. https://www.khronos.org/opengl/wiki/Legacy_OpenGL
  3. https://glumpy.github.io/modern-gl.html

I hope it helps you somehow and that the community won't eat me because of not directly answering your question.

Good luck!

  • 1
    \$\begingroup\$ This has absolutely nothing to do with the question. Depending on what the OP wants to do this might actually be detrimental. Can't beat 10 LoC to get a textured quad on the screen. \$\endgroup\$
    – JBeurer
    Feb 21, 2018 at 12:03
  • \$\begingroup\$ The answer to the question is glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); \$\endgroup\$
    – JBeurer
    Feb 21, 2018 at 12:03
  • \$\begingroup\$ @JBeurer the answer box is just a bit lower on the page, if you'd like to share your recommendation with some explanation about how it solves the problem. \$\endgroup\$
    – DMGregory
    Feb 21, 2018 at 12:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .