Browse Source

Reviewed GetTextureData()

pull/25/head
raysan5 9 years ago
parent
commit
6da175fccb
1 changed files with 16 additions and 8 deletions
  1. +16
    -8
      src/textures.c

+ 16
- 8
src/textures.c View File

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

Loading…
Cancel
Save