Changeset 9448 for code/branches/shaders/src/orxonox/RenderQueueListener.cc
- Timestamp:
- Nov 14, 2012, 9:16:18 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/shaders/src/orxonox/RenderQueueListener.cc
r9420 r9448 37 37 #include <OgreRoot.h> 38 38 #include <OgreRenderQueueListener.h> 39 #include <OgreHardwareOcclusionQuery.h> 39 40 40 41 namespace orxonox 41 42 { 43 RenderQueueListener::RenderQueueListener() : pixelCount_(0), pixelState_(RenderQueueListener::READY_FOR_RENDER) 44 { 45 hardwareOcclusionQuery_ = Ogre::Root::getSingleton().getRenderSystem()->createHardwareOcclusionQuery(); //create a new HOQ for the scene this listener is used in 46 } 47 48 RenderQueueListener::~RenderQueueListener() 49 { 50 Ogre::Root::getSingleton().getRenderSystem()->destroyHardwareOcclusionQuery(hardwareOcclusionQuery_); //destroy the created HOQ 51 } 52 53 /** 54 @brief 55 This function is returning the current pixel count and resets the pixel state if we're ready to do another Hardware Occlusion Query 56 57 @return 58 current pixel count taken from the last Hardware Occlusion Query 59 */ 60 unsigned int RenderQueueListener::getPixelCount() 61 { 62 if(this->pixelState_==RenderQueueListener::READY_FOR_ACCESS) 63 { 64 this->hardwareOcclusionQuery_->pullOcclusionQuery(&(this->pixelCount_)); 65 this->pixelState_=RenderQueueListener::READY_FOR_RENDER; 66 } 67 return this->pixelCount_; 68 } 69 42 70 /** 43 71 @brief 44 72 This function is called just before a RenderQueueGroup is rendered, this function is called by Ogre automatically with the correct parameters. 45 73 46 In this case we use it to set the stencil buffer parameters of the render system 74 In this case we use it to set the stencil buffer parameters of the render system and issue a Hardware Occlusion Query 47 75 */ 48 76 void RenderQueueListener::renderQueueStarted(Ogre::uint8 queueGroupId, const Ogre::String& invocation, bool& skipThisInvocation) … … 60 88 if (queueGroupId == RENDER_QUEUE_STENCIL_GLOW) 61 89 { 62 Ogre::RenderSystem * renderSystem = Ogre::Root::getSingleton().getRenderSystem(); 63 renderSystem->setStencilCheckEnabled(true); 64 renderSystem->setStencilBufferParams(Ogre::CMPF_NOT_EQUAL, 65 STENCIL_VALUE_FOR_GLOW, STENCIL_FULL_MASK, 66 Ogre::SOP_KEEP,Ogre::SOP_KEEP,Ogre::SOP_REPLACE,false); 90 Ogre::RenderSystem * renderSystem = Ogre::Root::getSingleton().getRenderSystem(); 91 renderSystem->setStencilCheckEnabled(true); 92 renderSystem->setStencilBufferParams(Ogre::CMPF_NOT_EQUAL, 93 STENCIL_VALUE_FOR_GLOW, STENCIL_FULL_MASK, 94 Ogre::SOP_KEEP,Ogre::SOP_KEEP,Ogre::SOP_REPLACE,false); 95 } 96 if (queueGroupId == RENDER_QUEUE_HOQ && this->pixelState_==RenderQueueListener::READY_FOR_RENDER) 97 { 98 this->hardwareOcclusionQuery_->beginOcclusionQuery(); 99 this->pixelState_=RenderQueueListener::QUERY_STARTED; 100 //TODO: Skip this rendering step altogheter if we haven't requested the pixel count yet, not sure if this is possible without a custom SceneManager 67 101 } 68 102 } … … 82 116 renderSystem->setStencilBufferParams(); 83 117 } 118 if (queueGroupId == RENDER_QUEUE_HOQ && this->pixelState_==RenderQueueListener::QUERY_STARTED) 119 { 120 this->hardwareOcclusionQuery_->endOcclusionQuery(); 121 this->pixelState_=RenderQueueListener::READY_FOR_ACCESS; 122 } 84 123 } 85 124 }
Note: See TracChangeset
for help on using the changeset viewer.