Changeset 527
- Timestamp:
- 05/26/08 17:22:18 (5 months ago)
- Location:
- trunk/thune
- Files:
-
- 6 added
- 28 modified
-
CMakeLists.txt (modified) (3 diffs)
-
boot.c (modified) (1 diff)
-
eval.c (modified) (4 diffs)
-
gc.c (modified) (5 diffs)
-
gl/CMakeLists.txt (modified) (4 diffs)
-
gl/TexFont.c (modified) (1 diff)
-
gl/TexFont.h (modified) (1 diff)
-
gl/boot.c (modified) (6 diffs)
-
gl/draw_list.c (modified) (17 diffs)
-
gl/gui.c (added)
-
gl/gui.h (added)
-
gl/gx.c (modified) (11 diffs)
-
gl/gx.h (modified) (5 diffs)
-
gl/gx.t (modified) (8 diffs)
-
gl/gx_atoms.h (modified) (1 diff)
-
gl/gx_dt.c (modified) (5 diffs)
-
gl/project.r (modified) (2 diffs)
-
gl/scripts/cloud.t (modified) (1 diff)
-
gl/scripts/gui.t (added)
-
gl/scripts/view.t (modified) (1 diff)
-
gl/shader.c (modified) (6 diffs)
-
gl/shader.h (modified) (1 diff)
-
gl/test.t (modified) (12 diffs)
-
gl/testfw.t (modified) (2 diffs)
-
gl/widgets (added)
-
gl/widgets/twidget.c (added)
-
mkboot.t (modified) (2 diffs)
-
parse.c (modified) (11 diffs)
-
scripts/ctx-hdr.t (added)
-
series.c (modified) (4 diffs)
-
thune-gl.spec (modified) (1 diff)
-
thune.c (modified) (13 diffs)
-
thune.spec (modified) (1 diff)
-
urlan.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/thune/CMakeLists.txt
r518 r527 1 1 project(Thune C) 2 2 3 # set(CMAKE_BUILD_TYPE Debug) 4 set(CMAKE_BUILD_TYPE Release) 5 6 # Config defines 7 add_definitions( 8 -DLANG_THUNE 9 -DUR_CONFIG_BZIP2 10 -DUR_CONFIG_TRIG 11 -DUR_CONFIG_MATH3D 12 -DUR_CONFIG_DATAFLOW 13 -DUR_CONFIG_NET 14 -DUR_CONFIG_MACROS 15 ) 3 #set(CMAKE_BUILD_TYPE Debug) 4 set(CMAKE_BUILD_TYPE Release) 16 5 17 6 … … 22 11 set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules/") 23 12 13 14 # Config defines 15 add_definitions( 16 -DLANG_THUNE 17 -DUR_CONFIG_BZIP2 18 -DUR_CONFIG_TRIG 19 -DUR_CONFIG_MATH3D 20 -DUR_CONFIG_DATAFLOW 21 -DUR_CONFIG_FCALC 22 -DUR_CONFIG_NET 23 -DUR_CONFIG_MACROS 24 ) 25 26 if(CMAKE_BUILD_TYPE STREQUAL "Debug") 27 add_definitions(-DDEBUG) 28 endif () 29 30 24 31 if (UNIX) 25 include_directories(. unix)26 add_definitions(-std=c99 -pedantic -D_GNU_SOURCE)32 include_directories(. unix) 33 add_definitions(-std=c99 -pedantic -D_GNU_SOURCE) 27 34 set(OS_FILE unix/os.c) 28 35 endif () 29 36 30 37 if (WIN32) 31 include_directories(. win32)38 include_directories(. win32) 32 39 set(OS_FILE win32/os.c) 33 40 endif () … … 35 42 36 43 add_library(thune-lib SHARED 37 urlan.c38 array.c39 list.c40 make.c41 eval.c42 thread.c43 gc.c44 tokenize.c45 charset.c46 context.c47 print.c48 series.c49 parse.c50 stdio.c51 files.c52 math.c53 bignum.c54 support/mt19937ar.c44 urlan.c 45 array.c 46 list.c 47 make.c 48 eval.c 49 thread.c 50 gc.c 51 tokenize.c 52 charset.c 53 context.c 54 print.c 55 series.c 56 parse.c 57 stdio.c 58 files.c 59 math.c 60 bignum.c 61 support/mt19937ar.c 55 62 ${OS_FILE} 56 63 ) -
trunk/thune/boot.c
r516 r527 128 128 "]\n" 129 129 "func :replace ; (ser pat rep -- ser)\n" 130 "[bind [dup second swap first set] iter/2] proc :set-key-values ; (blk ctx -- )\n" 130 131 "[now swap do now swap sub] proc :time-blk\n" 131 132 "[\n" -
trunk/thune/eval.c
r516 r527 352 352 353 353 354 static void _appendTraceBlk( UThread* ut, UCellError* err, int n, intit )354 void ur_appendTraceT( UThread* ut, UCellError* err, UIndex blkN, UIndex it ) 355 355 { 356 356 if( err->traceBlk ) … … 361 361 blk = ur_blockPtr( err->traceBlk ); 362 362 cell = ur_appendCell( blk, UT_BLOCK ); 363 ur_setSeries( cell, n, it );363 ur_setSeries( cell, blkN, it ); 364 364 } 365 365 } … … 504 504 505 505 506 /** 507 Evaluate C string. 508 509 \param cmd String to evaluate. 510 \param len Length of cmd string. May be -1 if cmd is null terminated. 511 512 \return UR_EVAL_ code. 513 */ 506 514 int ur_evalCStr( UThread* ut, const char* cmd, int len ) 507 515 { … … 1617 1625 res->func.closureN = 0; 1618 1626 res->func.sigN = sigN; 1619 } 1620 UR_S_DROP; 1627 1628 UR_S_DROP; 1629 } 1630 else 1631 { 1632 ur_throwErr( UR_ERR_DATATYPE, "func expected two block! values" ); 1633 } 1621 1634 } 1622 1635 -
trunk/thune/gc.c
r510 r527 231 231 232 232 233 static void _checkCells( UThread* ut, UCollector* gc, UCell* it, UCell* end );234 235 233 static void _checkBlock( UThread* ut, UCollector* gc, UBlock* blk ) 236 234 { … … 242 240 243 241 if( it ) 244 _checkCells( ut, gc, it, it + blk->used );245 } 246 247 248 static void _checkCells( UThread* ut, UCollector* gc, UCell* it,UCell* end )242 ur_gcMarkCells( ut, gc, it, it + blk->used ); 243 } 244 245 246 void ur_gcMarkCells( UThread* ut, UCollector* gc, UCell* it, const UCell* end ) 249 247 { 250 248 int idx; … … 410 408 UCell* cell = ((UCell*) it) - 1; 411 409 SET_BIT_BLOCK_L( it->cp.n ) 412 _checkCells( ut, gc, cell, cell + 1 );410 ur_gcMarkCells( ut, gc, cell, cell + 1 ); 413 411 it -= CC_LEN_ITER; 414 412 } … … 439 437 assert( UR_TOC >= UR_BOC ); 440 438 441 _checkCells( ut, gc, UR_BOC, UR_TOC );439 ur_gcMarkCells( ut, gc, UR_BOC, UR_TOC ); 442 440 } 443 441 #endif … … 451 449 assert( UR_TOS >= UR_BOS ); 452 450 453 _checkCells( ut, gc, UR_BOS + 1, UR_TOS + 1 );451 ur_gcMarkCells( ut, gc, UR_BOS + 1, UR_TOS + 1 ); 454 452 } 455 453 -
trunk/thune/gl/CMakeLists.txt
r518 r527 1 1 project(ThuneGL C) 2 2 3 # set(CMAKE_BUILD_TYPE Debug)4 set(CMAKE_BUILD_TYPE Release)3 #set(CMAKE_BUILD_TYPE Debug) 4 set(CMAKE_BUILD_TYPE Release) 5 5 6 6 … … 27 27 28 28 if (UNIX AND NOT APPLE) 29 find_package( X11 REQUIRED )29 find_package( X11 REQUIRED ) 30 30 include_directories(../unix) 31 31 include_directories(/usr/include/freetype2) … … 45 45 -DTHUNE_GL 46 46 ) 47 48 if(CMAKE_BUILD_TYPE STREQUAL "Debug") 49 add_definitions(-DDEBUG) 50 endif () 47 51 48 52 include_directories( … … 68 72 rfont.c 69 73 shader.c 70 # gui.c74 # gui.c 71 75 ${GLV_FILE} 72 76 ${JOYSTICK_FILE} -
trunk/thune/gl/TexFont.c
r512 r527 481 481 482 482 483 int txf_width( const TexFont* tf, const char* it, const char* end ) 484 { 485 TexGlyphInfo* prev = 0; 486 TexGlyphInfo* tgi; 487 int width = 0; 488 489 while( it != end ) 490 { 491 if( *it == '\n' ) 492 break; 493 if( *it == ' ' ) 494 { 495 tgi = txf_glyph( tf, ' ' ); 496 if( tgi ) 497 width += tgi->advance; 498 prev = 0; 499 } 500 else 501 { 502 tgi = txf_glyph( tf, *it ); 503 if( tgi ) 504 { 505 width += tgi->advance; 506 if( prev ) 507 width += txf_kerning( tf, prev, tgi ); 508 prev = tgi; 509 } 510 } 511 ++it; 512 } 513 514 return width; 515 } 516 517 518 int txf_linespacing( const TexFont* tf ) 519 { 520 return tf->max_ascent + (tf->max_ascent / 2); 521 } 522 523 483 524 /*EOF*/ -
trunk/thune/gl/TexFont.h
r512 r527 52 52 const TexGlyphInfo* right ); 53 53 extern void txf_swap( TexFont* ); 54 extern int txf_width( const TexFont*, const char* it, const char* end ); 55 extern int txf_linespacing( const TexFont* ); 54 56 55 57 #ifdef __cplusplus -
trunk/thune/gl/boot.c
r516 r527 1 "[file string!] [\n"2 " file 16 read\n"3 " dup \"RIFF\" match ift (file load-wav return)\n"4 " file read\n"5 " dup \"#!\" match ift (eol find)\n"6 " to-block kernel-ops infuse\n"7 "] func :load\n"8 1 "[\n" 9 2 " none :orient\n" … … 16 9 "context :camera\n" 17 10 "[\n" 18 " none :parent\n"19 " none :children\n"20 11 " 0,0 :area\n" 21 12 " none :key-down\n" … … 30 21 " none :draw\n" 31 22 "]\n" 32 "context :widget-proto\n" 23 "context :t-widget-proto\n" 24 "[\n" 25 " none :texture\n" 26 " none :tex-size\n" 27 " none :control-font\n" 28 " none :title-font\n" 29 " none :label\n" 30 " none :area\n" 31 " none :window-margin\n" 32 " none :window\n" 33 " none :button-size-limit\n" 34 " none :button-up\n" 35 " none :button-down\n" 36 " none :button-hover\n" 37 "]\n" 38 "context dup :gui-style-proto :gui-style\n" 33 39 "[\n" 34 40 " none :value\n" … … 47 53 " 3 :mouse-mb]\n" 48 54 "] case\n" 49 "[\n" 50 " copy\n" 51 " dup [dup first key-code 1 poke drop] iter/2\n" 52 " [dup none select do] copy swap 2 poke\n" 53 "]\n" 54 "proc :key-handler\n" 55 "[wid | handler]\n" 56 "[\n" 57 " [] display.events [\n" 58 " dup first wid get dup :handler\n" 59 " ift (second handler do) drop\n" 60 " ] iter/2\n" 61 "]\n" 62 "func :handle.events\n" 63 "[wid | handler]\n" 64 "[\n" 65 " [] 'wait display.events [\n" 66 " dup first wid get dup :handler\n" 67 " ift (second handler do) drop\n" 68 " ] iter/2\n" 69 "]\n" 70 "func :wait-events\n" 55 "[drop display.events] proc :handle-events\n" 56 "[drop display.events/wait] proc :wait-events\n" 71 57 "[list block! | ctx wrd n]\n" 72 58 "[\n" … … 128 114 "]\n" 129 115 "make-opcodes :draw-list-opcodes\n" 116 "[draw-list! swap make] proc :draw-list\n" 117 "[draw-list! swap paren! as make] proc :draw-list.compile\n" 130 118 "[\n" 131 " draw-list! swap make\n" 119 " copy\n" 120 " dup [dup first key-code 1 poke drop] iter/2\n" 132 121 "]\n" 133 "proc :draw-list\n" 122 "proc :key-handler\n" 123 "[desc | wid]\n" 134 124 "[\n" 135 " draw-list! swap paren! as make\n" 136 "]\n" 137 "proc :draw-list.compile\n" 138 "[desc | tok wid]\n" 139 "[\n" 140 " widget-proto [] make :wid\n" 141 " desc wid bind [\n" 142 " :tok\n" 143 " 'key-down block! (tok/2 key-handler :wid/key-down)\n" 144 " | 'key-up block! (tok/2 key-handler :wid/key-up)\n" 145 " | 'mouse-move block! (tok/2 :wid/mouse-move)\n" 146 " | 'mouse-down block! (tok/2 :wid/mouse-down)\n" 147 " | 'mouse-up block! (tok/2 :wid/mouse-up)\n" 148 " | 'mouse-wheel block! (tok/2 :wid/mouse-wheel)\n" 149 " | 'close block! (tok/2 :wid/close)\n" 150 " | 'resize block! (tok/2 :wid/resize)\n" 151 " | 'joystick block! (tok/2 :wid/joystick)\n" 152 " | 'draw block! (tok/2 :wid/draw)\n" 153 " | 'draw-list block! (tok/2 draw-list :wid/draw)\n" 154 " | 'parent word! (tok/2 get :wid/parent)\n" 155 " ] parse.some\n" 156 " wid/parent\n" 157 " ['area wid/parent get :wid/area]\n" 158 " [display.area :wid/area]\n" 159 " either\n" 160 " wid/resize ift (wid/area wid/resize do drop)\n" 125 " desc t-widget-proto copy dup :wid set-key-values\n" 126 " wid/key-down if-some (key-handler :wid/key-down)\n" 127 " wid/key-up if-some (key-handler :wid/key-up)\n" 128 " wid/draw if-some (draw-list :wid/draw)\n" 161 129 " wid\n" 162 130 "]\n" 163 "func :make-widget\n" 131 "func :t-widget-context\n" 132 "[widget! [t-widget none] rot 2 poke make] proc :make-widget\n" 133 "[file string!] [\n" 134 " file 16 read\n" 135 " dup \"RIFF\" match ift (file load-wav return)\n" 136 " file read\n" 137 " dup \"#!\" match ift (eol find)\n" 138 " to-block kernel-ops infuse\n" 139 "] func :load\n" 164 140 "[load shader! swap make] proc :load.shader\n" 165 141 "[load.png texture! swap make] proc :load.tex\n" … … 180 156 " 0.0 0.0 0.0 1.0 \n" 181 157 "] :unit-matrix\n" 182 "[\n" 183 " unit-matrix copy swap 13 poke\n" 184 "]\n" 185 "proc :make-matrix\n" 158 "[unit-matrix copy swap 13 poke] proc :make-matrix\n" -
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
