From 6da175fccbd5881535258b79a746eab3558f5473 Mon Sep 17 00:00:00 2001 From: raysan5 Date: Fri, 7 Aug 2015 17:23:53 +0200 Subject: [PATCH] Reviewed GetTextureData() --- src/textures.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/textures.c b/src/textures.c index d96c48f8..1f774254 100644 --- a/src/textures.c +++ b/src/textures.c @@ -490,20 +490,28 @@ Color *GetImageData(Image image) } // Get pixel data from GPU texture and return an Image +// NOTE: Compressed texture formats not supported Image GetTextureData(Texture2D texture) { Image image; + image.data = NULL; - image.data = rlglReadTexturePixels(texture.id, texture.format); - - if (image.data != NULL) + if (texture.format < 8) { - image.width = texture.width; - image.height = texture.height; - image.format = texture.format; - image.mipmaps = 1; + image.data = rlglReadTexturePixels(texture.id, texture.format); + + if (image.data != NULL) + { + image.width = texture.width; + image.height = texture.height; + image.format = texture.format; + image.mipmaps = 1; + + TraceLog(INFO, "Texture pixel data obtained successfully"); + } + else TraceLog(WARNING, "Texture pixel data could not be obtained"); } - else TraceLog(WARNING, "Texture pixel data could not be obtained"); + else TraceLog(WARNING, "Compressed texture data could not be obtained"); return image; }