2D Image loads uncorrectly?

Started by YogurtSmudge, October 04, 2018, 15:36:31

Previous topic - Next topic

YogurtSmudge

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:




but when I tried with a test image it worked fine:


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.