summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRay <[email protected]>2019-01-16 10:04:59 +0100
committerRay <[email protected]>2019-01-16 10:04:59 +0100
commitced73210899ddc59c1a359faf5f998ca665ed052 (patch)
tree227f929ce52a2ea644bc0949599302163a5173de
parentc93bf336fe3eb77fa263cb55ebfb4699ad021dfe (diff)
downloadraylib-ced73210899ddc59c1a359faf5f998ca665ed052.tar.gz
raylib-ced73210899ddc59c1a359faf5f998ca665ed052.zip
Readded alpha clear to rlReadScreenPixels()
When capturing framebuffer, if some element with transparency has been drawn, it retrieves that data... it could be a bit annoying in some situations because we could expect color compositing with background color... It depends on the situation and our needs... but most of the time we don't want that transparency on screenshots.
-rw-r--r--src/rlgl.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/rlgl.h b/src/rlgl.h
index d2ee776b..5bec1018 100644
--- a/src/rlgl.h
+++ b/src/rlgl.h
@@ -2630,8 +2630,11 @@ unsigned char *rlReadScreenPixels(int width, int height)
{
for (int x = 0; x < (width*4); x++)
{
- // Flip line
- imgData[((height - 1) - y)*width*4 + x] = screenData[(y*width*4) + x];
+ imgData[((height - 1) - y)*width*4 + x] = screenData[(y*width*4) + x]; // Flip line
+
+ // Set alpha component value to 255 (no trasparent image retrieval)
+ // NOTE: Alpha value has already been applied to RGB in framebuffer, we don't need it!
+ if (((x + 1)%4) == 0) imgData[((height - 1) - y)*width*4 + x] = 255;
}
}