0

So I want to load a PNG image using SOIL, like this:

unsigned char* image = SOIL_load_image("image.png", &width, &height, 0, SOIL_LOAD_AUTO);

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, image);
glGenerateMipmap(GL_TEXTURE_2D);
SOIL_free_image_data(image);
glBindTexture(GL_TEXTURE_2D, 0);

When I use a JPEG image everything is loaded and rendered as I expect... but when I try to load a PNG image, I get the following result:

rendered image in PNG format

Any one knows what could be wrong in here?!

genpfault
  • 51,148
  • 11
  • 85
  • 139
waas1919
  • 2,365
  • 7
  • 44
  • 76

1 Answers1

0

WorldSEnder was right :) It was indeed a RBGA image.

I missed the:

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, image);

Thanks!

waas1919
  • 2,365
  • 7
  • 44
  • 76