Changeset 527 for trunk/thune/gl/draw_list.c
- Timestamp:
- 05/26/08 17:22:18 (6 months ago)
- Files:
-
- 1 modified
-
trunk/thune/gl/draw_list.c (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/thune/gl/draw_list.c
r516 r527 72 72 73 73 74 structGrRenderState grState;75 76 77 #if 074 GrRenderState grState; 75 76 77 #if 1 78 78 void gr_disableTexture() 79 79 { … … 132 132 case GRS_SOLID: 133 133 glDepthMask( GL_FALSE ); 134 #if 0 134 135 gr_disable( "lbct" ); 135 /* 136 #else 136 137 glDisable( GL_LIGHTING ); 137 138 glDisable( GL_BLEND ); 138 139 glDisable( GL_CULL_FACE ); 139 140 gr_disableTexture(); 140 */ 141 142 grState.enableMask &= 143 ~(EN_LIGHTING | EN_BLEND | EN_CULL_FACE | EN_TEXTURE_2D); 144 #endif 141 145 break; 142 146 … … 163 167 164 168 // NOTE: Must disable all texture units but GL_TEXTURE0 if not 165 // using a shader or text may not render properly.169 // using a shader or text may not render properly. 166 170 gr_enableTexture0(); 167 171 … … 235 239 236 240 237 int gr_textWidth( const TexFont* tf, const char* it, const char* end )238 {239 TexGlyphInfo* prev = 0;240 TexGlyphInfo* tgi;241 int width = 0;242 243 while( it != end )244 {245 if( *it == '\n' )246 break;247 if( *it == ' ' )248 {249 tgi = txf_glyph( tf, ' ' );250 if( tgi )251 width += tgi->advance;252 prev = 0;253 }254 else255 {256 tgi = txf_glyph( tf, *it );257 if( tgi )258 {259 width += tgi->advance;260 if( prev )261 width += txf_kerning( tf, prev, tgi );262 prev = tgi;263 }264 }265 ++it;266 }267 268 return width;269 }270 271 272 241 /* 273 242 Returns TexGlyphInfo of rendered glyph. … … 395 364 { 396 365 int16_t* rect = area->coord.elem; 397 int w = gr_textWidth( tf, cpA, cpB );366 int w = txf_width( tf, cpA, cpB ); 398 367 int h = tf->max_ascent - (tf->max_ascent >> 1); 399 368 … … 646 615 647 616 blk = ur_block(val); 648 UR_ITER_BLOCK( it, end, blk, val ) ;617 UR_ITER_BLOCK( it, end, blk, val ) 649 618 while( it != end ) 650 619 { … … 826 795 COW_VALUE(pc, ts); 827 796 if( ! ur_is(ts, UT_COORD) ) 797 { 798 bad_dt: 799 ur_throwErr( UR_ERR_DATATYPE, "qaud-skin expected coord!" ); 828 800 return 0; 801 } 829 802 ++pc; 830 803 COW_VALUE(pc, tc); 831 804 if( ! ur_is(tc, UT_COORD) ) 832 return 0;805 goto bad_dt; 833 806 ++pc; 834 807 COW_VALUE(pc, vc); 835 808 if( ! ur_is(vc, UT_COORD) ) 836 return 0;809 goto bad_dt; 837 810 838 811 { … … 1163 1136 glEnable( e ); } 1164 1137 1138 #if 1 1165 1139 #define DISABLE(f,e) \ 1166 1140 if( grState.enableMask & f ) { \ 1167 1141 grState.enableMask &= ~f; \ 1168 1142 glDisable( e ); } 1143 #else 1144 #define DISABLE(f,e) glDisable( e ); 1145 #endif 1146 1169 1147 1170 1148 static void gr_enable( const char* cp ) … … 1288 1266 Returns zero if an error occurred. 1289 1267 */ 1290 static int_runDrawList( UThread* ut, UCell* val )1268 int ug_runDrawList( UThread* ut, UCell* val ) 1291 1269 { 1292 1270 UBlock* blk = ur_blockPtr( val->series.n ); … … 1337 1315 glCallList( ur_dlGL(val) ); 1338 1316 } 1339 else if( ! _runDrawList( ut, val ) )1317 else if( ! ug_runDrawList( ut, val ) ) 1340 1318 return 0; 1319 } 1320 else if( ur_is(val, UT_WIDGET) ) 1321 { 1322 // NOTE: Compiliation of widget draw lists will happen 1323 // inside gui_render(). 1324 gui_render( &gxEnv.gui, ur_int(val) ); 1341 1325 } 1342 1326 break; … … 1654 1638 { 1655 1639 if( ! ur_is(val, UT_COORD) || (val->coord.len < 4) ) 1640 { 1641 ur_throwErr( UR_ERR_DATATYPE, 1642 "text expected area coord!" ); 1656 1643 return 0; 1644 } 1657 1645 area = val; 1658 1646 ++pc; … … 1689 1677 loadShader( ut, val ); 1690 1678 break; 1691 #if 01679 #if 1 1692 1680 case DOP_UNIFORM: 1693 1681 { … … 1737 1725 if( ur_is(pc, UT_BLOCK) ) 1738 1726 { 1739 if( ! _runDrawList( ut, pc ) )1727 if( ! ug_runDrawList( ut, pc ) ) 1740 1728 return 0; 1741 1729 } … … 1805 1793 1806 1794 1795 int ug_compileDrawList( UThread* ut, UCell* blkCell, GLuint dl ) 1796 { 1797 int ok; 1798 1799 //printf( "KR compile DL %d\n", dl ); 1800 1801 // Need to keep grState.shaderProg for uniform to work in compiled list. 1802 //gr_clearState(); 1803 1804 glNewList( dl, GL_COMPILE ); 1805 ok = ug_runDrawList( ut, blkCell ); 1806 glEndList(); 1807 1808 return ok; 1809 } 1810 1811 1807 1812 /* 1808 1813 (draw-list! block -- dlist) … … 1826 1831 ur_initType(res, UT_DRAWLIST); 1827 1832 ur_setSeries(res, tos->series.n, tos->series.it ); 1828 ur_dlGL(res) = 0;1833 ur_dlGL(res) = 0; 1829 1834 //ur_dlPool(res) = 0; // Cleared by ur_initType. 1830 1835 } … … 1841 1846 1842 1847 gr_clearState(); 1843 1844 //printf( "KR compile %d\n", ur_dlGL(tos) ); 1845 1846 glNewList( ur_dlGL(res), GL_COMPILE ); 1847 1848 if( ! _runDrawList( ut, tos ) ) 1849 { 1850 ur_throwErr( UR_ERR_SCRIPT, "runDrawList failed" ); 1851 } 1852 1853 glEndList(); 1848 if( ! ug_compileDrawList( ut, tos, ur_dlGL(res) ) ) 1849 return; 1854 1850 } 1855 1851 else … … 1871 1867 if( ur_is(tos, UT_DRAWLIST) ) 1872 1868 { 1869 if( ur_dlGL(tos) ) 1870 { 1871 glCallList( ur_dlGL(tos) ); 1872 } 1873 else 1874 { 1875 gr_clearState(); 1876 ug_runDrawList( ut, tos ); 1877 } 1878 } 1879 else if( ur_is(tos, UT_WIDGET) ) 1880 { 1873 1881 gr_clearState(); 1874 1875 if( ur_dlGL(tos) ) 1876 glCallList( ur_dlGL(tos) ); 1877 else 1878 _runDrawList( ut, tos ); 1882 gui_render( &gxEnv.gui, ur_int(tos) ); 1879 1883 } 1880 1884 UR_S_DROP;
