OpenGL Renderer:

- Fix bug where if converting the framebuffer on GPU is not supported, but PBO is still supported, then the resulting framebuffer would be flipped with incorrect colors. (Regression from r5359.)
- Read back the pixels in RGBA format instead of BGRA on OpenGL 3.2 devices, since such devices should natively support that type of pixel transfer.
This commit is contained in:
rogerman 2016-02-18 02:13:47 +00:00
parent d6ae36e068
commit b849c5b1c3
2 changed files with 3 additions and 5 deletions

View File

@ -1115,7 +1115,7 @@ Render3DError OpenGLRenderer::FlushFramebuffer(const FragmentColor *__restrict s
FragmentColor* OpenGLRenderer::GetFramebuffer()
{
return (this->_mappedFramebuffer != NULL) ? this->_mappedFramebuffer : GPU->GetEngineMain()->Get3DFramebufferRGBA6665();
return (this->willConvertFramebufferOnGPU) ? this->_mappedFramebuffer : GPU->GetEngineMain()->Get3DFramebufferRGBA6665();
}
OpenGLRenderer_1_2::~OpenGLRenderer_1_2()

View File

@ -466,9 +466,7 @@ static const char *FramebufferOutputFragShader_150 = {"\
\n\
void main()\n\
{\n\
// Note that we swap B and R since pixel readbacks are done in BGRA format for fastest\n\
// performance. The final color is still in RGBA format.\n\
vec4 colorRGBA6665 = texture(texInFragColor, texCoord).bgra;\n\
vec4 colorRGBA6665 = texture(texInFragColor, texCoord);\n\
colorRGBA6665 = floor((colorRGBA6665 * 255.0) + 0.5);\n\
colorRGBA6665.rgb = floor(colorRGBA6665.rgb / 4.0);\n\
colorRGBA6665.a = floor(colorRGBA6665.a / 8.0);\n\
@ -1281,7 +1279,7 @@ Render3DError OpenGLRenderer_3_2::ReadBackPixels()
// Read back the pixels.
glReadBuffer(GL_COLOR_ATTACHMENT2);
glReadPixels(0, 0, this->_framebufferWidth, this->_framebufferHeight, GL_BGRA, GL_UNSIGNED_BYTE, 0);
glReadPixels(0, 0, this->_framebufferWidth, this->_framebufferHeight, GL_RGBA, GL_UNSIGNED_BYTE, 0);
// Set the read and draw target buffers back to color attachment 0, which is always the default.
glReadBuffer(GL_COLOR_ATTACHMENT0);