From 232e34bddd7f5bf0bd48d1292a5f94128dc45f46 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 28 Mar 2015 20:15:17 +0100 Subject: [PATCH] OpenCS: port lighting toolbar, fix multiple context GL objects issue --- apps/opencs/view/render/lighting.hpp | 15 ++- apps/opencs/view/render/lightingbright.cpp | 30 ++--- apps/opencs/view/render/lightingbright.hpp | 9 +- apps/opencs/view/render/lightingday.cpp | 35 +++--- apps/opencs/view/render/lightingday.hpp | 9 +- apps/opencs/view/render/lightingnight.cpp | 35 +++--- apps/opencs/view/render/lightingnight.hpp | 9 +- apps/opencs/view/render/previewwidget.cpp | 2 +- apps/opencs/view/render/scenewidget.cpp | 111 ++++++++++++++++-- apps/opencs/view/render/scenewidget.hpp | 46 +++++++- .../view/render/unpagedworldspacewidget.cpp | 12 +- apps/opencs/view/render/worldspacewidget.cpp | 10 +- apps/opencs/view/world/previewsubview.cpp | 4 +- apps/opencs/view/world/scenesubview.cpp | 4 +- components/esm/defs.hpp | 2 +- components/resource/scenemanager.cpp | 8 ++ components/resource/scenemanager.hpp | 2 + 17 files changed, 237 insertions(+), 106 deletions(-) diff --git a/apps/opencs/view/render/lighting.hpp b/apps/opencs/view/render/lighting.hpp index a1da9f7e38..eb8c97b129 100644 --- a/apps/opencs/view/render/lighting.hpp +++ b/apps/opencs/view/render/lighting.hpp @@ -1,10 +1,13 @@ #ifndef OPENCS_VIEW_LIGHTING_H #define OPENCS_VIEW_LIGHTING_H -namespace Ogre +namespace osgViewer { - class SceneManager; - class ColourValue; + class View; +} +namespace osg +{ + class Vec4f; } namespace CSVRender @@ -15,12 +18,12 @@ namespace CSVRender virtual ~Lighting(); - virtual void activate (Ogre::SceneManager *sceneManager, - const Ogre::ColourValue *defaultAmbient = 0) = 0; + virtual void activate (osgViewer::View* view, + const osg::Vec4f *defaultAmbient = 0) = 0; virtual void deactivate() = 0; - virtual void setDefaultAmbient (const Ogre::ColourValue& colour) = 0; + virtual void setDefaultAmbient (const osg::Vec4f& colour) = 0; }; } diff --git a/apps/opencs/view/render/lightingbright.cpp b/apps/opencs/view/render/lightingbright.cpp index a342ab0936..6d3d4d7906 100644 --- a/apps/opencs/view/render/lightingbright.cpp +++ b/apps/opencs/view/render/lightingbright.cpp @@ -3,28 +3,28 @@ #include -CSVRender::LightingBright::LightingBright() : mSceneManager (0), mLight (0) {} +#include -void CSVRender::LightingBright::activate (Ogre::SceneManager *sceneManager, - const Ogre::ColourValue *defaultAmbient) +CSVRender::LightingBright::LightingBright() : mView(NULL) {} + +void CSVRender::LightingBright::activate (osgViewer::View* view, + const osg::Vec4f* /*defaultAmbient*/) { - mSceneManager = sceneManager; + mView = view; + + // FIXME: ambient should be applied to LightModel instead of the light - mSceneManager->setAmbientLight (Ogre::ColourValue (1.0, 1.0, 1.0, 1)); + osg::ref_ptr light (new osg::Light); + light->setConstantAttenuation(1.f); + light->setDirection(osg::Vec3f(0.f, 0.f, -1.f)); + light->setDiffuse(osg::Vec4f(1.f, 1.f, 1.f, 1.f)); + light->setAmbient(osg::Vec4f(1.f, 1.f, 1.f, 1.f)); - mLight = mSceneManager->createLight(); - mLight->setType (Ogre::Light::LT_DIRECTIONAL); - mLight->setDirection (Ogre::Vector3 (0, 0, -1)); - mLight->setDiffuseColour (Ogre::ColourValue (1.0, 1.0, 1.0)); + mView->setLight(light); } void CSVRender::LightingBright::deactivate() { - if (mLight) - { - mSceneManager->destroyLight (mLight); - mLight = 0; - } } -void CSVRender::LightingBright::setDefaultAmbient (const Ogre::ColourValue& colour) {} +void CSVRender::LightingBright::setDefaultAmbient (const osg::Vec4f& colour) {} diff --git a/apps/opencs/view/render/lightingbright.hpp b/apps/opencs/view/render/lightingbright.hpp index bc01899cb0..e7ef63f0a9 100644 --- a/apps/opencs/view/render/lightingbright.hpp +++ b/apps/opencs/view/render/lightingbright.hpp @@ -12,19 +12,18 @@ namespace CSVRender { class LightingBright : public Lighting { - Ogre::SceneManager *mSceneManager; - Ogre::Light *mLight; + osgViewer::View* mView; public: LightingBright(); - virtual void activate (Ogre::SceneManager *sceneManager, - const Ogre::ColourValue *defaultAmbient = 0); + virtual void activate (osgViewer::View* view, + const osg::Vec4f *defaultAmbient = 0); virtual void deactivate(); - virtual void setDefaultAmbient (const Ogre::ColourValue& colour); + virtual void setDefaultAmbient (const osg::Vec4f& colour); }; } diff --git a/apps/opencs/view/render/lightingday.cpp b/apps/opencs/view/render/lightingday.cpp index c5189ccfdf..1d8444bc37 100644 --- a/apps/opencs/view/render/lightingday.cpp +++ b/apps/opencs/view/render/lightingday.cpp @@ -1,36 +1,33 @@ - #include "lightingday.hpp" -#include +#include -CSVRender::LightingDay::LightingDay() : mSceneManager (0), mLight (0) {} +CSVRender::LightingDay::LightingDay() : mView(NULL) {} -void CSVRender::LightingDay::activate (Ogre::SceneManager *sceneManager, - const Ogre::ColourValue *defaultAmbient) +void CSVRender::LightingDay::activate (osgViewer::View* view, + const osg::Vec4f *defaultAmbient) { - mSceneManager = sceneManager; + mView = view; + + osg::ref_ptr light (new osg::Light); + light->setDirection(osg::Vec3f(0.f, 0.f, -1.f)); + light->setDiffuse(osg::Vec4f(1.f, 1.f, 1.f, 1.f)); + light->setConstantAttenuation(1.f); if (defaultAmbient) - mSceneManager->setAmbientLight (*defaultAmbient); + light->setAmbient(*defaultAmbient); else - mSceneManager->setAmbientLight (Ogre::ColourValue (0.7, 0.7, 0.7, 1)); + light->setAmbient(osg::Vec4f(0.7f, 0.7f, 0.7f, 1.f)); - mLight = mSceneManager->createLight(); - mLight->setType (Ogre::Light::LT_DIRECTIONAL); - mLight->setDirection (Ogre::Vector3 (0, 0, -1)); - mLight->setDiffuseColour (Ogre::ColourValue (1, 1, 1)); + mView->setLight(light); } void CSVRender::LightingDay::deactivate() { - if (mLight) - { - mSceneManager->destroyLight (mLight); - mLight = 0; - } } -void CSVRender::LightingDay::setDefaultAmbient (const Ogre::ColourValue& colour) +void CSVRender::LightingDay::setDefaultAmbient (const osg::Vec4f& colour) { - mSceneManager->setAmbientLight (colour); + if (mView) + mView->getLight()->setAmbient(colour); } diff --git a/apps/opencs/view/render/lightingday.hpp b/apps/opencs/view/render/lightingday.hpp index 8638146e23..a0f39b866a 100644 --- a/apps/opencs/view/render/lightingday.hpp +++ b/apps/opencs/view/render/lightingday.hpp @@ -12,19 +12,18 @@ namespace CSVRender { class LightingDay : public Lighting { - Ogre::SceneManager *mSceneManager; - Ogre::Light *mLight; + osgViewer::View* mView; public: LightingDay(); - virtual void activate (Ogre::SceneManager *sceneManager, - const Ogre::ColourValue *defaultAmbient = 0); + virtual void activate (osgViewer::View* view, + const osg::Vec4f *defaultAmbient = 0); virtual void deactivate(); - virtual void setDefaultAmbient (const Ogre::ColourValue& colour); + virtual void setDefaultAmbient (const osg::Vec4f& colour); }; } diff --git a/apps/opencs/view/render/lightingnight.cpp b/apps/opencs/view/render/lightingnight.cpp index 7d94dc9646..81236ec13a 100644 --- a/apps/opencs/view/render/lightingnight.cpp +++ b/apps/opencs/view/render/lightingnight.cpp @@ -1,36 +1,33 @@ - #include "lightingnight.hpp" -#include +#include -CSVRender::LightingNight::LightingNight() : mSceneManager (0), mLight (0) {} +CSVRender::LightingNight::LightingNight() : mView(NULL) {} -void CSVRender::LightingNight::activate (Ogre::SceneManager *sceneManager, - const Ogre::ColourValue *defaultAmbient) +void CSVRender::LightingNight::activate (osgViewer::View* view, + const osg::Vec4f *defaultAmbient) { - mSceneManager = sceneManager; + mView = view; + + osg::ref_ptr light (new osg::Light); + light->setDirection(osg::Vec3f(0.f, 0.f, -1.f)); + light->setDiffuse(osg::Vec4f(0.2f, 0.2f, 0.2f, 1.f)); + light->setConstantAttenuation(1.f); if (defaultAmbient) - mSceneManager->setAmbientLight (*defaultAmbient); + light->setAmbient(*defaultAmbient); else - mSceneManager->setAmbientLight (Ogre::ColourValue (0.2, 0.2, 0.2, 1)); + light->setAmbient(osg::Vec4f(0.2f, 0.2f, 0.2f, 1.f)); - mLight = mSceneManager->createLight(); - mLight->setType (Ogre::Light::LT_DIRECTIONAL); - mLight->setDirection (Ogre::Vector3 (0, 0, -1)); - mLight->setDiffuseColour (Ogre::ColourValue (0.2, 0.2, 0.2)); + mView->setLight(light); } void CSVRender::LightingNight::deactivate() { - if (mLight) - { - mSceneManager->destroyLight (mLight); - mLight = 0; - } } -void CSVRender::LightingNight::setDefaultAmbient (const Ogre::ColourValue& colour) +void CSVRender::LightingNight::setDefaultAmbient (const osg::Vec4f& colour) { - mSceneManager->setAmbientLight (colour); + if (mView) + mView->getLight()->setAmbient(colour); } diff --git a/apps/opencs/view/render/lightingnight.hpp b/apps/opencs/view/render/lightingnight.hpp index 47d1d7ce82..b2fd178932 100644 --- a/apps/opencs/view/render/lightingnight.hpp +++ b/apps/opencs/view/render/lightingnight.hpp @@ -12,19 +12,18 @@ namespace CSVRender { class LightingNight : public Lighting { - Ogre::SceneManager *mSceneManager; - Ogre::Light *mLight; + osgViewer::View* mView; public: LightingNight(); - virtual void activate (Ogre::SceneManager *sceneManager, - const Ogre::ColourValue *defaultAmbient = 0); + virtual void activate (osgViewer::View* view, + const osg::Vec4f *defaultAmbient = 0); virtual void deactivate(); - virtual void setDefaultAmbient (const Ogre::ColourValue& colour); + virtual void setDefaultAmbient (const osg::Vec4f& colour); }; } diff --git a/apps/opencs/view/render/previewwidget.cpp b/apps/opencs/view/render/previewwidget.cpp index 02fcd9f060..f0cbc939aa 100644 --- a/apps/opencs/view/render/previewwidget.cpp +++ b/apps/opencs/view/render/previewwidget.cpp @@ -8,7 +8,7 @@ CSVRender::PreviewWidget::PreviewWidget (CSMWorld::Data& data, const std::string& id, bool referenceable, QWidget *parent) -: SceneWidget (parent), mData (data), mObject(data, mRootNode, id, referenceable) +: SceneWidget (data.getResourceSystem()->getSceneManager(), parent), mData (data), mObject(data, mRootNode, id, referenceable) { mView->setCameraManipulator(new osgGA::TrackballManipulator); diff --git a/apps/opencs/view/render/scenewidget.cpp b/apps/opencs/view/render/scenewidget.cpp index d7a85410bc..ef2d701c60 100644 --- a/apps/opencs/view/render/scenewidget.cpp +++ b/apps/opencs/view/render/scenewidget.cpp @@ -6,21 +6,23 @@ #include #include +#include +#include +#include +#include + +#include + #include "../widget/scenetoolmode.hpp" #include "../../model/settings/usersettings.hpp" #include "navigation.hpp" #include "lighting.hpp" -#include -#include -#include -#include - namespace CSVRender { -SceneWidget::SceneWidget(QWidget *parent, Qt::WindowFlags f) +RenderWidget::RenderWidget(QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f) , mRootNode(0) { @@ -58,9 +60,8 @@ SceneWidget::SceneWidget(QWidget *parent, Qt::WindowFlags f) mView->getCamera()->setProjectionMatrixAsPerspective(30.0f, static_cast(traits->width)/static_cast(traits->height), 1.0f, 10000.0f ); mRootNode = new osg::Group; - // TODO: move to utility file - mRootNode->getOrCreateStateSet()->setMode(GL_NORMALIZE, osg::StateAttribute::ON); - mRootNode->getOrCreateStateSet()->setMode(GL_CULL_FACE, osg::StateAttribute::ON); + + addDefaultRootState(mRootNode->getOrCreateStateSet()); mView->setSceneData(mRootNode); @@ -74,22 +75,30 @@ SceneWidget::SceneWidget(QWidget *parent, Qt::WindowFlags f) viewer.realize(); } -SceneWidget::~SceneWidget() +void RenderWidget::addDefaultRootState(osg::StateSet* stateset) +{ + stateset->setMode(GL_NORMALIZE, osg::StateAttribute::ON); + stateset->setMode(GL_CULL_FACE, osg::StateAttribute::ON); +} + +RenderWidget::~RenderWidget() { CompositeViewer::get().removeView(mView); } -void SceneWidget::flagAsModified() +void RenderWidget::flagAsModified() { mView->requestRedraw(); } -void SceneWidget::setVisibilityMask(int mask) +void RenderWidget::setVisibilityMask(int mask) { // 0x1 reserved for separating cull and update visitors mView->getCamera()->setCullMask(mask<<1); } +// -------------------------------------------------- + CompositeViewer::CompositeViewer() { #if QT_VERSION >= 0x050000 @@ -109,7 +118,7 @@ CompositeViewer::CompositeViewer() setRunFrameScheme(osgViewer::ViewerBase::CONTINUOUS); connect( &mTimer, SIGNAL(timeout()), this, SLOT(update()) ); - mTimer.start( 0 ); + mTimer.start( 10 ); } CompositeViewer &CompositeViewer::get() @@ -123,4 +132,80 @@ void CompositeViewer::update() frame(); } +// --------------------------------------------------- + +SceneWidget::SceneWidget(Resource::SceneManager* sceneManager, QWidget *parent, Qt::WindowFlags f) + : RenderWidget(parent, f) + , mSceneManager(sceneManager) + , mLighting(NULL) +{ + //mView->setLightingMode(osgViewer::View::NO_LIGHT); + + setLighting(&mLightingDay); +} + +SceneWidget::~SceneWidget() +{ + // Since we're holding on to the scene templates past the existance of this graphics context, we'll need to manually release the created objects + mSceneManager->releaseGLObjects(mView->getCamera()->getGraphicsContext()->getState()); +} + +void SceneWidget::setLighting(Lighting *lighting) +{ + if (mLighting) + mLighting->deactivate(); + + mLighting = lighting; + mLighting->activate (mView.get(), mHasDefaultAmbient ? &mDefaultAmbient : 0); + + flagAsModified(); +} + +void SceneWidget::selectLightingMode (const std::string& mode) +{ + if (mode=="day") + setLighting (&mLightingDay); + else if (mode=="night") + setLighting (&mLightingNight); + else if (mode=="bright") + setLighting (&mLightingBright); +} + +CSVWidget::SceneToolMode *SceneWidget::makeLightingSelector (CSVWidget::SceneToolbar *parent) +{ + CSVWidget::SceneToolMode *tool = new CSVWidget::SceneToolMode (parent, "Lighting Mode"); + + /// \todo replace icons + tool->addButton (":scenetoolbar/day", "day", + "Day" + "
  • Cell specific ambient in interiors
  • " + "
  • Low ambient in exteriors
  • " + "
  • Strong directional light source
  • " + "
  • This mode closely resembles day time in-game
