diff options
| author | Ray <[email protected]> | 2015-11-05 12:32:47 +0100 |
|---|---|---|
| committer | Ray <[email protected]> | 2015-11-05 12:32:47 +0100 |
| commit | 88e1fd9530100311071352f71999cca08854a3a2 (patch) | |
| tree | 0a318ce8ddf4ea74ba52e3831f9a44fa7f3ccc04 /src/textures.c | |
| parent | 2fa7e00f169c87585a46b178e6282ed63889189c (diff) | |
| download | raylib-88e1fd9530100311071352f71999cca08854a3a2.tar.gz raylib-88e1fd9530100311071352f71999cca08854a3a2.zip | |
Added texture retrieval support on OpenGL ES 2.0
Updated functions:
Image GetTextureData(Texture2D texture);
void *rlglReadTexturePixels(Texture2D texture);
Diffstat (limited to 'src/textures.c')
| -rw-r--r-- | src/textures.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/textures.c b/src/textures.c index 076ed935..27046b61 100644 --- a/src/textures.c +++ b/src/textures.c @@ -502,26 +502,27 @@ Image GetTextureData(Texture2D texture) Image image; image.data = NULL; -#if defined(GRAPHICS_API_OPENGL_ES2) - TraceLog(WARNING, "Texture data retrieval not supported on OpenGL ES 2.0"); -#else if (texture.format < 8) { - image.data = rlglReadTexturePixels(texture.id, texture.format); + image.data = rlglReadTexturePixels(texture); if (image.data != NULL) { image.width = texture.width; image.height = texture.height; - image.format = texture.format; image.mipmaps = 1; - +#if defined(GRAPHICS_API_OPENGL_ES2) + // NOTE: Data retrieved on OpenGL ES 2.0 comes as RGB (from framebuffer) + image.format = UNCOMPRESSED_R8G8B8A8; +#else + image.format = texture.format; +#endif TraceLog(INFO, "Texture pixel data obtained successfully"); } else TraceLog(WARNING, "Texture pixel data could not be obtained"); } else TraceLog(WARNING, "Compressed texture data could not be obtained"); -#endif + return image; } |
