diff options
| author | raysan5 <[email protected]> | 2019-03-17 11:58:02 +0100 |
|---|---|---|
| committer | raysan5 <[email protected]> | 2019-03-17 11:58:02 +0100 |
| commit | f02a0334d8f86277916c52b274a0c7c21b6b9cd0 (patch) | |
| tree | 16908af74bd78e66108f72d460b5209f5e06893f /src/textures.c | |
| parent | 2a92d6af3e63fcc47d1030c1274223afb4163a4b (diff) | |
| download | raylib-f02a0334d8f86277916c52b274a0c7c21b6b9cd0.tar.gz raylib-f02a0334d8f86277916c52b274a0c7c21b6b9cd0.zip | |
ADDED: GetScreenData()
Diffstat (limited to 'src/textures.c')
| -rw-r--r-- | src/textures.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/textures.c b/src/textures.c index 7c942f18..38995f11 100644 --- a/src/textures.c +++ b/src/textures.c @@ -740,6 +740,20 @@ Image GetTextureData(Texture2D texture) return image; } +// Get pixel data from GPU frontbuffer and return an Image (screenshot) +RLAPI Image GetScreenData(void) +{ + Image image = { 0 }; + + image.width = GetScreenWidth(); + image.height = GetScreenHeight(); + image.mipmaps = 1; + image.format = UNCOMPRESSED_R8G8B8A8; + image.data = rlReadScreenPixels(image.width, image.height); + + return image; +} + // Update GPU texture with new data // NOTE: pixels data must match texture.format void UpdateTexture(Texture2D texture, const void *pixels) @@ -1168,8 +1182,6 @@ void ImageAlphaPremultiply(Image *image) ImageFormat(image, prevFormat); } - - #if defined(SUPPORT_IMAGE_MANIPULATION) // Load cubemap from image, multiple image cubemap layouts supported TextureCubemap LoadTextureCubemap(Image image, int layoutType) |
