Corrected alpha issue on screenshots taken

This commit is contained in:
Ray 2015-11-05 09:46:18 +01:00
parent 76024b5036
commit 5208d57f1e

View file

@ -1610,7 +1610,7 @@ void rlglInitGraphics(int offsetX, int offsetY, int width, int height)
// NOTE: Don't confuse glViewport with the transformation matrix
// NOTE: glViewport just defines the area of the context that you will actually draw to.
glClearColor(0.0f, 0.0f, 0.0f, 1.0f); // Set background color (black)
glClearColor(0.0f, 0.0f, 0.0f, 1.0f); // Set clear color (black)
//glClearDepth(1.0f); // Clear depth buffer (default)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear used buffers, depth buffer is used for 3D
@ -2067,7 +2067,12 @@ unsigned char *rlglReadScreenPixels(int width, int height)
{
for (int x = 0; x < (width*4); x++)
{
imgData[x + (height - y - 1)*width*4] = screenData[x + (y*width*4)];
// Flip line
imgData[((height - 1) - y)*width*4 + x] = screenData[(y*width*4) + x];
// 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;
}
}