LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: YogurtSmudge on October 04, 2018, 15:36:31

Title: 2D Image loads uncorrectly?
Post by: YogurtSmudge on October 04, 2018, 15:36:31
So I'm currently working on a 2d game for the experience and not the outcome of it but, I tried loading this image and this happened:
(https://i.gyazo.com/3cd0cde0d9cc6e903f0150e07a68a1af.png)
(https://i.gyazo.com/ee9c5547de356fd8185c0a409ee5a5ab.png)


but when I tried with a test image it worked fine:
(https://i.gyazo.com/99bbe9953ef2291039cdb8c2d7b95208.png)

I'm using stbi_load to load the image and using this:
        this.tid = GL11.glGenTextures();

        glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA, renderer.getWidth(), renderer.getHeight());
        glBindTexture(GL_TEXTURE_2D, tid);

        glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
        glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, renderer.getByteBuffer());
        stbi_image_free(renderer.getByteBuffer());


Anything I'm doing wrong?

EDIT: the height was returning width, so it was width by width, instead of height by width.