1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-05 15:45:33 +00:00

ensure readbuffer is bound before using glReadPixels

This commit is contained in:
cody glassman 2022-01-08 16:12:24 -08:00
parent 99e4cbf513
commit e32d3d11ce

View file

@ -91,15 +91,18 @@ namespace MWRender
int width = screenW - leftPadding*2;
int height = screenH - topPadding*2;
// Ensure we are reading from the resolved framebuffer and not the multisampled render buffer when in use.
// glReadPixel() cannot read from multisampled targets.
// Ensure we are reading from the resolved framebuffer and not the multisampled render buffer. Also ensure that the readbuffer is set correctly with rendeirng to FBO.
// glReadPixel() cannot read from multisampled targets
PostProcessor* postProcessor = dynamic_cast<PostProcessor*>(renderInfo.getCurrentCamera()->getUserData());
if (postProcessor && postProcessor->getFbo() && postProcessor->getMsaaFbo())
if (postProcessor && postProcessor->getFbo())
{
osg::GLExtensions* ext = osg::GLExtensions::Get(renderInfo.getContextID(), false);
if (ext)
{
ext->glBindFramebuffer(GL_FRAMEBUFFER_EXT, postProcessor->getFbo()->getHandle(renderInfo.getContextID()));
renderInfo.getState()->glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
}
}
mImage->readPixels(leftPadding, topPadding, width, height, GL_RGB, GL_UNSIGNED_BYTE);