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:
parent
99e4cbf513
commit
e32d3d11ce
1 changed files with 6 additions and 3 deletions
|
@ -91,15 +91,18 @@ namespace MWRender
|
||||||
int width = screenW - leftPadding*2;
|
int width = screenW - leftPadding*2;
|
||||||
int height = screenH - topPadding*2;
|
int height = screenH - topPadding*2;
|
||||||
|
|
||||||
// Ensure we are reading from the resolved framebuffer and not the multisampled render buffer when in use.
|
// 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.
|
// glReadPixel() cannot read from multisampled targets
|
||||||
PostProcessor* postProcessor = dynamic_cast<PostProcessor*>(renderInfo.getCurrentCamera()->getUserData());
|
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);
|
osg::GLExtensions* ext = osg::GLExtensions::Get(renderInfo.getContextID(), false);
|
||||||
if (ext)
|
if (ext)
|
||||||
|
{
|
||||||
ext->glBindFramebuffer(GL_FRAMEBUFFER_EXT, postProcessor->getFbo()->getHandle(renderInfo.getContextID()));
|
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);
|
mImage->readPixels(leftPadding, topPadding, width, height, GL_RGB, GL_UNSIGNED_BYTE);
|
||||||
|
|
Loading…
Reference in a new issue