diff options
| author | raysan5 <raysan5@gmail.com> | 2015-05-21 14:13:51 +0200 |
|---|---|---|
| committer | raysan5 <raysan5@gmail.com> | 2015-05-21 14:13:51 +0200 |
| commit | fd851d1d8b4919d802bcc5041f9a9ff37669d159 (patch) | |
| tree | 875c5d4dd13eae08098cba24950359c80b94e729 /src/textures.c | |
| parent | 9e450df053c9b6f13a89553d65425c350d4399dd (diff) | |
| download | raylib-fd851d1d8b4919d802bcc5041f9a9ff37669d159.tar.gz raylib-fd851d1d8b4919d802bcc5041f9a9ff37669d159.zip | |
Improved custom shaders support
Corrected issues with textures loading
Diffstat (limited to 'src/textures.c')
| -rw-r--r-- | src/textures.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/src/textures.c b/src/textures.c index d4ad478b..e6c6cccb 100644 --- a/src/textures.c +++ b/src/textures.c @@ -246,8 +246,17 @@ Texture2D LoadTexture(const char *fileName) ConvertToPOT(&image, BLANK); #endif - texture = LoadTextureFromImage(image, false); - UnloadImage(image); + if (image.data != NULL) + { + texture = LoadTextureFromImage(image, false); + UnloadImage(image); + } + else + { + TraceLog(WARNING, "Texture could not be created"); + + texture.id = 0; + } return texture; } @@ -985,9 +994,9 @@ static Image LoadKTX(const char *fileName) image.height = header.height; image.mipmaps = header.mipmapLevels; - TraceLog(INFO, "KTX (ETC) image width: %i", header.width); - TraceLog(INFO, "KTX (ETC) image height: %i", header.height); - TraceLog(INFO, "KTX (ETC) image format: 0x%x", header.glInternalFormat); + TraceLog(DEBUG, "KTX (ETC) image width: %i", header.width); + TraceLog(DEBUG, "KTX (ETC) image height: %i", header.height); + TraceLog(DEBUG, "KTX (ETC) image format: 0x%x", header.glInternalFormat); unsigned char unused; @@ -1212,8 +1221,9 @@ static Image LoadASTC(const char *fileName) } else { - image.width = 0x00000000 | ((int)header.width[0] << 16) | ((int)header.width[1] << 8) | ((int)header.width[2]); - image.height = 0x00000000 | ((int)header.height[0] << 16) | ((int)header.height[1] << 8) | ((int)header.height[2]); + // NOTE: Assuming Little Endian (could it be wrong?) + image.width = 0x00000000 | ((int)header.width[2] << 16) | ((int)header.width[1] << 8) | ((int)header.width[0]); + image.height = 0x00000000 | ((int)header.height[2] << 16) | ((int)header.height[1] << 8) | ((int)header.height[0]); image.mipmaps = 1; TraceLog(DEBUG, "ASTC image width: %i", image.width); |
