diff options
| author | Ray <raysan5@gmail.com> | 2015-11-05 09:46:18 +0100 |
|---|---|---|
| committer | Ray <raysan5@gmail.com> | 2015-11-05 09:46:18 +0100 |
| commit | 5208d57f1e0180ea095cecec64d3db7703ec63c9 (patch) | |
| tree | 92b99d06f4b8821f8c5577db074096be39e48f81 /src | |
| parent | 76024b5036f060a19a1a2eea49c401d6db81cda8 (diff) | |
| download | raylib-5208d57f1e0180ea095cecec64d3db7703ec63c9.tar.gz raylib-5208d57f1e0180ea095cecec64d3db7703ec63c9.zip | |
Corrected alpha issue on screenshots taken
Diffstat (limited to 'src')
| -rw-r--r-- | src/rlgl.c | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -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 @@ -2063,11 +2063,16 @@ unsigned char *rlglReadScreenPixels(int width, int height) // Flip image vertically! unsigned char *imgData = (unsigned char *)malloc(width*height*sizeof(unsigned char)*4); - for (int y = height-1; y >= 0; y--) + for (int y = height - 1; y >= 0; y--) { 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; } } |
