LWJGL texture bleeding fix won't work

Posted by user1990950 on Game Development See other posts from Game Development or by user1990950
Published on 2013-09-29T15:24:45Z Indexed on 2013/10/31 16:19 UTC
Read the original article Hit count: 347

Filed under:
|
|
|

I tried a lot of things to fix texture bleeding, but nothing works. I don't want to add a transparent border around my textures, because I already got too many and it would take too much time and I can't do it with code because I'm loading textures with slick. My textures are seperate textures and they seem to wrap on the other side (texture bleeding).

Here are the textures that are "bleeding":

The bleeding texture

The head, body, arm and leg are seperate textures.

Here's the code I'm using to draw a texture:

public static void drawTextureN(Texture texture, Vector2f position, Vector2f translation, Vector2f origin,Vector2f scale,float rotation, Color color, FlipState flipState)
    {
        texture.setTextureFilter(GL11.GL_NEAREST);


        color.bind();
        texture.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);

        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);

        GL11.glTranslatef((int)position.x, (int)position.y, 0);
        GL11.glTranslatef(-(int)translation.x, -(int)translation.y, 0);
        GL11.glRotated(rotation, 0f, 0f, 1f);

        GL11.glScalef(scale.x, scale.y, 1);

        GL11.glTranslatef(-(int)origin.x, -(int)origin.y, 0);

        float pixelCorrection = 0f;

        GL11.glBegin(GL11.GL_QUADS);
        GL11.glTexCoord2f(0,0);
        GL11.glVertex2f(0,0);
        GL11.glTexCoord2f(1,0);
        GL11.glVertex2f(texture.getTextureWidth(),0);
        GL11.glTexCoord2f(1,1);
        GL11.glVertex2f(texture.getTextureWidth(),texture.getTextureHeight());
        GL11.glTexCoord2f(0,1);
        GL11.glVertex2f(0,texture.getTextureHeight());

        GL11.glEnd();

        GL11.glLoadIdentity();
    }

I tried a half pixel correction but it didn't make any sense because GL12.GL_CLAMP_TO_EDGE. I set pixelCorrection to 0, but it still wont work.

© Game Development or respective owner

Related posts about opengl

Related posts about java