Show
Ignore:
Timestamp:
06/30/07 08:14:01 (17 months ago)
Author:
krobillard
Message:

Thune GL - Added 'image & mouse button words. Fixes to specular model shaders.

Files:
1 modified

Legend:

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

    r409 r420  
    2828#include "shader.h" 
    2929#include "TexFont.h" 
     30 
     31 
     32extern struct GXEnv gxEnv; 
    3033 
    3134 
     
    6669void gr_disableTexture() 
    6770{ 
    68     glDisable( GL_TEXTURE_2D ); 
    69 } 
     71    GLint i; 
     72    for( i = 0; i < gxEnv.maxTextureUnits; ++i ) 
     73    { 
     74        glActiveTexture( GL_TEXTURE0 + i ); 
     75        glDisable( GL_TEXTURE_2D ); 
     76    } 
     77} 
     78#endif 
    7079 
    7180 
    7281void gr_enableTexture0() 
    7382{ 
    74 #if 1 
     83    GLint i; 
     84    for( i = 1; i < gxEnv.maxTextureUnits; ++i ) 
     85    { 
     86        glActiveTexture( GL_TEXTURE0 + i ); 
     87        glDisable( GL_TEXTURE_2D ); 
     88    } 
     89    glActiveTexture( GL_TEXTURE0 ); 
    7590    glEnable( GL_TEXTURE_2D ); 
    76 #else 
    77     glActiveTexture( GL_TEXTURE0 + 0 ); 
    78     glEnable( GL_TEXTURE_2D ); 
    79     glActiveTexture( GL_TEXTURE0 + 1 ); 
    80     glEnable( GL_TEXTURE_2D ); 
    81 #endif 
    82 } 
    83 #endif 
     91} 
    8492 
    8593 
     
    144152            glDepthMask( GL_FALSE ); 
    145153 
    146             gr_enable( "bt" ); 
     154            // NOTE: Must disable all texture units but GL_TEXTURE0 if not 
     155            // using a shader or text may not render properly. 
     156            gr_enableTexture0(); 
     157 
     158            gr_enable( "b" ); 
    147159            gr_disable( "adl" ); 
    148160            /* 
     
    150162            glDisable( GL_DEPTH_TEST ); 
    151163            glDisable( GL_LIGHTING ); 
    152  
    153164            glEnable( GL_BLEND ); 
    154             gr_enableTexture0(); 
    155165            */ 
    156166            glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); 
    157  
    158167 
    159168            //glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); 
     
    379388 
    380389 
     390static void gr_image( UThread* ut, UCell* val, GLfloat x, GLfloat y, 
     391                      UAtom atom ) 
     392{ 
     393    RasterHead* rh; 
     394 
     395    if( atom == UR_ATOM_TRANS ) 
     396    { 
     397        //gr_disable( "adl" ); 
     398        //gr_enable( "b" ); 
     399 
     400        glDisable( GL_ALPHA_TEST ); 
     401        glDisable( GL_DEPTH_TEST ); 
     402        glDisable( GL_LIGHTING ); 
     403        glEnable( GL_BLEND ); 
     404 
     405        glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); 
     406    } 
     407    else 
     408    { 
     409        gr_disable( "abdl" ); 
     410    } 
     411 
     412    glDepthMask( GL_FALSE ); 
     413 
     414    gr_enableTexture0(); 
     415    glBindTexture( GL_TEXTURE_2D, ur_texId(val) ); 
     416    //printf( "KR tex %d\n", ur_texId(val) ); 
     417 
     418    rh = (RasterHead*) ur_binPtr( ur_texRast(val) )->ptr.v; 
     419 
     420    glBegin( GL_QUADS ); 
     421 
     422    glMultiTexCoord2f( GL_TEXTURE0, 0.0f, 1.0f ); 
     423    glVertex2f( x, y ); 
     424    glMultiTexCoord2f( GL_TEXTURE0, 1.0f, 1.0f ); 
     425    glVertex2f( x + rh->width, y ); 
     426    glMultiTexCoord2f( GL_TEXTURE0, 1.0f, 0.0f ); 
     427    glVertex2f( x + rh->width, y + rh->height ); 
     428    glMultiTexCoord2f( GL_TEXTURE0, 0.0f, 0.0f ); 
     429    glVertex2f( x, y + rh->height ); 
     430 
     431    glEnd(); 
     432} 
     433 
     434 
     435//---------------------------------------------------------------------------- 
     436 
     437 
    381438#if 0 
    382439GLuint gr_querySamples() 
     
    10751132                ++pc; 
    10761133                VAL_WORD_OR_PC 
    1077                 glBindTexture( GL_TEXTURE_2D, ur_texId(val) ); 
     1134                if( ur_is(val, UT_TEXTURE) ) 
     1135                { 
     1136                    glBindTexture( GL_TEXTURE_2D, ur_texId(val) ); 
     1137                } 
     1138                break; 
     1139 
     1140            case DOP_IMAGE:                 // image [x,y] texture 
     1141            { 
     1142                GLfloat x, y; 
     1143                int atom = ur_sel(pc); 
     1144                ++pc; 
     1145                VAL_WORD_OR_PC 
     1146                if( ur_is(val, UT_COORD) ) 
     1147                { 
     1148                    x = (GLfloat) val->coord.elem[0]; 
     1149                    y = (GLfloat) val->coord.elem[1]; 
     1150                    ++pc; 
     1151                    VAL_WORD_OR_PC 
     1152                } 
     1153                else if( ur_is(val, UT_VEC3) ) 
     1154                { 
     1155                    x = val->vec3.xyz[0]; 
     1156                    y = val->vec3.xyz[1]; 
     1157                    ++pc; 
     1158                    VAL_WORD_OR_PC 
     1159                } 
     1160                else 
     1161                { 
     1162                    x = y = 0.0; 
     1163                } 
     1164                if( ur_is(val, UT_TEXTURE) ) 
     1165                    gr_image( ut, val, x, y, atom ); 
     1166            } 
    10781167                break; 
    10791168 
     
    13111400                    VAL_WORD_OR_PC 
    13121401                } 
     1402                else if( ur_is(val, UT_VEC3) ) 
     1403                { 
     1404                    _state.penX = val->vec3.xyz[0]; 
     1405                    _state.penY = val->vec3.xyz[1]; 
     1406                    ++pc; 
     1407                    VAL_WORD_OR_PC 
     1408                } 
    13131409                gr_drawTextCell( ut, val ); 
    13141410                break; 
     
    13441440                int hidden = ur_sel(pc);    // UR_ATOM_HIDDEN 
    13451441 
    1346                 ++pc; 
    1347                 if( ! ur_is(pc, UT_BLOCK) ) 
    1348                     return 0; 
    1349  
    13501442                _state.samplesQueryId = 0; 
    13511443 
     
    13581450                } 
    13591451 
    1360                 // Run draw-list containing samples-begin ops. 
    1361                 if( ! _runDrawList( ut, pc ) ) 
    1362                     return 0; 
     1452                // Run draw-list containing samples-begin (DOP_SAMPLES_BEGIN). 
     1453                ++pc; 
     1454                if( ur_is(pc, UT_BLOCK) ) 
     1455                { 
     1456                    if( ! _runDrawList( ut, pc ) ) 
     1457                        return 0; 
     1458                } 
     1459#if 1 
     1460                else if( ur_is(pc, UT_DRAWLIST) ) 
     1461                { 
     1462                    if( ur_dlGL(pc) ) 
     1463                        glCallList( ur_dlGL(pc) ); 
     1464                } 
     1465#endif 
    13631466 
    13641467                if( _state.samplesQueryId ) 
     
    13761479                    GLuint samples; 
    13771480                    GLuint id; 
    1378                     //UBinary* bin; 
    1379                     //UIndex binN; 
    13801481 
    13811482                    // Push query results on stack and call process-block. 
    1382  
    1383                     //bin = ur_binaryPtr( binN ); 
    13841483 
    13851484                    for( id = 1; id <= _state.samplesQueryId; ++id )