diff options
| author | Ray <raysan5@gmail.com> | 2017-04-30 13:03:31 +0200 |
|---|---|---|
| committer | Ray <raysan5@gmail.com> | 2017-04-30 13:03:31 +0200 |
| commit | d593bd0081ea2dcafe3182ffc874882b5b7110b4 (patch) | |
| tree | 15e9782c639571d57030420f69c6b8f7c4a69f50 /src/textures.c | |
| parent | 2d6213af6009a75cce8420f112ceb6d8bba7d198 (diff) | |
| download | raylib-d593bd0081ea2dcafe3182ffc874882b5b7110b4.tar.gz raylib-d593bd0081ea2dcafe3182ffc874882b5b7110b4.zip | |
Some code tweaks
Diffstat (limited to 'src/textures.c')
| -rw-r--r-- | src/textures.c | 39 |
1 files changed, 7 insertions, 32 deletions
diff --git a/src/textures.c b/src/textures.c index 6c56d6c5..2b61c241 100644 --- a/src/textures.c +++ b/src/textures.c @@ -154,14 +154,7 @@ static Image LoadASTC(const char *fileName); // Load ASTC file // Load image from file into CPU memory (RAM) Image LoadImage(const char *fileName) { - Image image; - - // Initialize image default values - image.data = NULL; - image.width = 0; - image.height = 0; - image.mipmaps = 0; - image.format = 0; + Image image = { 0 }; if (IsFileExtension(fileName, ".rres")) { @@ -282,13 +275,7 @@ Image LoadImagePro(void *data, int width, int height, int format) // Load an image from RAW file data Image LoadImageRaw(const char *fileName, int width, int height, int format, int headerSize) { - Image image; - - image.data = NULL; - image.width = 0; - image.height = 0; - image.mipmaps = 0; - image.format = 0; + Image image = { 0 }; FILE *rawFile = fopen(fileName, "rb"); @@ -342,7 +329,7 @@ Image LoadImageRaw(const char *fileName, int width, int height, int format, int // Load texture from file into GPU memory (VRAM) Texture2D LoadTexture(const char *fileName) { - Texture2D texture; + Texture2D texture = { 0 }; Image image = LoadImage(fileName); @@ -351,11 +338,7 @@ Texture2D LoadTexture(const char *fileName) texture = LoadTextureFromImage(image); UnloadImage(image); } - else - { - TraceLog(WARNING, "Texture could not be created"); - texture.id = 0; - } + else TraceLog(WARNING, "Texture could not be created"); return texture; } @@ -364,14 +347,7 @@ Texture2D LoadTexture(const char *fileName) // NOTE: image is not unloaded, it must be done manually Texture2D LoadTextureFromImage(Image image) { - Texture2D texture; - - // Init texture to default values - texture.id = 0; - texture.width = 0; - texture.height = 0; - texture.mipmaps = 0; - texture.format = 0; + Texture2D texture = { 0 }; texture.id = rlglLoadTexture(image.data, image.width, image.height, image.format, image.mipmaps); @@ -510,9 +486,8 @@ Color *GetImageData(Image image) // NOTE: Compressed texture formats not supported Image GetTextureData(Texture2D texture) { - Image image; - image.data = NULL; - + Image image = { 0 }; + if (texture.format < 8) { image.data = rlglReadTexturePixels(texture); |
