LWJGL 2 rendering lines between textures when window is maximise (Slick2D)

46 views Asked by At

EDIT: Fixed by putting:

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

just after glEnable(GL_TEXTURE_2D); in the texture rendering method!




So, when I maximise my game's window, the textures will have lines between them, like this: lines

However, when it's in 800x600, it looks like this: what it looks like in 800x600

I am using Slick2d to load the textures, if that is what is causing the issue.

        if (Display.wasResized()) {
            glViewport(0, 0, Display.getWidth(), Display.getHeight());
        }

        glClear(GL_COLOR_BUFFER_BIT);

        glEnable(GL_TEXTURE_2D);

        glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

        // Enable alpha blending
        glEnable(GL_BLEND);
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

        glViewport(0,0, Display.getWidth(), Display.getHeight());
        glMatrixMode(GL_MODELVIEW);

        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        glOrtho(0, Display.getWidth(), Display.getHeight(), 0, 1, -1);
        glMatrixMode(GL_MODELVIEW);

That is what is in the while(!Display.isCloseRequested()) loop.

My texture rendering method has this inside:

        glEnable(GL_TEXTURE_2D);
        glDisable(GL_BLEND);

        texture.bind();

        glBegin(GL_QUADS);

        glTexCoord2d(0, 0);
        glVertex2d(x, y);

        glTexCoord2d(1, 0);
        glVertex2d(x + width, y);

        glTexCoord2d(1, 1);
        glVertex2d(x + width, y + height);

        glTexCoord2d(0, 1);
        glVertex2d(x, y + height);

        glEnd();

        glEnable(GL_BLEND);
        glDisable(GL_TEXTURE_2D);

Any help would be greatly appreciated :)

0

There are 0 answers