Strange Texture bug

Started by white waluigi, February 17, 2013, 09:36:25

Previous topic - Next topic

white waluigi

When i start My Slick 2d Application i get the strange bug, that it looks like this:

The Borders look very strange.

Also my Graphics-card whirrs pretty loud.
But other Lwjgl like Minecraft work flawless.

On my Laptop this Problem doesn't appear with the exact same Configuration.
But my Grahpics card is completly new and Updated.

Did someone have this Problem before.

I use lwjgl-2.8.5 und slick util.


white waluigi

import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
import org.lwjgl.opengl.GL11;
import org.newdawn.slick.Color;
import org.newdawn.slick.opengl.Texture;
import org.newdawn.slick.opengl.TextureLoader;
import org.newdawn.slick.util.ResourceLoader;

public class TextureExample {
   /** The texture that will hold the image details */
   private Texture texture;
    * Start the example
   public void start() {
      while (true) {

         if (Display.isCloseRequested()) {
    * Initialise the GL display
    * @param width The width of the display
    * @param height The height of the display
   private void initGL(int width, int height) {
      try {
         Display.setDisplayMode(new DisplayMode(width,height));
      } catch (LWJGLException e) {

      GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);         
           // enable alpha blending
           GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

      GL11.glOrtho(0, width, height, 0, 1, -1);
    * Initialise resources
   public void init() {
      try {
         // load texture from PNG file
         texture = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/image.png"));
         System.out.println("Texture loaded: "+texture);
         System.out.println(">> Image width: "+texture.getImageWidth());
         System.out.println(">> Image height: "+texture.getImageHeight());
         System.out.println(">> Texture width: "+texture.getTextureWidth());
         System.out.println(">> Texture height: "+texture.getTextureHeight());
         System.out.println(">> Texture ID: "+texture.getTextureID());
      } catch (IOException e) {

    * draw a quad with the image on it
   public void render() {
      texture.bind(); // or GL11.glBind(texture.getTextureID());
    * Main Class
   public static void main(String[] argv) {
      TextureExample textureExample = new TextureExample();

white waluigi

i realised, that when Textures are square, the Problem solves itself.

Is that supposed to be so?


Textures are always supposed to have a width and height which is a power of 2.
If the texture you load has a width or height which is not a power of 2 it will be expanded automatically to the next biggest dimension.

white waluigi

Thank you very much.
But I think it should have been in the Tutorial

Fool Running

Another way to fix your problem is to use texture.getWidth() and texture.getHeight() instead of hard-coding 1s for the texture coordinates.
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D