Ignore:
Timestamp:
05/30/05 03:20:23 (19 years ago)
Author:
mattausch
Message:

added depth pass algorithm + delayed transparent object rendering (so depth ordering is right)

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

    r99 r115  
    2727#include "OgreException.h" 
    2828 
     29 
    2930namespace Ogre { 
    30  
    31 int GLHardwareOcclusionQuery::m_Skip = 0; 
    3231 
    3332/** 
     
    3635  * 
    3736  * @author Lee Sandberg email: lee@abcmedia.se 
     37  * 
     38  * Updated on 12/7/2004 by Chris McGuirk 
     39  * - Implemented ARB_occlusion_query 
    3840  */ 
    3941 
    40 /* Functions used; 
    41  
    42 glGenOcclusionQueriesNV_ptr( 1, m_uintQuery ); 
    43 glDeleteOcclusionQueriesNV_ptr( 1, &m_uintQuery[0] ); 
    44 glBeginOcclusionQueryNV_ptr( m_uintQuery[0] ); 
    45 glEndOcclusionQueryNV_ptr(); 
    46 glGetOcclusionQueryuivNV_ptr( m_uintQuery[0], GL_PIXEL_COUNT_NV, NumOfFragments ); 
    47  
    48   TO DO: change this to the new ARB functions... 
    49  
    50 */ 
    51  
    52 #ifndef GTP_VISIBILITY_MODIFIED_OGRE 
    5342/** 
    5443  * Default object constructor 
     
    5746GLHardwareOcclusionQuery::GLHardwareOcclusionQuery()  
    5847{  
    59         m_uintPixelCount = 0;  
    60         m_SkipCounter = 0; 
     48        mPixelCount = 0;  
     49        mSkipCounter = 0; 
     50        mSkipInterval = 0; 
    6151 
    6252        // Check for hardware occlusion support 
    63     if( glDeleteOcclusionQueriesNV_ptr != 0 )   // This is a hack to see if hw occlusion is supported. pointer is 0 if it's not supported. 
     53        // This is a hack to see if hw occlusion is supported. pointer is 0 if it's not supported. 
     54        //if (glGenQueriesARB_ptr != 0) 
     55        if (glGenOcclusionQueriesNV_ptr != 0) 
    6456    { 
    65                 m_bHWOcclusionSupport = true; 
     57                mHasOcclusionSupport = true; 
    6658        } 
    6759        else 
    6860        { 
    69                 m_bHWOcclusionSupport = false; 
     61                mHasOcclusionSupport = false; 
    7062        } 
    7163 
    72         if( m_bHWOcclusionSupport ) 
     64        if(mHasOcclusionSupport) 
    7365        { 
    74                 glGenOcclusionQueriesNV_ptr( 1, m_uintQuery );   
     66                //glGenQueriesARB_ptr(1, &mQueryID );    
     67                glGenOcclusionQueriesNV_ptr(1, &mQueryID); 
    7568        } 
    7669} 
    77  
    7870 
    7971/** 
     
    8274GLHardwareOcclusionQuery::~GLHardwareOcclusionQuery()  
    8375{  
    84         if( m_bHWOcclusionSupport ) 
     76        if( mHasOcclusionSupport ) 
    8577        { 
    86                 glDeleteOcclusionQueriesNV_ptr( 1, &m_uintQuery[0] );   
     78                //glDeleteQueriesARB_ptr(1, &mQueryID);   
     79                glDeleteOcclusionQueriesNV_ptr(1, &mQueryID);   
    8780        }        
    8881} 
     
    9386void GLHardwareOcclusionQuery::beginOcclusionQuery()  
    9487{  
    95         if( m_bHWOcclusionSupport )     // Make it fail silently if hardware occlusion isn't supported 
     88        // Make it fail silently if hardware occlusion isn't supported 
     89        if(mHasOcclusionSupport) 
    9690        { 
    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 
     91                // Counter starts at 0 again at mSkipInterval  
     92#ifndef GTP_VISIBILITY_MODIFIED_OGRE 
     93                if(mSkipCounter == mSkipInterval)  
     94#else 
     95                if (mSkipCounter >= mSkipInterval)  // otherwise no query ever issued if mSkipInterval = 0 ! 
     96#endif // GTP_VISIBILITY_MODIFIED_OGRE 
     97        { 
     98                        mSkipCounter = 0;  
     99                } 
     100 
     101                if (mSkipCounter == 0) 
    99102                { 
    100                         glBeginOcclusionQueryNV_ptr( m_uintQuery[0] ); 
     103                        //glBeginQueryARB_ptr(GL_SAMPLES_PASSED_ARB, mQueryID); 
     104                        glBeginOcclusionQueryNV_ptr(mQueryID); 
    101105                } 
    102106        } 
     
    105109void GLHardwareOcclusionQuery::endOcclusionQuery()  
    106110{  
    107         if( m_bHWOcclusionSupport )     // Make it fail silently if hardware occlusion isn't supported 
     111        // Make it fail silently if hardware occlusion isn't supported 
     112        if(mHasOcclusionSupport) 
    108113        { 
    109                 if( m_SkipCounter == 0 && m_uintPixelCount != 0 ) // New or none visable objects must allways be tested but visable objects can be skiped 
     114                if( mSkipCounter == 0) 
    110115                { 
     116                        //glEndQueryARB_ptr(GL_SAMPLES_PASSED_ARB); 
    111117                        glEndOcclusionQueryNV_ptr(); 
    112118                } 
    113                 m_SkipCounter++; 
    114         } 
    115 } 
    116119 
    117 bool 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 ); 
     120                mSkipCounter++; 
    122121        }  
    123         else 
    124         { 
    125                 *NumOfFragments = 100000;               // Fails quitlly -> every object tested is visable. 
    126         } 
    127  
    128         m_uintPixelCount = *NumOfFragments;  
    129  
    130         return true; 
    131122} 
    132123 
    133124//------------------------------------------------------------------ 
    134 // OpenGL dosn't use the flag, but to fulfil the abstract interface we need to include this function. 
    135 // Using this function in OpenGL mode simple works the same way as calling the other function without the flag parameter, 
    136 // but in DX9 it works differentlly, see notes in the DX9 implementation. 
    137 //-- 
     125// OpenGL dosn't use the flag paramter. 
     126//------------------------------------------------------------------ 
    138127bool GLHardwareOcclusionQuery::pullOcclusionQuery( unsigned int* NumOfFragments, const HW_OCCLUSIONQUERY flag  )  
    139128{ 
    140         if( m_bHWOcclusionSupport )     // Make it fail silently if hardware occlusion isn't supported 
     129        if( mHasOcclusionSupport )      // Make it fail silently if hardware occlusion isn't supported 
    141130        { 
    142                 glGetOcclusionQueryuivNV_ptr( m_uintQuery[0], GL_PIXEL_COUNT_NV, NumOfFragments ); 
     131                //glGetQueryObjectuivARB_ptr(mQueryID, GL_QUERY_RESULT_ARB, NumOfFragments); 
     132glGetOcclusionQueryuivNV_ptr(mQueryID, GL_PIXEL_COUNT_NV, NumOfFragments); 
    143133        } 
    144134        else 
     
    147137        } 
    148138 
    149         m_uintPixelCount = *NumOfFragments;  
     139        mPixelCount = *NumOfFragments;  
    150140         
    151141        return true; 
    152142} 
    153143 
    154 #else // GTP_VISIBILITY_MODIFIED_OGRE 
    155  
    156 //------------------------------------------------------------------ 
    157 GLHardwareOcclusionQuery::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 //------------------------------------------------------------------ 
    182 GLHardwareOcclusionQuery::~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 //------------------------------------------------------------------ 
    192 void 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          
    202 void 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 //------------------------------------------------------------------ 
    211 bool GLHardwareOcclusionQuery::pullOcclusionQuery( unsigned int * NumOfFragments, const bool waitForResult)  
     144#ifdef GTP_VISIBILITY_MODIFIED_OGRE 
     145        //------------------------------------------------------------------ 
     146        bool GLHardwareOcclusionQuery::pullOcclusionQuery( unsigned int * NumOfFragments, const bool waitForResult, const HW_OCCLUSIONQUERY flag)  
    212147{ 
    213148        unsigned int isAvailable = GL_TRUE; 
    214         //int isAvailable = GL_TRUE; 
    215149 
    216         if( m_bHWOcclusionSupport )      
     150                if (mHasOcclusionSupport)        
    217151        { 
    218152                if (!waitForResult) 
    219153                { 
    220                         glGetOcclusionQueryuivNV_ptr( m_uintQuery[0], GL_PIXEL_COUNT_AVAILABLE_NV, &isAvailable ); 
    221                         //glGetQueryivARB_ptr(m_uintQuery[0], GL_QUERY_RESULT_AVAILABLE_ARB, &isAvailable); 
     154                        // use nv queries rather that arb because they are faster (no flush) 
     155                                //glGetQueryivARB_ptr(mQueryID, GL_QUERY_RESULT_AVAILABLE_ARB, &isAvailable); 
     156                                glGetOcclusionQueryuivNV_ptr(mQueryID, GL_PIXEL_COUNT_AVAILABLE_NV, &isAvailable); 
    222157                } 
    223158 
    224159                if (isAvailable == GL_TRUE) 
    225160                { 
    226                         glGetOcclusionQueryuivNV_ptr( m_uintQuery[0], GL_PIXEL_COUNT_NV, NumOfFragments ); 
    227                         //glGetQueryObjectuivARB_ptr( m_uintQuery[0], GL_QUERY_RESULT_ARB, NumOfFragments); 
     161                                //glGetQueryObjectuivARB_ptr(mQueryID, GL_QUERY_RESULT_ARB, NumOfFragments); 
     162                                glGetOcclusionQueryuivNV_ptr(mQueryID, GL_PIXEL_COUNT_NV, NumOfFragments); 
    228163                } 
    229164        }  
     
    234169        } 
    235170 
    236         m_uintPixelCount = *NumOfFragments;  
     171                mPixelCount = *NumOfFragments;  
    237172 
    238173        return isAvailable == GL_TRUE;   
    239174} 
    240175 
    241 //------------------------------------------------------------------ 
    242 bool GLHardwareOcclusionQuery::pullOcclusionQuery( unsigned int* NumOfFragments, const bool waitForResult, const HW_OCCLUSIONQUERY flag  )  
    243 { 
    244         return pullOcclusionQuery(NumOfFragments, waitForResult); 
     176#endif // GTP_VIBILITY_MODIFIED_OGRE 
    245177} 
    246  
    247 #endif // GTP_VISIBILITY_MODIFIED_OGRE 
    248  
    249  
    250 } 
    251  
    252  
  • trunk/VUT/work/ogre_changes/RenderSystems/GL/src/OgreGLRenderSystem.cpp

    r97 r115  
    5858GL_ClientActiveTextureARB_Func glClientActiveTextureARB_ptr; 
    5959GL_SecondaryColorPointerEXT_Func glSecondaryColorPointerEXT_ptr; 
     60GL_SecondaryColor3fEXT_Func glSecondaryColor3fEXT_ptr; 
    6061GL_GenBuffersARB_Func glGenBuffersARB_ptr; 
    6162GL_BindBufferARB_Func glBindBufferARB_ptr; 
     
    9798GL_EndOcclusionQueryNV_Func glEndOcclusionQueryNV_ptr; 
    9899GL_GetOcclusionQueryuivNV_Func glGetOcclusionQueryuivNV_ptr; 
    99   
    100 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 
    101100GL_GenQueriesARB_Func glGenQueriesARB_ptr; 
    102101GL_DeleteQueriesARB_Func glDeleteQueriesARB_ptr; 
    103 GL_IsQueryARB_Func glIsQueryARB_ptr; 
    104102GL_BeginQueryARB_Func glBeginQueryARB_ptr; 
    105103GL_EndQueryARB_Func glEndQueryARB_ptr; 
     104#ifdef GTP_VISIBILITY_MODIFIED_OGRE 
    106105GL_GetQueryivARB_Func glGetQueryivARB_ptr; 
    107106GL_GetQueryObjectivARB_Func glGetQueryObjectivARB_ptr; 
     107#endif // GTP_VISIBILITY_MODIFIED_OGRE 
    108108GL_GetQueryObjectuivARB_Func glGetQueryObjectuivARB_ptr; 
    109 #endif // GTP_VISIBILITY_MODIFIED_OGRE 
    110109 
    111110namespace Ogre { 
     
    191190        glClientActiveTextureARB_ptr = 0; 
    192191        glSecondaryColorPointerEXT_ptr = 0; 
     192        glSecondaryColor3fEXT_ptr = 0; 
    193193        glGenBuffersARB_ptr = 0; 
    194194        glBindBufferARB_ptr = 0; 
     
    220220        glEndOcclusionQueryNV_ptr = 0; 
    221221        glGetOcclusionQueryuivNV_ptr = 0; 
    222  
    223 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 
    224222                glGenQueriesARB_ptr = 0; 
    225223                glDeleteQueriesARB_ptr = 0; 
    226                 glIsQueryARB_ptr = 0; 
    227224                glBeginQueryARB_ptr = 0; 
    228225                glEndQueryARB_ptr = 0; 
     226#ifdef GTP_VISIBILITY_MODIFIED_OGRE 
    229227                glGetQueryivARB_ptr = 0; 
    230228                glGetQueryObjectivARB_ptr = 0; 
     229#endif // GTP_VISIBILITY_MODIFIED_OGRE 
    231230                glGetQueryObjectuivARB_ptr = 0; 
    232 #endif // GTP_VISIBILITY_MODIFIED_OGRE 
    233231 
    234232        mCurrentLights = 0; 
     
    543541        glSecondaryColorPointerEXT_ptr =  
    544542            (GL_SecondaryColorPointerEXT_Func)mGLSupport->getProcAddress("glSecondaryColorPointerEXT"); 
     543        glSecondaryColor3fEXT_ptr =  
     544            (GL_SecondaryColor3fEXT_Func)mGLSupport->getProcAddress("glSecondaryColor3fEXT"); 
    545545        glGenBuffersARB_ptr =  
    546546            (GL_GenBuffersARB_Func)mGLSupport->getProcAddress("glGenBuffersARB"); 
     
    622622        glGetOcclusionQueryuivNV_ptr = 
    623623            (GL_GetOcclusionQueryuivNV_Func)mGLSupport->getProcAddress("glGetOcclusionQueryuivNV"); 
    624                 glGetQueryObjectivARB_ptr =  
    625                          (GL_GetQueryObjectivARB_Func)mGLSupport->getProcAddress("glGetQueryObjectivARB"); 
    626                 glGetQueryObjectuivARB_ptr =  
    627                          (GL_GetQueryObjectuivARB_Func)mGLSupport->getProcAddress("glGetQueryObjectuivARB"); 
    628 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 
     624 
    629625                glGenQueriesARB_ptr =  
    630626                         (GL_GenQueriesARB_Func)mGLSupport->getProcAddress("glGenQueriesARB"); 
    631627                glDeleteQueriesARB_ptr = 
    632628                        (GL_DeleteQueriesARB_Func)mGLSupport->getProcAddress("glDeleteQueriesARB"); 
    633                 glIsQueryARB_ptr = 
    634                         (GL_IsQueryARB_Func)mGLSupport->getProcAddress("glIsQueryARB"); 
    635629                glBeginQueryARB_ptr = 
    636630                         (GL_BeginQueryARB_Func)mGLSupport->getProcAddress("glBeginQueryARB"); 
    637631                glEndQueryARB_ptr = 
    638632                         (GL_EndQueryARB_Func)mGLSupport->getProcAddress("glEndQueryARB"); 
     633        #ifdef GTP_VISIBILITY_MODIFIED_OGRE 
    639634                glGetQueryivARB_ptr =  
    640635                        (GL_GetQueryivARB_Func)mGLSupport->getProcAddress("glGetQueryivARB"); 
    641636                glGetQueryObjectivARB_ptr =  
    642637                         (GL_GetQueryObjectivARB_Func)mGLSupport->getProcAddress("glGetQueryObjectivARB"); 
     638        #endif // GTP_VISIBILITY_MODIFIED_OGRE 
    643639                glGetQueryObjectuivARB_ptr =  
    644640                         (GL_GetQueryObjectuivARB_Func)mGLSupport->getProcAddress("glGetQueryObjectuivARB"); 
    645 #endif // GTP_VISIBILITY_MODIFIED_OGRE 
    646641 
    647642        mCapabilities->log(LogManager::getSingleton().getDefaultLog()); 
     
    18571852                    cv1[2] = bm.colourArg1.b; 
    18581853                    cv1[3] = bm.colourArg1.a; 
     1854                        mManualBlendColours[stage][0] = bm.colourArg1; 
     1855 
    18591856 
    18601857                    cv2[0] = bm.colourArg2.r; 
     
    18621859                    cv2[2] = bm.colourArg2.b; 
    18631860                    cv2[3] = bm.colourArg2.a; 
     1861                        mManualBlendColours[stage][1] = bm.colourArg2; 
    18641862        } 
    18651863 
    18661864                if (bm.blendType == LBT_ALPHA) 
    18671865        { 
    1868                     cv1[0] = 0; 
    1869                     cv1[1] = 0; 
    1870                     cv1[2] = 0; 
     1866                    cv1[0] = mManualBlendColours[stage][0].r; 
     1867                    cv1[1] = mManualBlendColours[stage][0].g; 
     1868                    cv1[2] = mManualBlendColours[stage][0].b; 
    18711869                    cv1[3] = bm.alphaArg1; 
    18721870 
    1873                     cv2[0] = 0; 
    1874                     cv2[1] = 0; 
    1875                     cv2[2] = 0; 
     1871                    cv2[0] = mManualBlendColours[stage][1].r; 
     1872                    cv2[1] = mManualBlendColours[stage][1].g; 
     1873                    cv2[2] = mManualBlendColours[stage][1].b; 
    18761874                    cv2[3] = bm.alphaArg2; 
    18771875        } 
     
    22492247        } 
    22502248        glColor4f(1,1,1,1); 
     2249        glSecondaryColor3fEXT_ptr(0.0f, 0.0f, 0.0f); 
    22512250 
    22522251        // UnGuard 
     
    25372536        glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR); 
    25382537        glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1);         
     2538        glEnable(GL_COLOR_SUM); 
     2539 
    25392540        // Check for FSAA 
    25402541        // Enable the extension if it was enabled by the GLSupport 
Note: See TracChangeset for help on using the changeset viewer.