Changeset 420 for branches/thune/thread_safe/gl/draw_list.c
- Timestamp:
- 06/30/07 08:14:01 (17 months ago)
- Files:
-
- 1 modified
-
branches/thune/thread_safe/gl/draw_list.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/thune/thread_safe/gl/draw_list.c
r409 r420 28 28 #include "shader.h" 29 29 #include "TexFont.h" 30 31 32 extern struct GXEnv gxEnv; 30 33 31 34 … … 66 69 void gr_disableTexture() 67 70 { 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 70 79 71 80 72 81 void gr_enableTexture0() 73 82 { 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 ); 75 90 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 } 84 92 85 93 … … 144 152 glDepthMask( GL_FALSE ); 145 153 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" ); 147 159 gr_disable( "adl" ); 148 160 /* … … 150 162 glDisable( GL_DEPTH_TEST ); 151 163 glDisable( GL_LIGHTING ); 152 153 164 glEnable( GL_BLEND ); 154 gr_enableTexture0();155 165 */ 156 166 glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); 157 158 167 159 168 //glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); … … 379 388 380 389 390 static 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 381 438 #if 0 382 439 GLuint gr_querySamples() … … 1075 1132 ++pc; 1076 1133 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 } 1078 1167 break; 1079 1168 … … 1311 1400 VAL_WORD_OR_PC 1312 1401 } 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 } 1313 1409 gr_drawTextCell( ut, val ); 1314 1410 break; … … 1344 1440 int hidden = ur_sel(pc); // UR_ATOM_HIDDEN 1345 1441 1346 ++pc;1347 if( ! ur_is(pc, UT_BLOCK) )1348 return 0;1349 1350 1442 _state.samplesQueryId = 0; 1351 1443 … … 1358 1450 } 1359 1451 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 1363 1466 1364 1467 if( _state.samplesQueryId ) … … 1376 1479 GLuint samples; 1377 1480 GLuint id; 1378 //UBinary* bin;1379 //UIndex binN;1380 1481 1381 1482 // Push query results on stack and call process-block. 1382 1383 //bin = ur_binaryPtr( binN );1384 1483 1385 1484 for( id = 1; id <= _state.samplesQueryId; ++id )
