Changeset 442

Show
Ignore:
Timestamp:
08/05/07 00:26:17 (15 months ago)
Author:
krobillard
Message:

Added ++/-- to replace word inc/dec.
Renamed UR_FLAG_EOL as UR_FLAG_SOL.
GL - Added 'sphere draw opcode and 'curve-value call.

Location:
branches/thune/thread_safe
Files:
22 modified

Legend:

Unmodified
Added
Removed
  • branches/thune/thread_safe/boot.c

    r417 r442  
    3030  "  opcode! 25 'inc     make :inc\n" 
    3131  "  opcode! 26 'dec     make :dec\n" 
    32   "  opcode! 27 'verify  make :verify\n" 
    33   "  opcode! 28 'forever make :forever\n" 
     32  "  opcode! 27 '++      make :++\n" 
     33  "  opcode! 28 '--      make :--\n" 
     34  "  opcode! 29 'verify  make :verify\n" 
     35  "  opcode! 30 'forever make :forever\n" 
    3436  "  int!/decimal! :number!\n" 
    3537  "  word!/set-word!/get-word!/lit-word! :any-word!\n" 
  • branches/thune/thread_safe/component.c

    r430 r442  
    5252    while( it != end ) 
    5353    { 
    54         if( ur_is(it, UT_WORD) ) 
     54        if( ur_is(it, UT_WORD) || ur_is(it, UT_OPCODE) ) 
    5555        { 
    5656            if( ur_atom(it) == UR_ATOM_DDASH ) 
     
    9191    while( it != end ) 
    9292    { 
    93         if( ur_is(it, UT_WORD) || ur_is(it, UT_SELECT) ) 
     93        if( ur_is(it, UT_WORD) || ur_is(it, UT_OPCODE) || 
     94            ur_is(it, UT_SELECT) ) 
    9495        { 
    9596            atom = ur_atom(it); 
  • branches/thune/thread_safe/doc/GLManual

    r383 r442  
    169169================  ======================  ====================== 
    170170lerp_             (val1 val2 t -- valt) 
     171curve-value_      (curve t -- valt) 
    171172================  ======================  ====================== 
    172173 
    173174 
    174175lerp 
     176++++ 
     177 
     178Does a linear interpolation between two values of the same type 
     179(decimal!, vec3!, or coord!). 
     180 
     181This is the calculation used:: 
     182 
     183        result = v1 + ((v2 - v1) * t) 
     184 
     185Stack usage:: 
     186 
     187    (v1 decimal!/vec3!/coord! 
     188     v2 decimal!/vec3!/coord! 
     189     t  decimal! 
     190     -- decimal!/vec3!/coord!) 
     191 
     192 
     193curve-value 
    175194+++++++++++ 
    176195 
    177 Does a linear interpolation between two decimal or two vec3 values. 
    178  
    179 :: 
    180  
    181     (decimal!/vec3!  decimal!/vec3! decimal! -- decimal!/vec3!) 
     196Returns value on curve at time t.  Currently only linear segments are 
     197implemented. 
     198 
     199Stack usage:: 
     200 
     201    (block!  decimal!/int! -- value) 
     202 
     203Example:: 
     204 
     205    [0.0  2.0 
     206     0.5  7.0 
     207     1.0  7.0 
     208     8.0  2.0] 3 curve-value 
     209    = 5.57143 
    182210 
    183211 
     
    196224clear                                     glClear() 
    197225call              draw-list 
     226enable/F                                  glEnable() 
     227disable/F                                 glDisable() 
    198228solid                                     Draw without textures 
    199229model                                     Draw with texture (will be changed) 
     
    212242font              font!                   Draw with font 
    213243text              [coord!] text           Draw text in current font 
     244sphere            radius slices,stacks    Draw textured GLUT sphere 
    214245shader            shader!/none!/0         Load shader 
    215246framebuffer       framebuffer!/none!/0    Bind framebuffer 
  • branches/thune/thread_safe/doc/thune.vim

    r211 r442  
    4444syn keyword     thuneOpcode     nop drop dup dup2 over swap nip tuck 
    4545syn keyword     thuneOpcode     rot rot.r do 
    46 syn keyword     thuneOpcode     inc dec verify 
     46syn keyword     thuneOpcode     inc dec ++ -- verify 
    4747 
    4848" Values 
  • branches/thune/thread_safe/eval.c

    r431 r442  
    13861386            if( wrdN > -1 ) 
    13871387            { 
    1388                 flags = it->id.flags & UR_FLAG_EOL; 
     1388                flags = it->id.flags & UR_FLAG_SOL; 
    13891389 
    13901390                ur_copyCell( it, values[ wrdN ] ); 
    13911391 
    1392                 it->id.flags = (it->id.flags & ~UR_FLAG_EOL) | flags; 
     1392                it->id.flags = (it->id.flags & ~UR_FLAG_SOL) | flags; 
    13931393            } 
    13941394        } 
     
    14041404                UCell* src; 
    14051405                int sel; 
    1406 #define ISEL_FLAGS   (UR_FLAG_EOL | UR_FLAG_SEL_ATOM) 
     1406#define ISEL_FLAGS   (UR_FLAG_SOL | UR_FLAG_SEL_ATOM) 
    14071407 
    14081408                src = values + wrdN; 
     
    14731473    while( it != end ) 
    14741474    { 
    1475         if( ur_is(it, UT_WORD) ) 
     1475        if( ur_is(it, UT_WORD) || ur_is(it, UT_OPCODE) ) 
    14761476        { 
    14771477            if( ur_atom(it) == UR_ATOM_DDASH ) 
     
    14961496    while( it != end ) 
    14971497    { 
    1498         if( ur_is(it, UT_WORD) ) 
     1498        if( ur_is(it, UT_WORD) || ur_is(it, UT_OPCODE) ) 
    14991499        { 
    15001500            if( ur_atom(it) == UR_ATOM_DDASH ) 
     
    16151615        { 
    16161616            cell = blk->ptr.cells + tos->series.it; 
    1617             cell->id.flags |= UR_FLAG_EOL; 
     1617            cell->id.flags |= UR_FLAG_SOL; 
    16181618        } 
    16191619    } 
     
    16281628            { 
    16291629                cell = blk->ptr.cells + tos->series.it; 
    1630                 cell->id.flags |= UR_FLAG_BLOCK_EOL; 
     1630                cell->id.flags |= UR_FLAG_BLOCK_SOL; 
    16311631            } 
    16321632            UR_S_DROP; 
  • branches/thune/thread_safe/gl/boot.c

    r436 r442  
    9797  "    quads\n" 
    9898  "    quad-strip\n" 
     99  "    sphere\n" 
    99100  "    camera\n" 
    100101  "    light\n" 
  • branches/thune/thread_safe/gl/draw_list.c

    r438 r442  
    4141    EN_LIGHTING     = 0x0010, 
    4242    EN_LINE_SMOOTH  = 0x0020, 
    43     EN_POINT_SMOOTH = 0x0040, 
    44     EN_POINT_SPRITE = 0x0080, 
    45     EN_SCISSOR_TEST = 0x0100, 
    46     EN_STENCIL_TEST = 0x0200, 
    47     EN_TEXTURE_2D   = 0x0400, 
    48     EN_VERTEX_PROGRAM_POINT_SIZE = 0x0800 
     43    EN_MULTISAMPLE  = 0x0040, 
     44    EN_POINT_SMOOTH = 0x0080, 
     45    EN_POINT_SPRITE = 0x0100, 
     46    EN_SCISSOR_TEST = 0x0200, 
     47    EN_STENCIL_TEST = 0x0400, 
     48    EN_TEXTURE_2D   = 0x0800, 
     49    EN_VERTEX_PROGRAM_POINT_SIZE = 0x1000 
    4950}; 
    5051 
     
    735736 
    736737/* 
     738   This should only be used from a compiled draw list since a GLUquadricObj 
     739   is created and deleted. 
     740*/ 
     741static UCell* dop_sphere( UThread* ut, UCell* pc ) 
     742{ 
     743    GLdouble radius;  
     744    GLint slices, stacks; 
     745 
     746    ++pc; 
     747    if( ur_is(pc, UT_DECIMAL) ) 
     748        radius = ur_decimal(pc); 
     749    else if( ur_is(pc, UT_INT) ) 
     750        radius = (GLdouble) ur_int(pc); 
     751    else 
     752    { 
     753        ur_throwErr( UR_ERR_DATATYPE, "sphere expected number! for radius" ); 
     754        return 0; 
     755    } 
     756 
     757    ++pc; 
     758    if( ur_is(pc, UT_COORD) ) 
     759    { 
     760        slices = pc->coord.elem[0]; 
     761        stacks = pc->coord.elem[1]; 
     762    } 
     763    else 
     764    { 
     765        ur_throwErr( UR_ERR_DATATYPE, 
     766                     "sphere expected coord! for slices,stacks" ); 
     767        return 0; 
     768    } 
     769 
     770    GLUquadricObj* obj = gluNewQuadric(); 
     771    if( obj ) 
     772    { 
     773        gluQuadricTexture( obj, GL_TRUE ); 
     774        gluQuadricNormals( obj, GLU_SMOOTH ); 
     775        gluQuadricDrawStyle( obj, GLU_FILL ); 
     776        gluQuadricOrientation( obj, GLU_OUTSIDE ); 
     777 
     778        gluSphere( obj, radius, slices, stacks ); 
     779 
     780        gluDeleteQuadric( obj ); 
     781    } 
     782 
     783    return pc; 
     784} 
     785 
     786 
     787/* 
    737788  attrib/1 shader/my-attrib float-count #[...] 
    738789 
     
    927978    PRINT_STATE( "GL_LIGHTING/l",     EN_LIGHTING,     GL_LIGHTING ) 
    928979    PRINT_STATE( "GL_LINE_SMOOTH/n",  EN_LINE_SMOOTH,  GL_LINE_SMOOTH ) 
     980    PRINT_STATE( "GL_MULTISAMPLE/m",  EN_MULTISAMPLE,  GL_MULTISAMPLE ) 
    929981    PRINT_STATE( "GL_POINT_SMOOTH/o", EN_POINT_SMOOTH, GL_POINT_SMOOTH ) 
    930982    PRINT_STATE( "GL_POINT_SPRITE/p", EN_POINT_SPRITE, GL_POINT_SPRITE ) 
     
    9701022                ENABLE( EN_LIGHTING, GL_LIGHTING ) 
    9711023                break; 
     1024            case 'm': 
     1025                ENABLE( EN_MULTISAMPLE, GL_MULTISAMPLE ) 
     1026                break; 
    9721027            case 'n': 
    9731028                ENABLE( EN_LINE_SMOOTH, GL_LINE_SMOOTH ) 
     
    10231078            case 'l': 
    10241079                DISABLE( EN_LIGHTING, GL_LIGHTING ) 
     1080                break; 
     1081            case 'm': 
     1082                DISABLE( EN_MULTISAMPLE, GL_MULTISAMPLE ) 
    10251083                break; 
    10261084            case 'n': 
     
    12091267                        break; 
    12101268                } 
     1269                break; 
     1270 
     1271            case DOP_SPHERE:                 // sphere rad silces,stacks 
     1272                pc = dop_sphere( ut, pc ); 
     1273                if( ! pc ) 
     1274                    return 0; 
    12111275                break; 
    12121276 
  • branches/thune/thread_safe/gl/draw_ops.h

    r420 r442  
    2626#define DOP_QUADS           23 
    2727#define DOP_QUAD_STRIP      24 
    28 #define DOP_CAMERA          25 
    29 #define DOP_LIGHT           26 
    30 #define DOP_LIGHTING        27 
    31 #define DOP_PUSH            28 
    32 #define DOP_POP             29 
    33 #define DOP_TRANSLATE       30 
    34 #define DOP_ROTATE          31 
    35 #define DOP_SCALE           32 
    36 #define DOP_FONT            33 
    37 #define DOP_TEXT            34 
    38 #define DOP_SHADER          35 
    39 #define DOP_FRAMEBUFFER     36 
    40 #define DOP_SHADOW_BEGIN    37 
    41 #define DOP_SHADOW_END      38 
    42 #define DOP_SAMPLES_QUERY   39 
    43 #define DOP_SAMPLES_BEGIN   40 
     28#define DOP_SPHERE          25 
     29#define DOP_CAMERA          26 
     30#define DOP_LIGHT           27 
     31#define DOP_LIGHTING        28 
     32#define DOP_PUSH            29 
     33#define DOP_POP             30 
     34#define DOP_TRANSLATE       31 
     35#define DOP_ROTATE          32 
     36#define DOP_SCALE           33 
     37#define DOP_FONT            34 
     38#define DOP_TEXT            35 
     39#define DOP_SHADER          36 
     40#define DOP_FRAMEBUFFER     37 
     41#define DOP_SHADOW_BEGIN    38 
     42#define DOP_SHADOW_END      39 
     43#define DOP_SAMPLES_QUERY   40 
     44#define DOP_SAMPLES_BEGIN   41 
  • branches/thune/thread_safe/gl/glfbo.c

    r438 r442  
    118118            GLuint name = listBase + i; 
    119119            glDeleteFramebuffersEXT( 1, &name ); 
     120            //printf( "KR glDeleteFramebuffersEXT(1,%d)\n", name ); 
    120121        } 
    121122    } 
  • branches/thune/thread_safe/gl/gx.c

    r440 r442  
    11881188 
    11891189 
    1190 // (val1 val2 time -- valI) 
    1191 UR_CALL( uc_lerp ) 
    1192 { 
    1193     UCell* v1; 
    1194     UCell* v2; 
    1195  
    1196 #define INTERP(A,B)     A += (B - A) * frac; 
    1197  
    1198     if( ur_is(tos, UT_DECIMAL) ) 
    1199     { 
    1200         double frac = ur_decimal(tos); 
    1201  
     1190#define INTERP(R,A,B)     R = A + (B - A) * frac; 
     1191 
     1192/* 
     1193   res may be v1 or v2. 
     1194 
     1195   \return non-zero if successful. 
     1196*/ 
     1197static int _lerpCells( UCell* v1, UCell* v2, double frac, UCell* res ) 
     1198{ 
     1199    if( ur_type(v1) == ur_type(v2) ) 
     1200    { 
    12021201        if( frac < 0.0 ) 
    12031202            frac = 0.0; 
     
    12051204            frac = 1.0; 
    12061205 
     1206        if( ur_is(v1, UT_DECIMAL) ) 
     1207        { 
     1208            ur_initType(res, UT_DECIMAL); 
     1209            INTERP( ur_decimal(res), ur_decimal(v1), ur_decimal(v2) ); 
     1210            return 1; 
     1211        } 
     1212        else if( ur_is(v1, UT_VEC3) ) 
     1213        { 
     1214            ur_initType(res, UT_VEC3); 
     1215            INTERP( res->vec3.xyz[0], v1->vec3.xyz[0], v2->vec3.xyz[0] ); 
     1216            INTERP( res->vec3.xyz[1], v1->vec3.xyz[1], v2->vec3.xyz[1] ); 
     1217            INTERP( res->vec3.xyz[2], v1->vec3.xyz[2], v2->vec3.xyz[2] ); 
     1218            return 1; 
     1219        } 
     1220        else if( ur_is(v1, UT_COORD) ) 
     1221        { 
     1222            int i; 
     1223            int len = v1->coord.len; 
     1224            if( v2->coord.len < len ) 
     1225                len = v2->coord.len; 
     1226            for( i = 0; i < len; ++i ) 
     1227            { 
     1228                INTERP( res->coord.elem[i], 
     1229                        v1->coord.elem[i], v2->coord.elem[i] ); 
     1230            } 
     1231            ur_initType(res, UT_COORD); 
     1232            res->coord.len = len; 
     1233            return 1; 
     1234        } 
     1235    } 
     1236    return 0; 
     1237} 
     1238 
     1239 
     1240// (val1 val2 time -- valI) 
     1241UR_CALL( uc_lerp ) 
     1242{ 
     1243    UCell* v1; 
     1244    UCell* v2; 
     1245 
     1246    if( ur_is(tos, UT_DECIMAL) ) 
     1247    { 
    12071248        v2 = ur_s_prev(tos); 
    12081249        v1 = ur_s_prev(v2); 
    1209         if( ur_type(v1) == ur_type(v2) ) 
    1210         { 
    1211             if( ur_is(v1, UT_DECIMAL) ) 
    1212             { 
    1213                 INTERP( ur_decimal(v1), ur_decimal(v2) ); 
    1214             } 
    1215             else if( ur_is(v1, UT_VEC3) ) 
    1216             { 
    1217                 INTERP( v1->vec3.xyz[0], v2->vec3.xyz[0] ); 
    1218                 INTERP( v1->vec3.xyz[1], v2->vec3.xyz[1] ); 
    1219                 INTERP( v1->vec3.xyz[2], v2->vec3.xyz[2] ); 
    1220             } 
    1221             else if( ur_is(v1, UT_COORD) ) 
    1222             { 
    1223                 int i; 
    1224                 int len = v1->coord.len; 
    1225                 if( v2->coord.len < len ) 
    1226                     len = v2->coord.len; 
    1227                 for( i = 0; i < len; ++i ) 
    1228                 { 
    1229                     INTERP( v1->coord.elem[i], v2->coord.elem[i] ); 
    1230                 } 
    1231             } 
    1232             else 
    1233             { 
    1234                 ur_throwErr( UR_ERR_DATATYPE, 
    1235                              "lerp expected decimal!/vec3!/coord! value" ); 
    1236                 return; 
    1237             } 
     1250        if( _lerpCells( v1, v2, ur_decimal(tos), v1 ) ) 
     1251        { 
    12381252            UR_S_DROPN( 2 ); 
    12391253            return; 
    12401254        } 
    12411255        ur_throwErr( UR_ERR_DATATYPE, 
    1242                      "lerp expected 2 values of the same type" ); 
     1256                     "lerp expected 2 decimal!/vec3!/coord! values" ); 
    12431257        return; 
    12441258    } 
    12451259    ur_throwErr( UR_ERR_DATATYPE, "lerp expected decimal! fraction" ); 
     1260} 
     1261 
     1262 
     1263// (curve t -- val) 
     1264UR_CALL( uc_curve_value ) 
     1265{ 
     1266    double t, t1, d; 
     1267    int len; 
     1268    UCell* v1; 
     1269    UCell* cv; 
     1270    UCell* it; 
     1271    UCell* end; 
     1272    UBlock* blk; 
     1273 
     1274    if( ur_is(tos, UT_DECIMAL) ) 
     1275        t = ur_decimal(tos); 
     1276    else if( ur_is(tos, UT_INT) ) 
     1277        t = (double) ur_int(tos); 
     1278    else 
     1279        goto bad_dt; 
     1280 
     1281    cv = ur_s_prev(tos); 
     1282    if( ur_is(cv, UT_BLOCK) ) 
     1283    { 
     1284        blk = ur_block( cv ); 
     1285        UR_ITER_BLOCK( it, end, blk, cv ); 
     1286        len = end - it; 
     1287        if( len & 1 ) 
     1288        { 
     1289            --len; 
     1290            --end; 
     1291        } 
     1292        if( len ) 
     1293        { 
     1294            v1 = 0; 
     1295            while( it != end ) 
     1296            { 
     1297                // Assume decimal! for speed. 
     1298                if( t <= ur_decimal(it) ) 
     1299                { 
     1300                    if( ! v1 ) 
     1301                    { 
     1302                        ur_copyCell( cv, it[1] ); 
     1303                        goto finish; 
     1304                    } 
     1305 
     1306                    t1 = ur_decimal(v1); 
     1307                    d  = ur_decimal(it) - t1; 
     1308                    if( ! d ) 
     1309                        goto copy; 
     1310 
     1311                    if( _lerpCells( v1 + 1, it + 1, (t - t1) / d, cv ) ) 
     1312                        goto finish; 
     1313                    ur_throwErr( UR_ERR_DATATYPE, 
     1314                             "lerp expected 2 decimal!/vec3!/coord! values" ); 
     1315                    return; 
     1316                } 
     1317                v1 = it; 
     1318                it += 2; 
     1319            } 
     1320copy: 
     1321            ur_copyCell( cv, v1[1] ); 
     1322        } 
     1323        else 
     1324        { 
     1325            ur_setNone( cv ); 
     1326        } 
     1327 
     1328finish: 
     1329        UR_S_DROP; 
     1330        return; 
     1331    } 
     1332 
     1333bad_dt: 
     1334 
     1335    ur_throwErr( UR_ERR_DATATYPE, 
     1336                 "curve-value expected block! int!/decimal!" ); 
    12461337} 
    12471338 
     
    12861377 
    12871378#if 0 
    1288 #if 0 
     1379#if 1 
    12891380extern float perlinNoise2D( float x, float y, int octaves, float persist ); 
    12901381#define PReal   float 
     
    13411432                    for( x = 0.0f; x < w; x += 1.0f ) 
    13421433                    { 
    1343                       //n = perlinNoise2D( x * 0.1, y * 0.1, octaves, persist ); 
    1344                         n = perlinNoise2D( x/w, y/h, persist, 2, octaves ); 
     1434                        n = perlinNoise2D( x * 0.1, y * 0.1, octaves, persist ); 
     1435                      //n = perlinNoise2D( x/w, y/h, persist, 2, octaves ); 
    13451436 
    13461437                        //printf( "%g\n", n ); 
     
    14641555    { uc_look_at,        "look-at" }, 
    14651556    { uc_lerp,           "lerp" }, 
     1557    { uc_curve_value,    "curve-value" }, 
    14661558    { uc_gl_extensions,  "gl-extensions" }, 
    14671559    { uc_gl_max_textures,"gl-max-textures" }, 
     
    15821674#endif 
    15831675 
    1584     gView = glv_create( GLV_ATTRIB_DOUBLEBUFFER ); 
     1676    gView = glv_create( GLV_ATTRIB_DOUBLEBUFFER | GLV_ATTRIB_MULTISAMPLE ); 
    15851677    if( ! gView ) 
    15861678    { 
  • branches/thune/thread_safe/gl/gx.t

    r436 r442  
    161161    quads 
    162162    quad-strip 
     163 
     164    sphere 
    163165 
    164166    camera 
  • branches/thune/thread_safe/gl/gx_atoms.h

    r438 r442  
    99#define UR_ATOM_TEXTURE         325 
    1010#define UR_ATOM_ELEM            326 
    11 #define UR_ATOM_CLOSE           179 
     11#define UR_ATOM_CLOSE           178 
    1212#define UR_ATOM_FOCUS           327 
    1313#define UR_ATOM_RESIZE          328 
     
    4242#define UR_ATOM_ON              258 
    4343#define UR_ATOM_OFF             260 
    44 #define UR_ATOM_ADD             198 
     44#define UR_ATOM_ADD             197 
    4545#define UR_ATOM_BURN            355 
    4646#define UR_ATOM_COLOR           356 
  • branches/thune/thread_safe/gl/project.r

    r426 r442  
    9393        %rfont.c 
    9494        %shader.c 
     95        ;%noise.c 
    9596        ;%perlin.c 
     97        ;%../util/cbparse.c 
     98        ;%curves.c 
    9699        ;%hit/AABBTree.c 
    97100        ;%hit/build_bbt.c 
    98  
    99         ;%noise.c 
    100         ;%../util/cbparse.c 
    101         ;%curves.c 
    102101    ] 
    103102] 
  • branches/thune/thread_safe/gl/testfw.t

    r438 r442  
    59591.0 :zoom 
    60600,0,155 :bg-color 
     61;true :multisample 
     62 
    6163 
    6264 
     
    9395        key-down [ 
    9496            esc [quit] 
     97            ;m   [multisample complement dup . dup :multisample 
     98            ;     [enable/m][disable/m?] either] 
    95