Changeset 383
- Timestamp:
- 04/29/07 06:21:11 (19 months ago)
- Location:
- trunk/thune
- Files:
-
- 6 modified
-
doc/GLManual (modified) (3 diffs)
-
gl/boot.c (modified) (1 diff)
-
gl/draw_list.c (modified) (8 diffs)
-
gl/draw_ops.h (modified) (1 diff)
-
gl/gx.h (modified) (2 diffs)
-
gl/gx.t (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/thune/doc/GLManual
r364 r383 229 229 normals vector! Set normal array 230 230 uvs vector! Set texture UV array 231 attrib select! (int!) vector! Set user attribute array 231 232 points attr vector! Draw points 232 233 lines attr vector! Draw line primitives … … 256 257 UV t Index into texture *uvs* vector 257 258 Vertex v Index into *verts* vector 259 User Attribute a Index into *attrib* vector 258 260 ================ ====================== =========================== 259 261 262 The UV attribute (t) may appear more than once in the word. Each occurance 263 will set the UV of the next texture unit (0, 1, 2, etc.). 260 264 261 265 Some primitive examples:: … … 267 271 268 272 quads tnv #[0 0 0 1 0 1 2 0 2 3 0 3 269 270 273 271 274 -
trunk/thune/gl/boot.c
r360 r383 69 69 " normals\n" 70 70 " uvs\n" 71 " attrib\n" 71 72 " points\n" 72 73 " lines\n" -
trunk/thune/gl/draw_list.c
r382 r383 73 73 _state.uvVals = 0; 74 74 _state.colorVals = 0; 75 _state.attr[0].vals = 0; 76 _state.attr[1].vals = 0; 75 77 } 76 78 … … 598 600 599 601 /* 602 attrib/1 shader/my-attrib float-count #[...] 603 604 Returns pc at last argument or zero if arguments are bad. 605 */ 606 static UCell* dop_attrib( UThread* ur_thread, UCell* pc ) 607 { 608 GrVertexAttribute* attr; 609 Shader* sh = 0; 610 611 attr = _state.attr; // + ur_sel(pc); 612 ++pc; 613 614 if( ur_is(pc, UT_SELECT) ) 615 { 616 UCell* val = ur_wordCell( ur_thread, pc ); 617 if( ! val ) 618 return 0; 619 if( ur_is(val, UT_CONTEXT) ) 620 { 621 UCell* cval = ur_blockPtr( val->ctx.valBlk )->ptr.cells; 622 if( cval && ur_is(cval, UT_SHADER) ) 623 { 624 sh = (Shader*) ur_resPtr( cval->series.n )->ptr; 625 } 626 } 627 else if( ur_is(val, UT_SHADER) ) 628 { 629 sh = (Shader*) ur_resPtr( val->series.n )->ptr; 630 } 631 } 632 633 if( ! sh ) 634 { 635 ur_throwErr( UR_ERR_DATATYPE, "attrib expected shader!" ); 636 return 0; 637 } 638 639 //glUseProgram( sh->program ); 640 641 // LIMIT: Shader attribute names must be lower-case. 642 attr->loc = glGetAttribLocation( sh->program, ur_atomCStr(ur_sel(pc), 0) ); 643 if( attr->loc == -1 ) 644 { 645 ur_throwErr( UR_ERR_SCRIPT, "attrib '%s not found", 646 ur_atomCStr(ur_sel(pc), 0) ); 647 return 0; 648 } 649 650 ++pc; 651 if( ur_is(pc, UT_INT) ) 652 { 653 attr->count = ur_int(pc); 654 ++pc; 655 } 656 else 657 { 658 attr->count = 3; 659 } 660 661 if( ur_is(pc, UT_VECTOR) ) 662 { 663 attr->vals = ur_bin(pc)->ptr.f; 664 return pc; 665 } 666 667 ur_throwErr( UR_ERR_DATATYPE, "attrib expected vector!" ); 668 return 0; 669 } 670 671 672 /* 600 673 icell is an int array! 601 674 */ … … 604 677 //GLdouble vec[3]; 605 678 const char* ki; 679 int ti; 606 680 UCell* col; 607 681 int32_t* it; … … 613 687 614 688 ki = key; 689 ti = 0; 615 690 616 691 while( it != end ) … … 618 693 switch( *ki ) 619 694 { 620 /*621 glUseProgram( program );622 GLint attrib_loc = glGetAttribLocation( program, âmy_attribâ );623 if( attrib_loc == -1 ) not_found;624 695 case 'a': 625 glVertexAttrib3f( attrib_loc, 4.0f, 2.0f, 7.0f ); 626 break; 627 */ 696 { 697 GrVertexAttribute* attr = _state.attr; 698 switch( attr->count ) 699 { 700 case 1: 701 glVertexAttrib1fv( attr->loc, attr->vals + *it ); 702 break; 703 case 2: 704 glVertexAttrib2fv( attr->loc, attr->vals + *it * 2 ); 705 break; 706 case 3: 707 glVertexAttrib3fv( attr->loc, attr->vals + *it * 3 ); 708 break; 709 case 4: 710 glVertexAttrib4fv( attr->loc, attr->vals + *it * 4 ); 711 break; 712 } 713 } 714 break; 628 715 629 716 case 'c': … … 657 744 float* uv = _state.uvVals + *it * 2; 658 745 //glMultiTexCoord2fv( GL_TEXTURE0, uv ); 659 glMultiTexCoord2f( GL_TEXTURE0, uv[0], 1.0f - uv[1] ); 746 glMultiTexCoord2f( GL_TEXTURE0 + ti, uv[0], 1.0f - uv[1] ); 747 ++ti; 660 748 } 661 749 break; … … 664 752 ++ki; 665 753 if( *ki == '\0' ) 754 { 666 755 ki = key; 756 ti = 0; 757 } 667 758 668 759 ++it; … … 852 943 if( ur_is(pc, UT_VECTOR) ) 853 944 _state.uvVals = ur_bin(pc)->ptr.f; 945 break; 946 947 case DOP_ATTRIB: 948 pc = dop_attrib( ur_thread, pc ); 949 if( ! pc ) 950 return 0; 854 951 break; 855 952 -
trunk/thune/gl/draw_ops.h
r359 r383 14 14 #define DOP_NORMALS 11 15 15 #define DOP_UVS 12 16 #define DOP_POINTS 13 17 #define DOP_LINES 14 18 #define DOP_LINE_STRIP 15 19 #define DOP_TRIS 16 20 #define DOP_TRI_STRIP 17 21 #define DOP_TRI_FAN 18 22 #define DOP_QUADS 19 23 #define DOP_QUAD_STRIP 20 24 #define DOP_CAMERA 21 25 #define DOP_LIGHT 22 26 #define DOP_LIGHTING 23 27 #define DOP_PUSH 24 28 #define DOP_POP 25 29 #define DOP_TRANSLATE 26 30 #define DOP_ROTATE 27 31 #define DOP_SCALE 28 32 #define DOP_FONT 29 33 #define DOP_TEXT 30 34 #define DOP_SHADER 31 35 #define DOP_FRAMEBUFFER 32 36 #define DOP_SHADOW_BEGIN 33 37 #define DOP_SHADOW_END 34 16 #define DOP_ATTRIB 13 17 #define DOP_POINTS 14 18 #define DOP_LINES 15 19 #define DOP_LINE_STRIP 16 20 #define DOP_TRIS 17 21 #define DOP_TRI_STRIP 18 22 #define DOP_TRI_FAN 19 23 #define DOP_QUADS 20 24 #define DOP_QUAD_STRIP 21 25 #define DOP_CAMERA 22 26 #define DOP_LIGHT 23 27 #define DOP_LIGHTING 24 28 #define DOP_PUSH 25 29 #define DOP_POP 26 30 #define DOP_TRANSLATE 27 31 #define DOP_ROTATE 28 32 #define DOP_SCALE 29 33 #define DOP_FONT 30 34 #define DOP_TEXT 31 35 #define DOP_SHADER 32 36 #define DOP_FRAMEBUFFER 33 37 #define DOP_SHADOW_BEGIN 34 38 #define DOP_SHADOW_END 35 -
trunk/thune/gl/gx.h
r382 r383 120 120 121 121 122 typedef struct 123 { 124 float* vals; 125 int count; 126 GLint loc; 127 } 128 GrVertexAttribute; 129 130 122 131 struct GrRenderState 123 132 { … … 133 142 UCell* colorVals; 134 143 float* uvVals; 144 145 GrVertexAttribute attr[2]; 135 146 }; 136 147 -
trunk/thune/gl/gx.t
r360 r383 128 128 normals 129 129 uvs 130 attrib 130 131 131 132 points
