From f4898539e9c99f0f2c4a36c0f47bf0f90dcc0290 Mon Sep 17 00:00:00 2001 From: scrawl Date: Sat, 24 Mar 2012 13:06:01 +0100 Subject: [PATCH] added some code that doesn't do anything yet, waiting for ogre 1.8 --- apps/openmw/CMakeLists.txt | 2 +- apps/openmw/mwrender/occlusionquery.cpp | 27 +++++++++++++++++++++++ apps/openmw/mwrender/occlusionquery.hpp | 27 +++++++++++++++++++++++ apps/openmw/mwrender/renderingmanager.cpp | 3 +++ apps/openmw/mwrender/renderingmanager.hpp | 7 ++++-- 5 files changed, 63 insertions(+), 3 deletions(-) create mode 100644 apps/openmw/mwrender/occlusionquery.cpp create mode 100644 apps/openmw/mwrender/occlusionquery.hpp diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 2630098f5..7d4836d3b 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -15,7 +15,7 @@ source_group(game FILES ${GAME} ${GAME_HEADER}) add_openmw_dir (mwrender renderingmanager debugging sky player animation npcanimation creatureanimation actors objects - renderinginterface localmap + renderinginterface localmap occlusionquery ) add_openmw_dir (mwinput diff --git a/apps/openmw/mwrender/occlusionquery.cpp b/apps/openmw/mwrender/occlusionquery.cpp new file mode 100644 index 000000000..395660bb5 --- /dev/null +++ b/apps/openmw/mwrender/occlusionquery.cpp @@ -0,0 +1,27 @@ +#include "occlusionquery.hpp" + +#include +#include + +using namespace MWRender; +using namespace Ogre; + +OcclusionQuery::OcclusionQuery() : + mSunTotalAreaQuery(0), mSunVisibleAreaQuery(0) +{ + try { + RenderSystem* renderSystem = Root::getSingleton().getRenderSystem(); + + mSunTotalAreaQuery = renderSystem->createHardwareOcclusionQuery(); + mSunVisibleAreaQuery = renderSystem->createHardwareOcclusionQuery(); + + mSupported = (mSunTotalAreaQuery != 0) && (mSunVisibleAreaQuery != 0); + } + catch (Ogre::Exception e) + { + mSupported = false; + } + + if (!mSupported) + std::cout << "Hardware occlusion queries not supported." << std::endl; +} diff --git a/apps/openmw/mwrender/occlusionquery.hpp b/apps/openmw/mwrender/occlusionquery.hpp new file mode 100644 index 000000000..619b072ee --- /dev/null +++ b/apps/openmw/mwrender/occlusionquery.hpp @@ -0,0 +1,27 @@ +#ifndef _GAME_OCCLUSION_QUERY_H +#define _GAME_OCCLUSION_QUERY_H + +#include + +namespace MWRender +{ + /// + /// \brief Implements hardware occlusion queries on the GPU + /// + class OcclusionQuery + { + public: + OcclusionQuery(); + + bool supported(); + ///< returns true if occlusion queries are supported on the user's hardware + + private: + Ogre::HardwareOcclusionQuery* mSunTotalAreaQuery; + Ogre::HardwareOcclusionQuery* mSunVisibleAreaQuery; + + bool mSupported; + }; +} + +#endif diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index e2aea19c6..78287dadb 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -49,6 +49,8 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const Ogre::SceneNode *cameraYawNode = playerNode->createChildSceneNode(); Ogre::SceneNode *cameraPitchNode = cameraYawNode->createChildSceneNode(); cameraPitchNode->attachObject(mRendering.getCamera()); + + mOcclusionQuery = new OcclusionQuery(); //mSkyManager = 0; mSkyManager = new SkyManager(mMwRoot, mRendering.getCamera(), &environment); @@ -65,6 +67,7 @@ RenderingManager::~RenderingManager () delete mPlayer; delete mSkyManager; delete mLocalMap; + delete mOcclusionQuery; } MWRender::SkyManager* RenderingManager::getSkyManager() diff --git a/apps/openmw/mwrender/renderingmanager.hpp b/apps/openmw/mwrender/renderingmanager.hpp index 78a1d2fdb..996396633 100644 --- a/apps/openmw/mwrender/renderingmanager.hpp +++ b/apps/openmw/mwrender/renderingmanager.hpp @@ -25,6 +25,7 @@ #include "actors.hpp" #include "player.hpp" #include "localmap.hpp" +#include "occlusionquery.hpp" namespace Ogre { @@ -131,9 +132,11 @@ class RenderingManager: private RenderingInterface { private: void setAmbientMode(); - + SkyManager* mSkyManager; - + + OcclusionQuery* mOcclusionQuery; + OEngine::Render::OgreRenderer &mRendering; MWRender::Objects mObjects;