Some code tweaks

This commit is contained in:
Ray
2017-04-30 13:03:31 +02:00
parent 2d6213af60
commit d593bd0081
4 changed files with 70 additions and 91 deletions

View File

@@ -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);