Changeset 296 for trunk/thune/gl
- Timestamp:
- 10/06/06 21:47:31 (2 years ago)
- Location:
- trunk/thune/gl
- Files:
-
- 5 modified
-
draw_list.c (modified) (6 diffs)
-
draw_ops.h (modified) (1 diff)
-
gx.c (modified) (1 diff)
-
gx.t (modified) (2 diffs)
-
test.t (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/thune/gl/draw_list.c
r295 r296 21 21 #include <assert.h> 22 22 #include "gx.h" 23 #include "gx_atoms.h" 23 24 #include "draw_ops.h" 24 25 #include "gllist.h" … … 95 96 break; 96 97 98 case GRS_MODEL: 99 glDepthMask( GL_TRUE ); 100 glShadeModel( GL_SMOOTH ); 101 102 //glColorMaterial( GL_FRONT, GL_DIFFUSE ); 103 //glEnable( GL_COLOR_MATERIAL ); 104 105 glEnable( GL_DEPTH_TEST ); 106 glEnable( GL_LIGHTING ); 107 glEnable( GL_CULL_FACE ); 108 109 glDisable( GL_BLEND ); 110 111 gr_disableTexture(); 112 break; 113 97 114 case GRS_TEXT: 98 115 glDepthMask( GL_FALSE ); … … 363 380 364 381 382 static void _lightv3( GLenum light, GLenum pname, UCell* cell, GLfloat w ) 383 { 384 GLfloat pos[4]; 385 386 pos[0] = cell->vec3.xyz[0]; 387 pos[1] = cell->vec3.xyz[1]; 388 pos[2] = cell->vec3.xyz[2]; 389 pos[3] = w; 390 391 printf( "KR %d %d %g\n", light, pname, w ); 392 glLightfv( light, pname, pos ); 393 } 394 395 396 static void _lightEn( GLenum light, UCell* cell ) 397 { 398 if( ur_logic(cell) ) 399 glEnable( light ); 400 else 401 glDisable( light ); 402 } 403 404 405 static void dop_light( UThread* ur_thread, UCell* val, int light ) 406 { 407 if( ur_is(val, UT_LOGIC) ) 408 { 409 _lightEn( light, val ); 410 } 411 else if( ur_is(val, UT_VEC3) ) 412 { 413 _lightv3( light, GL_POSITION, val, 0.0f ); 414 } 415 else if( ur_is(val, UT_BLOCK) ) 416 { 417 UBlock* blk; 418 UCell* it; 419 UCell* end; 420 GLenum name = GL_POSITION; 421 GLfloat w = 0.0f; 422 423 blk = ur_block(val); 424 UR_ITER_BLOCK( it, end, blk, val ); 425 while( it != end ) 426 { 427 if( ur_isAWord(it) ) 428 { 429 switch( ur_atom(it) ) 430 { 431 case UR_ATOM_AMBIENT: name = GL_AMBIENT; w = 1.0f; break; 432 case UR_ATOM_DIFFUSE: name = GL_DIFFUSE; w = 1.0f; break; 433 case UR_ATOM_POS: name = GL_POSITION; w = 0.0f; break; 434 435 default: 436 val = ur_wordCell( ur_thread, it ); 437 if( val ) 438 { 439 if( ur_is(val, UT_LOGIC) ) 440 _lightEn( light, val ); 441 else if( ur_is(val, UT_VEC3) ) 442 _lightv3( light, name, val, w ); 443 } 444 break; 445 } 446 } 447 else if( ur_is(it, UT_VEC3) ) 448 { 449 _lightv3( light, name, it, w ); 450 } 451 else if( ur_is(it, UT_LOGIC) ) 452 { 453 _lightEn( light, it ); 454 } 455 ++it; 456 } 457 } 458 } 459 365 460 366 461 /* … … 470 565 break; 471 566 472 case DOP_CAMERA: 567 case DOP_MODEL: 568 gr_setState( GRS_MODEL ); 569 break; 570 571 case DOP_CAMERA: // context! 473 572 { 474 573 //int ref = ur_selIsAtom(pc) ? ur_sel(pc) : 0; … … 478 577 dop_camera( val ); 479 578 } 579 break; 580 581 case DOP_LIGHT: // logic! on/off 582 // vec3! position 583 { 584 int light = ur_selIsAtom(pc) ? 0 : ur_sel(pc); 585 ++pc; 586 VAL_WORD_OR_PC 587 dop_light( ur_thread, val, GL_LIGHT0 + light ); 588 } 589 break; 590 591 case DOP_LIGHTING: // logic! on/off 592 ++pc; 593 if( ur_is(pc, UT_LOGIC) ) 594 { 595 if( ur_logic(val) ) 596 glEnable( GL_LIGHTING ); 597 else 598 glDisable( GL_LIGHTING ); 599 } 480 600 break; 481 601 … … 499 619 { 500 620 glColor3fv( pc->vec3.xyz ); 621 //glMaterialfv( GL_FRONT_AND_BACK, GL_DIFFUSE, pc->vec3.xyz ); 501 622 } 502 623 else if( ur_is(pc, UT_INT) ) -
trunk/thune/gl/draw_ops.h
r286 r296 5 5 #define DOP_CALL 2 6 6 #define DOP_SOLID 3 7 #define DOP_COLOR 4 8 #define DOP_COLORS 5 9 #define DOP_VERTS 6 10 #define DOP_NORMALS 7 11 #define DOP_UVS 8 12 #define DOP_POINTS 9 13 #define DOP_LINES 10 14 #define DOP_LINE_STRIP 11 15 #define DOP_TRIS 12 16 #define DOP_TRI_STRIP 13 17 #define DOP_TRI_FAN 14 18 #define DOP_QUADS 15 19 #define DOP_QUAD_STRIP 16 20 #define DOP_CAMERA 17 21 #define DOP_UNIT_XFORM 18 22 #define DOP_PUSH 19 23 #define DOP_POP 20 24 #define DOP_TRANSLATE 21 25 #define DOP_ROTATE 22 26 #define DOP_SCALE 23 27 #define DOP_FONT 24 28 #define DOP_TEXT 25 7 #define DOP_MODEL 4 8 #define DOP_COLOR 5 9 #define DOP_COLORS 6 10 #define DOP_VERTS 7 11 #define DOP_NORMALS 8 12 #define DOP_UVS 9 13 #define DOP_POINTS 10 14 #define DOP_LINES 11 15 #define DOP_LINE_STRIP 12 16 #define DOP_TRIS 13 17 #define DOP_TRI_STRIP 14 18 #define DOP_TRI_FAN 15 19 #define DOP_QUADS 16 20 #define DOP_QUAD_STRIP 17 21 #define DOP_CAMERA 18 22 #define DOP_LIGHT 19 23 #define DOP_LIGHTING 20 24 #define DOP_PUSH 21 25 #define DOP_POP 22 26 #define DOP_TRANSLATE 23 27 #define DOP_ROTATE 24 28 #define DOP_SCALE 25 29 #define DOP_FONT 26 30 #define DOP_TEXT 27 -
trunk/thune/gl/gx.c
r295 r296 1844 1844 FIXED_ATOM( "mouse-wheel", 11, UR_ATOM_MOUSE_WHEEL ); 1845 1845 1846 FIXED_ATOM( "ambient", 7, UR_ATOM_AMBIENT ); 1847 FIXED_ATOM( "diffuse", 7, UR_ATOM_DIFFUSE ); 1848 FIXED_ATOM( "specular", 8, UR_ATOM_SPECULAR ); 1849 FIXED_ATOM( "pos", 3, UR_ATOM_POS ); 1850 1846 1851 #if MAKE_ATOM_HEADER 1847 1852 exit(0); -
trunk/thune/gl/gx.t
r295 r296 95 95 call 96 96 solid 97 model 97 98 98 99 color … … 112 113 113 114 camera 114 unit-xform 115 light 116 lighting 117 ;unit-xform 115 118 push 116 119 pop -
trunk/thune/gl/test.t
r295 r296 106 106 ] 107 107 func :turntable 108 109 0 0 turntable 108 110 ] make :visual-cam 109 111 … … 166 168 draw-list [ 167 169 camera visual-cam 168 solid 170 light [on 1.0,0.8,1.0] 171 light/1 [on -1.0,-0.8,0.0 diffuse 0.8,0.5,0.5] 172 model 169 173 call d7-list 170 174 171 175 camera ortho-cam 176 lighting off 172 177 push 173 178 scale zoom
