0
votes

EDIT - I fixed it while I was waiting for this to be answered. I will leave this here for others who will run into thsi problem.

The problem was that the image i was loading was 1280 x 100, and that was not a proper aspect ratio, so when I changed it to 1280 x 720, it fixed itself.

When I render the ground-layer quad, it draws a textured line above it. It is the only texture that does that.

It is the only one of my textures that does that. And I even checked if maybe I drew an extra line in PAINT.NET but no, it looks normal outside the game.

    //Ground
    GL11.glPushMatrix();

    Color.white.bind();
    TextureBuffer.Level_TutorialGround.bind();

    GL11.glBegin(GL11.GL_QUADS);

    GL11.glTexCoord2f(0, 0);
    GL11.glVertex2f(-100, 650);
    GL11.glTexCoord2f(1, 0);
    GL11.glVertex2f(1950, 650);
    GL11.glTexCoord2f(1, 1);
    GL11.glVertex2f(1950, 500);
    GL11.glTexCoord2f(0, 1);
    GL11.glVertex2f(-100, 500);

    GL11.glEnd();

    GL11.glPopMatrix();

That is my rendering code, in case it matters.

And a weird thing is that when I first placed the quad in the scene it looked fine, but after I re-positioned it via Hot Code swap(Debug mode in eclipse) it added the line.

EDIT: My texture loading stuff: (I removed the other texture's loading stuff for the sake of space)

public static void loadTextures() throws IOException {
    try {
    Level_TutorialGround = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/textures/Level_TutorialGround.png"));
        System.out.println("Texture loaded: " + "Level_TutorialGround");
        System.out.println(">> Image width: " + Level_TutorialGround.getImageWidth());
        System.out.println(">> Image height: " + Level_TutorialGround.getImageHeight());
        System.out.println(">> Texture width: " + Level_TutorialGround.getTextureWidth());
        System.out.println(">> Texture height: " + Level_TutorialGround.getTextureHeight());
        System.out.println(">> Texture ID: " + Level_TutorialGround.getTextureID());
    } finally {
        doneLoading = true;
    }
1
Is your texture repeating? If it is it may be the way you load the texture. Can you post your texture loading code.Jesse Laning
I actually considered whether or not it was repeating, i'm just using slick2d to load textures.mcmonkeyninja
GL's default texture wrap state is GL_REPEAT, and the texture coordinates (1.0) and (0.0) are actually on the boundary between the edge/border of your image. This means that if you use a linear texture filter, your texels will be partially sampled from the other side. There are a couple of ways to solve this, but if you just want to stretch this texture over your quad a single time the absolute easiest way is simply to use GL_CLAMP_TO_EDGE for GL_TEXTURE_WRAP_S and GL_TEXTURE_WRAP_T.Andon M. Coleman
@mcmonkeyninja When you load your image replace your texture line with this Level_TutorialGround = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/textures/Level_TutorialGround.png"), GL11.GL_NEAREST);Jesse Laning
Thanks, I will use ya'lls suggestions for when I run into this problem again, but I found an easier way to fix it for this situation. Thanks for your helpmcmonkeyninja

1 Answers

1
votes

GL's default texture wrap state is GL_REPEAT, and the texture coordinates (1.0) and (0.0) are actually on the boundary between the edge/border of your image.

This means that if you use a linear texture filter (also default), your texels will be partially sampled from the other side (hence the term repeat) at the edges of your quad. There are a couple of ways to solve this, but if you just want to stretch this texture over your quad a single time the absolute easiest way is simply to use GL_CLAMP_TO_EDGE for GL_TEXTURE_WRAP_S and GL_TEXTURE_WRAP_T.

You can fix this by setting your texture's wrap state like so:

TextureBuffer.Level_TutorialGround.bind ();

GL11.glTexParameteri (GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE);
GL11.glTexParameteri (GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE);

However, texture objects track this state persistently so you would only need to do this when you first load your texture.