Drawing a quad with a texture mapped to it with the fixed OpenGL pipeline is one of the easiest things to do in OpenGL.

And for some madmaking, mysterious, dumb reason I can't get it to work.

I loaded a texture through Slick:

texture = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("resources/textures/texture.png"), false);

I setup my 2D projection:

glOrtho(0, Display.getWidth(), Display.getHeight(), 0, 1, -1);

Then in my game loop I call:


glTexCoord2f(0.0f, 1.0f);
glVertex2f(0, 0);

glTexCoord2f(1.0f, 1.0f);
glVertex2f(300, 0);

glTexCoord2f(1, 0);
glVertex2f(300, 90);

glTexCoord2f(0.0f, 0.0f);
glVertex2f(0, 90);


This is my texture:


And this is what I get:


It's smaller, and as you can see it's all wrong. It's kind of embarrassing that I have to ask this question, but it has keeping me busy for a few hours now.

  • \$\begingroup\$ Have you tried rendering it with colors instead of a texture in order to see what pixels are actually being rendered? Also, you should set your texture environment (clamp mode, filtering, etc). \$\endgroup\$
    – Mokosha
    Commented Jul 14, 2013 at 21:22
  • \$\begingroup\$ Yes, it renders from the top left to the bottom right (where the green line ends). I tried setting up the texture environment already, no change though. \$\endgroup\$
    – Basaa
    Commented Jul 14, 2013 at 21:45

1 Answer 1


It’s likely that when loaded by your framework, the texture is padded vertically and horizontally to the nearest power of two. For instance, if it’s a 320×200 image, it will be stored in a 512×256 texture.

You have at least two options:

  • use a texture with power of two dimensions
  • or change your texture coordinates to the proper ones, for instance glTexCoord2f(320.f / 512, 200.f / 256);.
  • \$\begingroup\$ Unbelievable. That sucks, Slick! Thanks for your answer :) \$\endgroup\$
    – Basaa
    Commented Jul 14, 2013 at 21:47
  • \$\begingroup\$ Its good for you, by default OpenGL cant handle non power-of-two textures, so you would have to pad them yourself to the next power of two, its just doing the hard work for you. \$\endgroup\$
    – akaltar
    Commented Jul 15, 2013 at 10:36

You must log in to answer this question.

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