"); + tool->addButton (":scenetoolbar/night", "night", + "Night" + "
  • Cell specific ambient in interiors
  • " + "
  • Low ambient in exteriors
  • " + "
  • Weak directional light source
  • " + "
  • This mode closely resembles night time in-game
"); + tool->addButton (":scenetoolbar/bright", "bright", + "Bright" + "
  • Maximum ambient
  • " + "
  • Strong directional light source
"); + + connect (tool, SIGNAL (modeChanged (const std::string&)), + this, SLOT (selectLightingMode (const std::string&))); + + return tool; +} + +void SceneWidget::setDefaultAmbient (const osg::Vec4f& colour) +{ + mDefaultAmbient = colour; + mHasDefaultAmbient = true; + + if (mLighting) + mLighting->setDefaultAmbient (colour); +} + } diff --git a/apps/opencs/view/render/scenewidget.hpp b/apps/opencs/view/render/scenewidget.hpp index 04025340d3..8580a2bb1a 100644 --- a/apps/opencs/view/render/scenewidget.hpp +++ b/apps/opencs/view/render/scenewidget.hpp @@ -11,6 +11,11 @@ #include #include +namespace Resource +{ + class SceneManager; +} + namespace osg { class Group; @@ -27,13 +32,13 @@ namespace CSVRender class Navigation; class Lighting; - class SceneWidget : public QWidget + class RenderWidget : public QWidget { Q_OBJECT public: - SceneWidget(QWidget* parent = 0, Qt::WindowFlags f = 0); - ~SceneWidget(); + RenderWidget(QWidget* parent = 0, Qt::WindowFlags f = 0); + virtual ~RenderWidget(); void flagAsModified(); @@ -41,6 +46,8 @@ namespace CSVRender protected: + void addDefaultRootState(osg::StateSet* stateset); + osg::ref_ptr mView; osg::Group* mRootNode; @@ -48,6 +55,39 @@ namespace CSVRender QTimer mTimer; }; + // Extension of RenderWidget to support lighting mode selection & toolbar + class SceneWidget : public RenderWidget + { + Q_OBJECT + public: + SceneWidget(Resource::SceneManager* sceneManager, QWidget* parent = 0, Qt::WindowFlags f = 0); + virtual ~SceneWidget(); + + CSVWidget::SceneToolMode *makeLightingSelector (CSVWidget::SceneToolbar *parent); + ///< \attention The created tool is not added to the toolbar (via addTool). Doing that + /// is the responsibility of the calling function. + + void setDefaultAmbient (const osg::Vec4f& colour); + ///< \note The actual ambient colour may differ based on lighting settings. + + protected: + void setLighting (Lighting *lighting); + ///< \attention The ownership of \a lighting is not transferred to *this. + + Resource::SceneManager* mSceneManager; + + Lighting* mLighting; + + osg::Vec4f mDefaultAmbient; + bool mHasDefaultAmbient; + LightingDay mLightingDay; + LightingNight mLightingNight; + LightingBright mLightingBright; + + private slots: + + void selectLightingMode (const std::string& mode); + }; // There are rendering glitches when using multiple Viewer instances, work around using CompositeViewer with multiple views diff --git a/apps/opencs/view/render/unpagedworldspacewidget.cpp b/apps/opencs/view/render/unpagedworldspacewidget.cpp index e48b84cffb..a6d18a0f2d 100644 --- a/apps/opencs/view/render/unpagedworldspacewidget.cpp +++ b/apps/opencs/view/render/unpagedworldspacewidget.cpp @@ -23,9 +23,12 @@ void CSVRender::UnpagedWorldspaceWidget::update() const CSMWorld::Record& record = dynamic_cast&> (mCellsModel->getRecord (mCellId)); - Ogre::ColourValue colour; - colour.setAsABGR (record.get().mAmbi.mAmbient); - //setDefaultAmbient (colour); + ESM::Color clr = record.get().mAmbi.mAmbient; + osg::Vec4f colour(((clr >> 0) & 0xFF) / 255.0f, + ((clr >> 8) & 0xFF) / 255.0f, + ((clr >> 16) & 0xFF) / 255.0f, 1.f); + + setDefaultAmbient (colour); /// \todo deal with mSunlight and mFog/mForDensity @@ -51,7 +54,6 @@ CSVRender::UnpagedWorldspaceWidget::UnpagedWorldspaceWidget (const std::string& mCell.reset (new Cell (document.getData(), mRootNode, mCellId)); mView->setCameraManipulator(new osgGA::TrackballManipulator); - //mView->setCameraManipulator(new osgGA::FirstPersonManipulator); } void CSVRender::UnpagedWorldspaceWidget::cellDataChanged (const QModelIndex& topLeft, @@ -93,7 +95,7 @@ bool CSVRender::UnpagedWorldspaceWidget::handleDrop (const std::vectorgetId(); - // FIXME: we shouldn't need to rebuild the whole cell + mCell.reset (new Cell (getDocument().getData(), mRootNode, mCellId)); update(); diff --git a/apps/opencs/view/render/worldspacewidget.cpp b/apps/opencs/view/render/worldspacewidget.cpp index 4bbfd5bcdc..2d7a0a0f85 100644 --- a/apps/opencs/view/render/worldspacewidget.cpp +++ b/apps/opencs/view/render/worldspacewidget.cpp @@ -19,7 +19,7 @@ #include "editmode.hpp" CSVRender::WorldspaceWidget::WorldspaceWidget (CSMDoc::Document& document, QWidget* parent) -: SceneWidget (parent), mDocument(document), mSceneElements(0), mRun(0), +: SceneWidget (document.getData().getResourceSystem()->getSceneManager(), parent), mDocument(document), mSceneElements(0), mRun(0), mInteractionMask (0) { setAcceptDrops(true); @@ -361,7 +361,7 @@ void CSVRender::WorldspaceWidget::mouseMoveEvent (QMouseEvent *event) { //mMouse->mouseMoveEvent(event); } - SceneWidget::mouseMoveEvent(event); + RenderWidget::mouseMoveEvent(event); } void CSVRender::WorldspaceWidget::mousePressEvent (QMouseEvent *event) @@ -386,7 +386,7 @@ void CSVRender::WorldspaceWidget::mouseReleaseEvent (QMouseEvent *event) */ //mMouse->mouseReleaseEvent(event); } - SceneWidget::mouseReleaseEvent(event); + RenderWidget::mouseReleaseEvent(event); } void CSVRender::WorldspaceWidget::mouseDoubleClickEvent (QMouseEvent *event) @@ -401,7 +401,7 @@ void CSVRender::WorldspaceWidget::mouseDoubleClickEvent (QMouseEvent *event) void CSVRender::WorldspaceWidget::wheelEvent (QWheelEvent *event) { //if(!mMouse->wheelEvent(event)) - SceneWidget::wheelEvent(event); + RenderWidget::wheelEvent(event); } void CSVRender::WorldspaceWidget::keyPressEvent (QKeyEvent *event) @@ -411,5 +411,5 @@ void CSVRender::WorldspaceWidget::keyPressEvent (QKeyEvent *event) //mMouse->cancelDrag(); } else - SceneWidget::keyPressEvent(event); + RenderWidget::keyPressEvent(event); } diff --git a/apps/opencs/view/world/previewsubview.cpp b/apps/opencs/view/world/previewsubview.cpp index 0c9823c444..1c2d6b95c7 100644 --- a/apps/opencs/view/world/previewsubview.cpp +++ b/apps/opencs/view/world/previewsubview.cpp @@ -30,8 +30,8 @@ CSVWorld::PreviewSubView::PreviewSubView (const CSMWorld::UniversalId& id, CSMDo CSVWidget::SceneToolbar *toolbar = new CSVWidget::SceneToolbar (48+6, this); - //CSVWidget::SceneToolMode *lightingTool = mScene->makeLightingSelector (toolbar); - //toolbar->addTool (lightingTool); + CSVWidget::SceneToolMode *lightingTool = mScene->makeLightingSelector (toolbar); + toolbar->addTool (lightingTool); layout->addWidget (toolbar, 0); diff --git a/apps/opencs/view/world/scenesubview.cpp b/apps/opencs/view/world/scenesubview.cpp index c59236ee5d..3fdf2f6e5c 100644 --- a/apps/opencs/view/world/scenesubview.cpp +++ b/apps/opencs/view/world/scenesubview.cpp @@ -107,8 +107,8 @@ CSVWidget::SceneToolbar* CSVWorld::SceneSubView::makeToolbar (CSVRender::Worldsp CSVWidget::SceneToolMode *navigationTool = widget->makeNavigationSelector (toolbar); toolbar->addTool (navigationTool); - //CSVWidget::SceneToolMode *lightingTool = widget->makeLightingSelector (toolbar); - //toolbar->addTool (lightingTool); + CSVWidget::SceneToolMode *lightingTool = widget->makeLightingSelector (toolbar); + toolbar->addTool (lightingTool); CSVWidget::SceneToolToggle2 *sceneVisibilityTool = widget->makeSceneVisibilitySelector (toolbar); diff --git a/components/esm/defs.hpp b/components/esm/defs.hpp index 7ef8102c29..d261d7247d 100644 --- a/components/esm/defs.hpp +++ b/components/esm/defs.hpp @@ -13,7 +13,7 @@ struct TimeStamp }; // Pixel color value. Standard four-byte rr,gg,bb,aa format. -typedef int32_t Color; +typedef uint32_t Color; enum Specialization { diff --git a/components/resource/scenemanager.cpp b/components/resource/scenemanager.cpp index c44cbd2ae4..3f38762caa 100644 --- a/components/resource/scenemanager.cpp +++ b/components/resource/scenemanager.cpp @@ -115,4 +115,12 @@ namespace Resource instance->accept(visitor); } + void SceneManager::releaseGLObjects(osg::State *state) + { + for (Index::iterator it = mIndex.begin(); it != mIndex.end(); ++it) + { + it->second->releaseGLObjects(state); + } + } + } diff --git a/components/resource/scenemanager.hpp b/components/resource/scenemanager.hpp index 3d439c1867..7b3bcb2d54 100644 --- a/components/resource/scenemanager.hpp +++ b/components/resource/scenemanager.hpp @@ -41,6 +41,8 @@ namespace Resource /// @note Assumes the given instance was not attached to any parents before. void attachTo(osg::Node* instance, osg::Group* parentNode) const; + void releaseGLObjects(osg::State* state); + private: const VFS::Manager* mVFS; Resource::TextureManager* mTextureManager;