1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-03-29 22:36:43 +00:00

Make sure CopyFramebufferToTextureCallback is only called once and not every frame

This commit is contained in:
Ilya Zhuravlev 2018-12-25 11:56:24 -05:00
parent 8e7c01b561
commit 1bdec2399f

View file

@ -133,11 +133,15 @@ namespace MWGui
public: public:
CopyFramebufferToTextureCallback(osg::Texture2D* texture) CopyFramebufferToTextureCallback(osg::Texture2D* texture)
: mTexture(texture) : mTexture(texture)
, oneshot(true)
{ {
} }
virtual void operator () (osg::RenderInfo& renderInfo) const virtual void operator () (osg::RenderInfo& renderInfo) const
{ {
if (!oneshot)
return;
oneshot = false;
int w = renderInfo.getCurrentCamera()->getViewport()->width(); int w = renderInfo.getCurrentCamera()->getViewport()->width();
int h = renderInfo.getCurrentCamera()->getViewport()->height(); int h = renderInfo.getCurrentCamera()->getViewport()->height();
mTexture->copyTexImage2D(*renderInfo.getState(), 0, 0, w, h); mTexture->copyTexImage2D(*renderInfo.getState(), 0, 0, w, h);
@ -145,6 +149,7 @@ namespace MWGui
private: private:
osg::ref_ptr<osg::Texture2D> mTexture; osg::ref_ptr<osg::Texture2D> mTexture;
mutable bool oneshot;
}; };
class DontComputeBoundCallback : public osg::Node::ComputeBoundingSphereCallback class DontComputeBoundCallback : public osg::Node::ComputeBoundingSphereCallback