Hello Guest

2D Image loads uncorrectly?

  • 0 Replies
  • 556 Views
2D Image loads uncorrectly?
« 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:




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


I'm using stbi_load to load the image and using this:
Code: [Select]
        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.

« Last Edit: October 05, 2018, 21:22:24 by YogurtSmudge »