Changeset 343 for trunk/VUT/work/ogre_changes/RenderSystems/GL/src
- Timestamp:
- 10/20/05 18:49:11 (19 years ago)
- Location:
- trunk/VUT/work/ogre_changes/RenderSystems/GL/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/work/ogre_changes/RenderSystems/GL/src/OgreGLHardwareOcclusionQuery.cpp
r193 r343 29 29 namespace Ogre { 30 30 31 bool GLHardwareOcclusionQuery::sUseArbQueries = false; 31 32 /** 32 33 * This is a class that is the base class of the query class for … … 51 52 // Check for hardware occlusion support 52 53 // This is a hack to see if hw occlusion is supported. pointer is 0 if it's not supported. 53 #ifdef GTP_VISIBILITY_USE_ARB_QUERIES 54 if (glGenQueriesARB_ptr != 0) 55 #else 56 if (glGenOcclusionQueriesNV_ptr != 0) 57 #endif 58 { 59 mHasOcclusionSupport = true; 60 } 61 else 62 { 63 mHasOcclusionSupport = false; 64 } 54 mHasOcclusionSupportARB = (glGenQueriesARB_ptr != 0); 55 mHasOcclusionSupportNV = (glGenOcclusionQueriesNV_ptr != 0); 65 56 66 if(mHasOcclusionSupport) 67 { 68 #ifdef GTP_VISIBILITY_USE_ARB_QUERIES 57 if (sUseArbQueries && mHasOcclusionSupportARB) 69 58 glGenQueriesARB_ptr(1, &mQueryID ); 70 #else 59 else if (!sUseArbQueries && mHasOcclusionSupportNV) 71 60 glGenOcclusionQueriesNV_ptr(1, &mQueryID); 72 #endif73 }74 61 } 75 62 … … 79 66 GLHardwareOcclusionQuery::~GLHardwareOcclusionQuery() 80 67 { 81 if( mHasOcclusionSupport ) 82 { 83 #ifdef GTP_VISIBILITY_USE_ARB_QUERIES 68 if (sUseArbQueries && mHasOcclusionSupportARB) 84 69 glDeleteQueriesARB_ptr(1, &mQueryID); 85 #else 70 else if (!sUseArbQueries && mHasOcclusionSupportNV) 86 71 glDeleteOcclusionQueriesNV_ptr(1, &mQueryID); 87 #endif88 }89 72 } 90 73 … … 94 77 void GLHardwareOcclusionQuery::beginOcclusionQuery() 95 78 { 96 // Make it fail silently if hardware occlusion isn't supported 97 if(mHasOcclusionSupport) 98 { 99 // Counter starts at 0 again at mSkipInterval 100 #ifndef GTP_VISIBILITY_MODIFIED_OGRE 101 if(mSkipCounter == mSkipInterval) 102 #else 103 if (mSkipCounter >= mSkipInterval) // otherwise no query ever issued if mSkipInterval = 0 ! 104 #endif // GTP_VISIBILITY_MODIFIED_OGRE 105 { 106 mSkipCounter = 0; 107 } 79 //if (mSkipCounter >= mSkipInterval) // otherwise no query ever issued if mSkipInterval = 0 ! 80 // mSkipCounter = 0; if (mSkipCounter != 0) return; 108 81 109 if (mSkipCounter == 0) 110 { 111 #ifdef GTP_VISIBILITY_USE_ARB_QUERIES 82 if (sUseArbQueries && mHasOcclusionSupportARB) 112 83 glBeginQueryARB_ptr(GL_SAMPLES_PASSED_ARB, mQueryID); 113 #else 84 else if (!sUseArbQueries && mHasOcclusionSupportNV) 114 85 glBeginOcclusionQueryNV_ptr(mQueryID); 115 #endif116 }117 }118 86 } 119 87 120 88 void GLHardwareOcclusionQuery::endOcclusionQuery() 121 89 { 122 // Make it fail silently if hardware occlusion isn't supported 123 if(mHasOcclusionSupport) 124 { 125 if( mSkipCounter == 0) 126 { 127 #ifdef GTP_VISIBILITY_USE_ARB_QUERIES 90 //if( mSkipCounter != 0) return; 91 if (sUseArbQueries && mHasOcclusionSupportARB) 128 92 glEndQueryARB_ptr(GL_SAMPLES_PASSED_ARB); 129 #else 93 else if (!sUseArbQueries && mHasOcclusionSupportNV) 130 94 glEndOcclusionQueryNV_ptr(); 131 #endif 95 // mSkipCounter++; 132 96 } 133 97 134 mSkipCounter++;135 }136 }137 138 //------------------------------------------------------------------139 // OpenGL dosn't use the flag paramter.140 //------------------------------------------------------------------141 98 bool GLHardwareOcclusionQuery::pullOcclusionQuery( unsigned int* NumOfFragments, const HW_OCCLUSIONQUERY flag ) 142 99 { 143 if( mHasOcclusionSupport ) // Make it fail silently if hardware occlusion isn't supported 144 { 145 #ifdef GTP_VISIBILITY_USE_ARB_QUERIES 100 if (sUseArbQueries && mHasOcclusionSupportARB) 146 101 glGetQueryObjectuivARB_ptr(mQueryID, GL_QUERY_RESULT_ARB, NumOfFragments); 147 #else 102 else if (!sUseArbQueries && mHasOcclusionSupportNV) 148 103 glGetOcclusionQueryuivNV_ptr(mQueryID, GL_PIXEL_COUNT_NV, NumOfFragments); 149 #endif150 }151 104 else 152 { 153 *NumOfFragments = 100000; // Fails quitlly -> every object tested is visable. 154 } 105 *NumOfFragments = 100000; // Fails quietly 155 106 156 107 mPixelCount = *NumOfFragments; … … 161 112 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 162 113 //------------------------------------------------------------------ 163 bool GLHardwareOcclusionQuery::pullOcclusionQuery( unsigned int * NumOfFragments, const bool waitForResult, const HW_OCCLUSIONQUERY flag) 114 bool GLHardwareOcclusionQuery::pullOcclusionQuery(unsigned int * NumOfFragments, 115 const bool waitForResult, 116 const HW_OCCLUSIONQUERY flag) 164 117 { 165 unsigned int isAvailable = GL_TRUE; 118 if (sUseArbQueries && mHasOcclusionSupportARB) 119 { 120 int isAvailable = GL_TRUE; 166 121 167 if (mHasOcclusionSupport)168 {169 122 if (!waitForResult) 123 glGetQueryivARB_ptr(mQueryID, GL_QUERY_RESULT_AVAILABLE_ARB, &isAvailable); 124 125 if (isAvailable == GL_TRUE) 126 glGetQueryObjectuivARB_ptr(mQueryID, GL_QUERY_RESULT_ARB, NumOfFragments); 127 128 mPixelCount = *NumOfFragments; 129 130 return isAvailable == GL_TRUE; 131 } 132 else if (!sUseArbQueries && mHasOcclusionSupportNV) 170 133 { 171 // use nv queries rather that arb because they are faster (no flush) 172 //glGetQueryivARB_ptr(mQueryID, GL_QUERY_RESULT_AVAILABLE_ARB, &isAvailable); 134 unsigned int isAvailable = GL_TRUE; 135 136 if (!waitForResult) 173 137 glGetOcclusionQueryuivNV_ptr(mQueryID, GL_PIXEL_COUNT_AVAILABLE_NV, &isAvailable); 174 }175 138 176 139 if (isAvailable == GL_TRUE) 177 {178 //glGetQueryObjectuivARB_ptr(mQueryID, GL_QUERY_RESULT_ARB, NumOfFragments);179 140 glGetOcclusionQueryuivNV_ptr(mQueryID, GL_PIXEL_COUNT_NV, NumOfFragments); 180 }181 }182 else183 {184 // In case hardware occlusion isn't supported, every object is set visible.185 *NumOfFragments = 100000;186 }187 141 188 142 mPixelCount = *NumOfFragments; 189 143 190 return isAvailable == GL_TRUE; 144 return isAvailable == GL_TRUE; 145 } 146 147 // In case hardware occlusion isn't supported, every object is set visible. 148 *NumOfFragments = 100000; 149 mPixelCount = *NumOfFragments; 150 151 return GL_TRUE; 191 152 } 192 153 -
trunk/VUT/work/ogre_changes/RenderSystems/GL/src/OgreGLRenderSystem.cpp
r316 r343 281 281 void GLRenderSystem::setConfigOption(const String &name, const String &value) 282 282 { 283 // set occlusion query 284 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 285 if ( name == "ArbQueries" ) 286 { 287 if ( value == "No" ) 288 { 289 GLHardwareOcclusionQuery::sUseArbQueries = false; 290 } 291 else if ( value == "Yes" ) 292 { 293 GLHardwareOcclusionQuery::sUseArbQueries = true; 294 } 295 return; 296 } 297 #endif 298 283 299 mGLSupport->setConfigOption(name, value); 284 300 }
Note: See TracChangeset
for help on using the changeset viewer.