mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-04-15 23:42:20 +00:00
fix coverity warning and build on some osg
This commit is contained in:
parent
6360bdc859
commit
d63eb3325f
@ -43,14 +43,15 @@ namespace
|
|||||||
|
|
||||||
void operator()(osg::Node* node, osg::NodeVisitor* nv) override
|
void operator()(osg::Node* node, osg::NodeVisitor* nv) override
|
||||||
{
|
{
|
||||||
osgUtil::RenderStage* renderStage = nv->asCullVisitor()->getCurrentRenderStage();
|
osgUtil::CullVisitor* cv = static_cast<osgUtil::CullVisitor*>(nv);
|
||||||
|
osgUtil::RenderStage* renderStage = cv->getCurrentRenderStage();
|
||||||
|
|
||||||
unsigned int frame = nv->getTraversalNumber();
|
unsigned int frame = nv->getTraversalNumber();
|
||||||
if (frame != mLastFrameNumber)
|
if (frame != mLastFrameNumber)
|
||||||
{
|
{
|
||||||
mLastFrameNumber = frame;
|
mLastFrameNumber = frame;
|
||||||
|
|
||||||
MWRender::PostProcessor* postProcessor = dynamic_cast<MWRender::PostProcessor*>(nv->asCullVisitor()->getCurrentCamera()->getUserData());
|
MWRender::PostProcessor* postProcessor = dynamic_cast<MWRender::PostProcessor*>(cv->getCurrentCamera()->getUserData());
|
||||||
|
|
||||||
if (!postProcessor)
|
if (!postProcessor)
|
||||||
{
|
{
|
||||||
@ -99,8 +100,12 @@ namespace MWRender
|
|||||||
PostProcessor::PostProcessor(RenderingManager& rendering, osgViewer::Viewer* viewer, osg::Group* rootNode)
|
PostProcessor::PostProcessor(RenderingManager& rendering, osgViewer::Viewer* viewer, osg::Group* rootNode)
|
||||||
: mViewer(viewer)
|
: mViewer(viewer)
|
||||||
, mRootNode(new osg::Group)
|
, mRootNode(new osg::Group)
|
||||||
|
, mDepthFormat(GL_DEPTH_COMPONENT24)
|
||||||
, mRendering(rendering)
|
, mRendering(rendering)
|
||||||
{
|
{
|
||||||
|
if (!SceneUtil::getReverseZ())
|
||||||
|
return;
|
||||||
|
|
||||||
osg::GraphicsContext* gc = viewer->getCamera()->getGraphicsContext();
|
osg::GraphicsContext* gc = viewer->getCamera()->getGraphicsContext();
|
||||||
unsigned int contextID = gc->getState()->getContextID();
|
unsigned int contextID = gc->getState()->getContextID();
|
||||||
osg::GLExtensions* ext = gc->getState()->get<osg::GLExtensions>();
|
osg::GLExtensions* ext = gc->getState()->get<osg::GLExtensions>();
|
||||||
@ -128,7 +133,6 @@ namespace MWRender
|
|||||||
// TODO: Once we have post-processing implemented we want to skip this return and continue with setup.
|
// TODO: Once we have post-processing implemented we want to skip this return and continue with setup.
|
||||||
// Rendering to a FBO to fullscreen geometry has overhead (especially when MSAA is enabled) and there are no
|
// Rendering to a FBO to fullscreen geometry has overhead (especially when MSAA is enabled) and there are no
|
||||||
// benefits if no floating point depth formats are supported.
|
// benefits if no floating point depth formats are supported.
|
||||||
mDepthFormat = GL_DEPTH_COMPONENT24;
|
|
||||||
Log(Debug::Warning) << errPreamble << "'GL_ARB_depth_buffer_float' and 'GL_NV_depth_buffer_float' unsupported.";
|
Log(Debug::Warning) << errPreamble << "'GL_ARB_depth_buffer_float' and 'GL_NV_depth_buffer_float' unsupported.";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -137,7 +141,7 @@ namespace MWRender
|
|||||||
int height = viewer->getCamera()->getViewport()->height();
|
int height = viewer->getCamera()->getViewport()->height();
|
||||||
|
|
||||||
createTexturesAndCamera(width, height);
|
createTexturesAndCamera(width, height);
|
||||||
resize(width, height, true);
|
resize(width, height);
|
||||||
|
|
||||||
mRootNode->addChild(mHUDCamera);
|
mRootNode->addChild(mHUDCamera);
|
||||||
mRootNode->addChild(rootNode);
|
mRootNode->addChild(rootNode);
|
||||||
@ -154,7 +158,7 @@ namespace MWRender
|
|||||||
mViewer->getCamera()->setUserData(this);
|
mViewer->getCamera()->setUserData(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PostProcessor::resize(int width, int height, bool init)
|
void PostProcessor::resize(int width, int height)
|
||||||
{
|
{
|
||||||
mDepthTex->setTextureSize(width, height);
|
mDepthTex->setTextureSize(width, height);
|
||||||
mSceneTex->setTextureSize(width, height);
|
mSceneTex->setTextureSize(width, height);
|
||||||
@ -170,7 +174,7 @@ namespace MWRender
|
|||||||
// When MSAA is enabled we must first render to a render buffer, then
|
// When MSAA is enabled we must first render to a render buffer, then
|
||||||
// blit the result to the FBO which is either passed to the main frame
|
// blit the result to the FBO which is either passed to the main frame
|
||||||
// buffer for display or used as the entry point for a post process chain.
|
// buffer for display or used as the entry point for a post process chain.
|
||||||
if (samples > 0)
|
if (samples > 1)
|
||||||
{
|
{
|
||||||
mMsaaFbo = new osg::FrameBufferObject;
|
mMsaaFbo = new osg::FrameBufferObject;
|
||||||
osg::ref_ptr<osg::RenderBuffer> colorRB = new osg::RenderBuffer(width, height, mSceneTex->getInternalFormat(), samples);
|
osg::ref_ptr<osg::RenderBuffer> colorRB = new osg::RenderBuffer(width, height, mSceneTex->getInternalFormat(), samples);
|
||||||
@ -179,12 +183,8 @@ namespace MWRender
|
|||||||
mMsaaFbo->setAttachment(osg::Camera::DEPTH_BUFFER, osg::FrameBufferAttachment(depthRB));
|
mMsaaFbo->setAttachment(osg::Camera::DEPTH_BUFFER, osg::FrameBufferAttachment(depthRB));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (init)
|
|
||||||
return;
|
|
||||||
|
|
||||||
mViewer->getCamera()->resize(width, height);
|
mViewer->getCamera()->resize(width, height);
|
||||||
mHUDCamera->resize(width, height);
|
mHUDCamera->resize(width, height);
|
||||||
|
|
||||||
mRendering.updateProjectionMatrix();
|
mRendering.updateProjectionMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ namespace MWRender
|
|||||||
|
|
||||||
int getDepthFormat() { return mDepthFormat; }
|
int getDepthFormat() { return mDepthFormat; }
|
||||||
|
|
||||||
void resize(int width, int height, bool init=false);
|
void resize(int width, int height);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void createTexturesAndCamera(int width, int height);
|
void createTexturesAndCamera(int width, int height);
|
||||||
|
@ -431,6 +431,12 @@ namespace MWRender
|
|||||||
mGroundcoverWorld->setActiveGrid(osg::Vec4i(0, 0, 0, 0));
|
mGroundcoverWorld->setActiveGrid(osg::Vec4i(0, 0, 0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mStateUpdater = new StateUpdater;
|
||||||
|
sceneRoot->addUpdateCallback(mStateUpdater);
|
||||||
|
|
||||||
|
mSharedUniformStateUpdater = new SharedUniformStateUpdater;
|
||||||
|
rootNode->addUpdateCallback(mSharedUniformStateUpdater);
|
||||||
|
|
||||||
mPostProcessor = new PostProcessor(*this, viewer, mRootNode);
|
mPostProcessor = new PostProcessor(*this, viewer, mRootNode);
|
||||||
resourceSystem->getSceneManager()->setDepthFormat(mPostProcessor->getDepthFormat());
|
resourceSystem->getSceneManager()->setDepthFormat(mPostProcessor->getDepthFormat());
|
||||||
|
|
||||||
@ -476,12 +482,6 @@ namespace MWRender
|
|||||||
|
|
||||||
source->setStateSetModes(*mRootNode->getOrCreateStateSet(), osg::StateAttribute::ON);
|
source->setStateSetModes(*mRootNode->getOrCreateStateSet(), osg::StateAttribute::ON);
|
||||||
|
|
||||||
mStateUpdater = new StateUpdater;
|
|
||||||
sceneRoot->addUpdateCallback(mStateUpdater);
|
|
||||||
|
|
||||||
mSharedUniformStateUpdater = new SharedUniformStateUpdater;
|
|
||||||
rootNode->addUpdateCallback(mSharedUniformStateUpdater);
|
|
||||||
|
|
||||||
osg::Camera::CullingMode cullingMode = osg::Camera::DEFAULT_CULLING|osg::Camera::FAR_PLANE_CULLING;
|
osg::Camera::CullingMode cullingMode = osg::Camera::DEFAULT_CULLING|osg::Camera::FAR_PLANE_CULLING;
|
||||||
|
|
||||||
if (!Settings::Manager::getBool("small feature culling", "Camera"))
|
if (!Settings::Manager::getBool("small feature culling", "Camera"))
|
||||||
|
@ -194,7 +194,7 @@ public:
|
|||||||
|
|
||||||
void operator()(osg::Node* node, osg::NodeVisitor* nv) override
|
void operator()(osg::Node* node, osg::NodeVisitor* nv) override
|
||||||
{
|
{
|
||||||
osgUtil::RenderStage* renderStage = nv->asCullVisitor()->getCurrentRenderStage();
|
osgUtil::RenderStage* renderStage = static_cast<osgUtil::CullVisitor*>(nv)->getCurrentRenderStage();
|
||||||
|
|
||||||
renderStage->setMultisampleResolveFramebufferObject(mFbo);
|
renderStage->setMultisampleResolveFramebufferObject(mFbo);
|
||||||
renderStage->setFrameBufferObject(mMsaaFbo);
|
renderStage->setFrameBufferObject(mMsaaFbo);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user