Failing to load correctly some images with stb_image

Started by
2 comments, last by _WeirdCat_ 6 years, 11 months ago

Hi!

Up to now I have only been using dds, I am now trying to load some jpg and png textures to test something, but I have had mixed luck with stb

All I do to load is


stbi_load(path, &w, &h, &c, STBI_rgb_alpha); 

Now some textures load ok,

Nsttahp.png

some load with a strange stripey pattern

bKWRXo2.png

Stripey pattern that is not visible in the source image.

I tried STBI_rgb for the one that loaded strangely, but the result is even more wrong in most cases, like I would expect actually...

What am I doing wrong? The texture resource is created in all cases with DXGI_FORMAT_R8G8B8A8_UNORM

thanks

Jacques

Advertisement

stb_image is documented to not have complete support for all JPG and PNG formats: have a look at the top of the header file for notes on this.

However I suspect that is isn't your problem (the formats it doesn't handle are unlikely to be met in common usage) but rather that stb_image is loading the textures correctly and that your problem is actually happening during the transfer of the image data to Direct3D. You'll need to talk a little about how you're doing that before I can say more.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

stb_image is documented to not have complete support for all JPG and PNG formats: have a look at the top of the header file for notes on this.

However I suspect that is isn't your problem (the formats it doesn't handle are unlikely to be met in common usage) but rather that stb_image is loading the textures correctly and that your problem is actually happening during the transfer of the image data to Direct3D. You'll need to talk a little about how you're doing that before I can say more.

It was indeed that! After posting I googled a bit, to find that comp is not the number of components of the output data like I thought it was!

if you think you have l0oaded texture properly then you need to check your rendering code perspective projection etc/ and see if you are even drawing it properly

This topic is closed to new replies.

Advertisement