Show
Ignore:
Timestamp:
06/02/07 06:45:33 (18 months ago)
Author:
krobillard
Message:

Thune GL - Added samples-query.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/thune/thread_safe/gl/draw_list.c

    r403 r405  
    7575    _state.attr[0].vals = 0; 
    7676    _state.attr[1].vals = 0; 
     77    _state.samplesQueryId = 0; 
    7778} 
    7879 
     
    132133            { 
    133134                glDepthMask( GL_FALSE ); 
     135 
     136            //glEnable( GL_DEPTH_TEST ); 
    134137 
    135138                glDisable( GL_ALPHA_TEST ); 
     
    345348    } 
    346349} 
     350 
     351 
     352//---------------------------------------------------------------------------- 
     353 
     354 
     355#if 0 
     356GLuint gr_querySamples() 
     357{ 
     358    GLuint sampleCount; 
     359    //const GLuint id = 1; 
     360    int id; 
     361    int endId = 1 + 1; 
     362 
     363#if 0 
     364    // 32 bits on GeForce 6600 GT 
     365    GLint bits; 
     366    glGetQueryiv( GL_SAMPLES_PASSED, GL_QUERY_COUNTER_BITS, &bits ); 
     367    printf( "KR GL_QUERY_COUNTER_BITS = %d\n", bits ); 
     368#endif 
     369 
     370    glColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE ); 
     371    glDepthMask( GL_FALSE ); 
     372 
     373    for( id = 1; id < endId; ++id ) 
     374    { 
     375        glBeginQuery( GL_SAMPLES_PASSED, id ); 
     376 
     377        // Draw... 
     378 
     379        glEndQuery( GL_SAMPLES_PASSED ); 
     380    } 
     381 
     382    //glFlush(); 
     383 
     384    glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE ); 
     385    glDepthMask( GL_TRUE ); 
     386 
     387    for( id = 1; id < endId; ++id ) 
     388    { 
     389        glGetQueryObjectuiv( id, GL_QUERY_RESULT, &sampleCount ); 
     390        //printf( "KR GL_QUERY_RESULT = %d\n", sampleCount ); 
     391    } 
     392 
     393    return sampleCount; 
     394} 
     395#endif 
    347396 
    348397 
     
    792841        { 
    793842            case DOP_NOP: 
     843                //printf( "KR DL NOP\n" ); 
    794844                break; 
    795845 
     
    858908                    case UR_ATOM_SPRITE: 
    859909                        gr_setState( GRS_PARTICLE ); 
    860                         glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); 
     910                        //glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); 
     911                        //glBlendFunc( GL_ONE, GL_ONE_MINUS_SRC_ALPHA ); 
     912                        glBlendFunc( GL_SRC_ALPHA, GL_ONE ); 
    861913                        glEnable( GL_POINT_SPRITE ); 
    862914                        break; 
     
    10851137                break; 
    10861138 
     1139            case DOP_SAMPLES_QUERY:     // dlist-block process-block 
     1140                ++pc; 
     1141                if( ! ur_is(pc, UT_BLOCK) ) 
     1142                    return 0; 
     1143 
     1144                _state.samplesQueryId = 0; 
     1145 
     1146                glEnable( GL_CULL_FACE ); 
     1147                glColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE ); 
     1148                glDepthMask( GL_FALSE ); 
     1149 
     1150                // Run draw-list containing samples-begin ops. 
     1151                if( ! _runDrawList( ut, pc ) ) 
     1152                    return 0; 
     1153 
     1154                if( _state.samplesQueryId ) 
     1155                    glEndQuery( GL_SAMPLES_PASSED ); 
     1156 
     1157                glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE ); 
     1158                glDepthMask( GL_TRUE ); 
     1159 
     1160                ++pc; 
     1161                if( ur_is(pc, UT_BLOCK) ) 
     1162                { 
     1163                    GLuint samples; 
     1164                    GLuint id; 
     1165                    //UBinary* bin; 
     1166                    //UIndex binN; 
     1167 
     1168                    // Push query results on stack and call process-block. 
     1169 
     1170                    //bin = ur_binaryPtr( binN ); 
     1171 
     1172                    for( id = 1; id <= _state.samplesQueryId; ++id ) 
     1173                    { 
     1174                        glGetQueryObjectuiv( id, GL_QUERY_RESULT, &samples ); 
     1175                        //printf( "KR samples %d %d\n", id, samples ); 
     1176 
     1177                        UR_S_GROW; 
     1178                        ur_initType( UR_TOS, UT_INT ); 
     1179                        ur_int(UR_TOS) = samples; 
     1180                    } 
     1181 
     1182                    if( ur_eval( ut, pc->series.n, pc->series.it ) 
     1183                        != UR_EVAL_OK ) 
     1184                        return 0; 
     1185                } 
     1186 
     1187                _state.samplesQueryId = 0; 
     1188                break; 
     1189 
     1190            case DOP_SAMPLES_BEGIN: 
     1191                if( _state.samplesQueryId ) 
     1192                    glEndQuery( GL_SAMPLES_PASSED ); 
     1193 
     1194                ++_state.samplesQueryId; 
     1195                glBeginQuery( GL_SAMPLES_PASSED, _state.samplesQueryId ); 
     1196                break; 
     1197 
    10871198            default: 
    10881199                assert( 0 && "Invalid Draw List Opcode" );