[59] | 1 | #include "OgrePlatformOcclusionQuery.h"
|
---|
[115] | 2 | #include <OgreLogManager.h>
|
---|
[96] | 3 |
|
---|
[59] | 4 | namespace Ogre {
|
---|
| 5 |
|
---|
| 6 | //-----------------------------------------------------------------------
|
---|
| 7 | PlatformOcclusionQuery::PlatformOcclusionQuery(RenderSystem *rsys)
|
---|
| 8 | {
|
---|
| 9 | mHardwareOcclusionQuery = rsys->createHardwareOcclusionQuery();
|
---|
| 10 | }
|
---|
| 11 | //-----------------------------------------------------------------------
|
---|
| 12 | PlatformOcclusionQuery::~PlatformOcclusionQuery()
|
---|
| 13 | {
|
---|
[944] | 14 | // hardwareocclusion query is deleted by Ogre
|
---|
[903] | 15 | //delete mHardwareOcclusionQuery;
|
---|
[59] | 16 | }
|
---|
| 17 | //-----------------------------------------------------------------------
|
---|
[87] | 18 | void PlatformOcclusionQuery::BeginQuery()
|
---|
[59] | 19 | {
|
---|
| 20 | mHardwareOcclusionQuery->beginOcclusionQuery();
|
---|
| 21 | }
|
---|
| 22 | //-----------------------------------------------------------------------
|
---|
[87] | 23 | void PlatformOcclusionQuery::EndQuery()
|
---|
[59] | 24 | {
|
---|
| 25 | mHardwareOcclusionQuery->endOcclusionQuery();
|
---|
| 26 | }
|
---|
| 27 | //-----------------------------------------------------------------------
|
---|
[86] | 28 | bool PlatformOcclusionQuery::GetQueryResult(unsigned int &visiblePixels,
|
---|
| 29 | const bool waitForResult) const
|
---|
[59] | 30 | {
|
---|
[897] | 31 | // return mHardwareOcclusionQuery->pullOcclusionQuery(&visiblePixels, waitForResult);
|
---|
| 32 |
|
---|
| 33 | bool isAvailable = true;
|
---|
| 34 |
|
---|
[925] | 35 | if (!waitForResult)
|
---|
| 36 | {
|
---|
[897] | 37 | isAvailable = !mHardwareOcclusionQuery->isStillOutstanding();
|
---|
[925] | 38 | }
|
---|
| 39 |
|
---|
[938] | 40 | //std::stringstream d; d << mHardwareOcclusionQuery << ", available: " << isAvailable << ", waitforresult: " << waitForResult;
|
---|
| 41 | // Ogre::LogManager::getSingleton().logMessage(d.str());
|
---|
| 42 |
|
---|
[897] | 43 | if (isAvailable)
|
---|
| 44 | return mHardwareOcclusionQuery->pullOcclusionQuery(&visiblePixels);
|
---|
[925] | 45 |
|
---|
| 46 | return false;
|
---|
[59] | 47 | }
|
---|
| 48 |
|
---|
| 49 | } // namespace Ogre |
---|