Ignore:
Timestamp:
05/13/05 15:14:12 (19 years ago)
Author:
mattausch
Message:

ogre: changed from occlusion_query_nv to occlusion_query_arb (in ogre_changes)

Location:
trunk/VUT/work/ogre_changes/RenderSystems/GL/src
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/work/ogre_changes/RenderSystems/GL/src/OgreGLHardwareOcclusionQuery.cpp

    r88 r97  
    5050*/ 
    5151 
    52  
     52#ifndef GTP_VISIBILITY_MODIFIED_OGRE 
    5353/** 
    5454  * Default object constructor 
     
    9595        if( m_bHWOcclusionSupport )     // Make it fail silently if hardware occlusion isn't supported 
    9696        { 
    97                 glBeginOcclusionQueryNV_ptr( m_uintQuery[0] ); 
     97                if  ( m_SkipCounter ==  m_Skip ) { m_SkipCounter = 0; };                // Counter starts at 0 again at m_Skip  
     98                if ( m_SkipCounter == 0 && m_uintPixelCount != 0 ) // New or none visable objects must allways be tested but visable objects can be skiped 
     99                { 
     100                        glBeginOcclusionQueryNV_ptr( m_uintQuery[0] ); 
     101                } 
    98102        } 
    99103} 
     
    103107        if( m_bHWOcclusionSupport )     // Make it fail silently if hardware occlusion isn't supported 
    104108        { 
    105                 glEndOcclusionQueryNV_ptr(); 
    106         } 
    107 } 
    108  
    109 bool GLHardwareOcclusionQuery::pullOcclusionQuery( unsigned int * NumOfFragments, const bool waitForResult)  
    110 { 
    111         unsigned int isAvailable = GL_TRUE; 
    112  
    113         if( m_bHWOcclusionSupport )      
    114         { 
    115                 if(!waitForResult) 
    116                 { 
    117                         glGetOcclusionQueryuivNV_ptr( m_uintQuery[0], GL_PIXEL_COUNT_AVAILABLE_NV, &isAvailable ); 
    118                 } 
    119  
    120                 if(isAvailable == GL_TRUE) 
    121                 { 
    122                         glGetOcclusionQueryuivNV_ptr( m_uintQuery[0], GL_PIXEL_COUNT_NV, NumOfFragments ); 
    123                 } 
     109                if( m_SkipCounter == 0 && m_uintPixelCount != 0 ) // New or none visable objects must allways be tested but visable objects can be skiped 
     110                { 
     111                        glEndOcclusionQueryNV_ptr(); 
     112                } 
     113                m_SkipCounter++; 
     114        } 
     115} 
     116 
     117bool GLHardwareOcclusionQuery::pullOcclusionQuery( unsigned int * NumOfFragments)  
     118{ 
     119        if( m_bHWOcclusionSupport )     // Make it fail silently if hardware occlusion isn't supported 
     120        { 
     121                glGetOcclusionQueryuivNV_ptr( m_uintQuery[0], GL_PIXEL_COUNT_NV, NumOfFragments ); 
    124122        }  
    125123        else 
    126124        { 
    127                 // In case hardware occlusion isn't supported, every object is set visible. 
    128                 *NumOfFragments = 100000;                
     125                *NumOfFragments = 100000;               // Fails quitlly -> every object tested is visable. 
    129126        } 
    130127 
    131128        m_uintPixelCount = *NumOfFragments;  
    132129 
    133         return isAvailable == GL_TRUE;   
    134 } 
    135  
    136 //------------------------------------------------------------------ 
    137 // OpenGL doesn't use the flag, but to implement the abstract interface we need to include this function. 
     130        return true; 
     131} 
     132 
     133//------------------------------------------------------------------ 
     134// OpenGL dosn't use the flag, but to fulfil the abstract interface we need to include this function. 
    138135// Using this function in OpenGL mode simple works the same way as calling the other function without the flag parameter, 
    139136// but in DX9 it works differentlly, see notes in the DX9 implementation. 
    140137//-- 
     138bool GLHardwareOcclusionQuery::pullOcclusionQuery( unsigned int* NumOfFragments, const HW_OCCLUSIONQUERY flag  )  
     139{ 
     140        if( m_bHWOcclusionSupport )     // Make it fail silently if hardware occlusion isn't supported 
     141        { 
     142                glGetOcclusionQueryuivNV_ptr( m_uintQuery[0], GL_PIXEL_COUNT_NV, NumOfFragments ); 
     143        } 
     144        else 
     145        { 
     146                *NumOfFragments = 100000;               // Fails quitlly -> every object tested is visable. 
     147        } 
     148 
     149        m_uintPixelCount = *NumOfFragments;  
     150         
     151        return true; 
     152} 
     153 
     154#else // GTP_VISIBILITY_MODIFIED_OGRE 
     155 
     156//------------------------------------------------------------------ 
     157GLHardwareOcclusionQuery::GLHardwareOcclusionQuery()  
     158{  
     159        m_uintPixelCount = 0;  
     160        m_SkipCounter = 0; 
     161 
     162        // Check for hardware occlusion support 
     163    // if( glDeleteOcclusionQueriesNV_ptr != 0 )        // This is a hack to see if hw occlusion is supported. pointer is 0 if it's not supported. 
     164        if( glDeleteQueriesARB_ptr != 0 ) 
     165        { 
     166                m_bHWOcclusionSupport = true; 
     167        } 
     168        else 
     169        { 
     170                m_bHWOcclusionSupport = false; 
     171        } 
     172 
     173        if( m_bHWOcclusionSupport ) 
     174        { 
     175                //glGenOcclusionQueriesNV_ptr( 1, m_uintQuery );         
     176                glGenQueriesARB_ptr(1, m_uintQuery); 
     177        } 
     178} 
     179 
     180 
     181//------------------------------------------------------------------ 
     182GLHardwareOcclusionQuery::~GLHardwareOcclusionQuery()  
     183{  
     184        if( m_bHWOcclusionSupport ) 
     185        { 
     186                //glDeleteOcclusionQueriesNV_ptr( 1, &m_uintQuery[0] );   
     187                glDeleteQueriesARB_ptr(1, &m_uintQuery[0]); 
     188        }        
     189} 
     190 
     191//------------------------------------------------------------------ 
     192void GLHardwareOcclusionQuery::beginOcclusionQuery()  
     193{  
     194        if( m_bHWOcclusionSupport )     // Make it fail silently if hardware occlusion isn't supported 
     195        { 
     196                // do the actual occlusion query for this node 
     197                //glBeginOcclusionQueryNV_ptr( m_uintQuery[0] ); 
     198                glBeginQueryARB_ptr(GL_SAMPLES_PASSED_ARB, m_uintQuery[0]); 
     199        } 
     200} 
     201         
     202void GLHardwareOcclusionQuery::endOcclusionQuery()  
     203{  
     204        if( m_bHWOcclusionSupport )     // Make it fail silently if hardware occlusion isn't supported 
     205        { 
     206                //glEndOcclusionQueryNV_ptr(); 
     207                glEndQueryARB_ptr(GL_SAMPLES_PASSED_ARB); 
     208        } 
     209} 
     210//------------------------------------------------------------------ 
     211bool GLHardwareOcclusionQuery::pullOcclusionQuery( unsigned int * NumOfFragments, const bool waitForResult)  
     212{ 
     213        //unsigned int isAvailable = GL_TRUE; 
     214        int isAvailable = GL_TRUE; 
     215 
     216        if( m_bHWOcclusionSupport )      
     217        { 
     218                if(!waitForResult) 
     219                { 
     220                        //glGetOcclusionQueryuivNV_ptr( m_uintQuery[0], GL_PIXEL_COUNT_AVAILABLE_NV, &isAvailable ); 
     221                        glGetQueryivARB_ptr(m_uintQuery[0], GL_QUERY_RESULT_AVAILABLE_ARB, &isAvailable); 
     222                } 
     223 
     224                if(isAvailable == GL_TRUE) 
     225                { 
     226                        glGetQueryObjectuivARB_ptr( m_uintQuery[0], GL_QUERY_RESULT_ARB, NumOfFragments); 
     227                        //glGetOcclusionQueryuivNV_ptr( m_uintQuery[0], GL_PIXEL_COUNT_NV, NumOfFragments ); 
     228                } 
     229        }  
     230        else 
     231        { 
     232                // In case hardware occlusion isn't supported, every object is set visible. 
     233                *NumOfFragments = 100000;                
     234        } 
     235 
     236        m_uintPixelCount = *NumOfFragments;  
     237 
     238        return isAvailable == GL_TRUE;   
     239} 
     240 
     241//------------------------------------------------------------------ 
    141242bool GLHardwareOcclusionQuery::pullOcclusionQuery( unsigned int* NumOfFragments, const bool waitForResult, const HW_OCCLUSIONQUERY flag  )  
    142243{ 
     
    144245} 
    145246 
    146 } 
    147  
    148  
     247#endif // GTP_VISIBILITY_MODIFIED_OGRE 
     248 
     249 
     250} 
     251 
     252 
Note: See TracChangeset for help on using the changeset viewer.