Changeset 347 for trunk/thune/gl
- Timestamp:
- 01/20/07 05:28:58 (2 years ago)
- Location:
- trunk/thune/gl
- Files:
-
- 20 added
- 5 modified
-
data (added)
-
data/font (added)
-
data/image (added)
-
data/model (added)
-
data/shader (added)
-
data/shader/brick.gx (added)
-
data/shader/clsmap.gx (added)
-
data/shader/cmap_shadow.gx (added)
-
data/shader/colormap.gx (added)
-
data/shader/lh_specular.gx (added)
-
data/shader/lumimap.gx (added)
-
data/shader/matte.gx (added)
-
data/shader/partsphere.gx (added)
-
data/shader/specular.gx (added)
-
data/shader/specular_mat.gx (added)
-
draw_list.c (modified) (5 diffs)
-
gx.t (modified) (1 diff)
-
gx_atoms.h (modified) (1 diff)
-
gx_dt.c (modified) (6 diffs)
-
project.r (modified) (2 diffs)
-
scripts (added)
-
scripts/cloud.t (added)
-
scripts/fbo.t (added)
-
scripts/shadow.t (added)
-
scripts/view.t (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/thune/gl/draw_list.c
r331 r347 336 336 } 337 337 #endif 338 339 340 static GLfloat* _cameraMatrix = 0; 338 341 339 342 … … 384 387 if( ur_is(val, UT_VECTOR) && (ur_vectorDT(val) == UT_DECIMAL) ) 385 388 { 389 // glLoadTransposeMatrixf() could be used in GL 2.0? 386 390 GLfloat eye[16]; 387 391 UBinary* arr = ur_bin(val); 388 392 if( arr->used == 16 ) 389 393 { 394 _cameraMatrix = arr->ptr.f; 390 395 ur_matrixInverse( eye, arr->ptr.f ); 391 396 glLoadMatrixf( eye ); … … 484 489 485 490 #if 1 491 #define SHADOW_BACK_FACES 1 492 493 static GLdouble lightViewMatrix[ 16 ]; 494 static GLdouble lightProjMatrix[ 16 ]; 495 496 497 /* 498 Camera must be set up for light before calling shadow-begin. 499 */ 500 static void dop_shadow_begin( /*UThread* ur_thread,*/ UCell* fbCell ) 501 { 502 // Save matrices for shadow-end. 503 glGetDoublev( GL_MODELVIEW_MATRIX, lightViewMatrix ); 504 glGetDoublev( GL_PROJECTION_MATRIX, lightProjMatrix ); 505 506 507 glDepthMask( GL_TRUE ); 508 glEnable( GL_DEPTH_TEST ); 509 glDisable( GL_LIGHTING ); 510 glDisable( GL_BLEND ); 511 gr_disableTexture(); 512 513 514 glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, ur_fboId(fbCell) ); 515 glClear( GL_DEPTH_BUFFER_BIT ); 516 517 #ifdef SHADOW_BACK_FACES 518 glEnable( GL_CULL_FACE ); 519 glCullFace( GL_FRONT ); 520 #else 521 glEnable( GL_POLYGON_OFFSET_FILL ); 522 //glPolygonOffset( polygon_offset_scale, polygon_offset_bias ); 523 //glPolygonOffset( 2.0f, 10.0f ); 524 glPolygonOffset( 2.0f, 4.0f ); 525 #endif 526 } 527 528 486 529 // Transform from -1..1 to 0..1 487 530 const GLdouble bias[] = … … 492 535 0.5, 0.5, 0.5, 1.0 493 536 }; 494 495 496 GLdouble lightModelMatrix[ 16 ];497 GLdouble lightProjMatrix[ 16 ];498 499 //#define SHADOW_BACK_FACES 1500 501 static void dop_shadow_begin( /*UThread* ur_thread,*/ UCell* fbCell )502 {503 glGetDoublev( GL_MODELVIEW_MATRIX, lightModelMatrix );504 glGetDoublev( GL_PROJECTION_MATRIX, lightProjMatrix );505 506 507 glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, ur_fboId(fbCell) );508 glClear( GL_DEPTH_BUFFER_BIT );509 510 #ifdef SHADOW_BACK_FACES511 glEnable( GL_CULL_FACE );512 glCullFace( GL_FRONT );513 #else514 //glPolygonOffset( polygon_offset_scale, polygon_offset_bias );515 glPolygonOffset( 2.0f, 10.0f );516 //glPolygonOffset( 2.0f, 2.0f );517 glEnable( GL_POLYGON_OFFSET_FILL );518 #endif519 520 521 #if 0522 glMatrixMode( GL_TEXTURE );523 glLoadIdentity();524 glMatrixMode( GL_MODELVIEW );525 #endif526 527 }528 537 529 538 … … 538 547 539 548 540 //glActiveTextureARB(GL_TEXTURE1_ARB); 541 549 glActiveTextureARB( GL_TEXTURE1 ); 542 550 glMatrixMode( GL_TEXTURE ); 551 552 #if 1 543 553 glLoadMatrixd( bias ); 544 #if 0545 gluPerspective( fov, 1, near, far );546 554 #else 555 glLoadIdentity(); 556 #endif 547 557 glMultMatrixd( lightProjMatrix ); 548 glMultMatrixd( lightModelMatrix ); 549 #endif 558 glMultMatrixd( lightViewMatrix ); 559 //glMultMatrixf( _cameraMatrix ); 560 550 561 glMatrixMode( GL_MODELVIEW ); 551 552 //glActiveTextureARB(GL_TEXTURE0_ARB); 562 glActiveTextureARB( GL_TEXTURE0 ); 553 563 } 554 564 #endif -
trunk/thune/gl/gx.t
r331 r347 52 52 context :widget-proto 53 53 54 55 /* 56 [ 57 none :value 58 0.0 :time 59 'loop :repeat 60 none :curve 61 ] 62 context :anim-proto 63 64 [ 65 0.0,0,0 :p1 66 0.0,0,0 :p2 67 1.0 :radius 68 none :mesh 69 -1 :mask 70 [] :hits 71 ] 72 context :hit-input 73 */ 54 74 55 75 [ -
trunk/thune/gl/gx_atoms.h
r331 r347 1 1 // This file is automatically generated - do not edit. 2 2 3 #define UR_ATOM_DRAW_LIST_OPCODES 30 34 #define UR_ATOM_WIDTH 30 45 #define UR_ATOM_HEIGHT 30 56 #define UR_ATOM_AREA 3 067 #define UR_ATOM_RECT 3 078 #define UR_ATOM_RASTER 3 089 #define UR_ATOM_TEXTURE 3 0910 #define UR_ATOM_ELEM 31 011 #define UR_ATOM_CLOSE 17 112 #define UR_ATOM_FOCUS 31 113 #define UR_ATOM_RESIZE 31 214 #define UR_ATOM_KEY_DOWN 31 315 #define UR_ATOM_KEY_UP 31 416 #define UR_ATOM_MOUSE_MOVE 31 517 #define UR_ATOM_MOUSE_UP 3 1618 #define UR_ATOM_MOUSE_DOWN 3 1719 #define UR_ATOM_MOUSE_WHEEL 3 1820 #define UR_ATOM_AMBIENT 3 1921 #define UR_ATOM_DIFFUSE 32 022 #define UR_ATOM_SPECULAR 32 123 #define UR_ATOM_POS 32 224 #define UR_ATOM_SHADER 32 325 #define UR_ATOM_VERTEX 32 426 #define UR_ATOM_FRAGMENT 32 527 #define UR_ATOM_DEFAULT 3 2628 #define UR_ATOM_RGB 3 2729 #define UR_ATOM_RGBA 3 2830 #define UR_ATOM_DEPTH 3 2931 #define UR_ATOM_CLAMP 33 032 #define UR_ATOM_REPEAT 33 133 #define UR_ATOM_NEAREST 33 234 #define UR_ATOM_LINEAR 33 335 #define UR_ATOM_MIN 33 436 #define UR_ATOM_MAG 33 537 #define UR_ATOM_MIPMAP 3 3638 #define UR_ATOM_ON 2 4739 #define UR_ATOM_OFF 2 4940 #define UR_ATOM_ADD 19 041 #define UR_ATOM_BURN 3 3742 #define UR_ATOM_COLOR 3 3843 #define UR_ATOM_TRANS 3 393 #define UR_ATOM_DRAW_LIST_OPCODES 307 4 #define UR_ATOM_WIDTH 308 5 #define UR_ATOM_HEIGHT 309 6 #define UR_ATOM_AREA 310 7 #define UR_ATOM_RECT 311 8 #define UR_ATOM_RASTER 312 9 #define UR_ATOM_TEXTURE 313 10 #define UR_ATOM_ELEM 314 11 #define UR_ATOM_CLOSE 172 12 #define UR_ATOM_FOCUS 315 13 #define UR_ATOM_RESIZE 316 14 #define UR_ATOM_KEY_DOWN 317 15 #define UR_ATOM_KEY_UP 318 16 #define UR_ATOM_MOUSE_MOVE 319 17 #define UR_ATOM_MOUSE_UP 320 18 #define UR_ATOM_MOUSE_DOWN 321 19 #define UR_ATOM_MOUSE_WHEEL 322 20 #define UR_ATOM_AMBIENT 323 21 #define UR_ATOM_DIFFUSE 324 22 #define UR_ATOM_SPECULAR 325 23 #define UR_ATOM_POS 326 24 #define UR_ATOM_SHADER 327 25 #define UR_ATOM_VERTEX 328 26 #define UR_ATOM_FRAGMENT 329 27 #define UR_ATOM_DEFAULT 330 28 #define UR_ATOM_RGB 331 29 #define UR_ATOM_RGBA 332 30 #define UR_ATOM_DEPTH 333 31 #define UR_ATOM_CLAMP 334 32 #define UR_ATOM_REPEAT 335 33 #define UR_ATOM_NEAREST 336 34 #define UR_ATOM_LINEAR 337 35 #define UR_ATOM_MIN 338 36 #define UR_ATOM_MAG 339 37 #define UR_ATOM_MIPMAP 340 38 #define UR_ATOM_ON 250 39 #define UR_ATOM_OFF 252 40 #define UR_ATOM_ADD 191 41 #define UR_ATOM_BURN 341 42 #define UR_ATOM_COLOR 342 43 #define UR_ATOM_TRANS 343 -
trunk/thune/gl/gx_dt.c
r331 r347 240 240 241 241 242 struct TextureDef 242 typedef struct 243 243 { 244 244 const void* pixels; … … 250 250 GLint min_filter; 251 251 GLint mag_filter; 252 }; 253 254 255 static void _texRast( struct TextureDef* tex, const RasterHead* rh ) 252 } 253 TextureDef; 254 255 256 static void _texRast( TextureDef* tex, const RasterHead* rh ) 256 257 { 257 258 tex->width = rh->width; … … 280 281 281 282 282 static void _texCoord( structTextureDef* tex, const UCell* cell )283 static void _texCoord( TextureDef* tex, const UCell* cell ) 283 284 { 284 285 tex->width = cell->coord.elem[0]; … … 309 310 UR_CALL( make_texture ) 310 311 { 311 structTextureDef def;312 TextureDef def; 312 313 GLuint name; 313 314 int pool; … … 778 779 /* 779 780 (framebuffer! texture -- fbo) 781 (framebuffer! coord -- fbo) 780 782 */ 783 // (framebuffer! size 'shadow -- fbo) 781 784 UR_CALL( make_fbo ) 782 785 { 783 int pool; 784 GLuint name; 786 int fbPool; 787 int texPool; 788 GLuint fbName; 789 GLuint texName; 785 790 const char* err; 786 791 UCell* res = ur_s_prev(tos); … … 790 795 if( ur_is(tos, UT_TEXTURE) ) 791 796 { 792 name = glfbo_alloc( &pool ); 793 794 glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, name ); 795 796 glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, 797 GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, 798 ur_texId(tos), 0 ); 799 800 if( (err = _framebufferStatus()) ) 801 { 802 ur_throwErr( UR_ERR_INTERNAL, err ); 803 return; 804 } 805 806 glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0 ); 807 808 ur_initType( res, UT_FBO ); 809 ur_fboPool(res) = pool; 810 ur_fboId(res) = name; 811 ur_fboTexPool(res) = ur_texPool(tos); 812 ur_fboTexId(res) = ur_texId(tos); 813 814 UR_S_DROP; 815 return; 816 } 817 } 818 ur_throwErr( UR_ERR_DATATYPE, "framebuffer! make expected texture!" ); 797 fbName = glfbo_alloc( &fbPool ); 798 texName = ur_texId(tos); 799 texPool = ur_texPool(tos); 800 goto build; 801 } 802 else if( ur_is(tos, UT_COORD) ) 803 { 804 TextureDef def; 805 806 fbName = glfbo_alloc( &fbPool ); 807 808 _texCoord( &def, tos ); 809 810 texName = gltex_alloc( &texPool ); 811 glBindTexture( GL_TEXTURE_2D, texName ); 812 813 glTexImage2D( GL_TEXTURE_2D, 0, def.comp, def.width, def.height, 814 0, def.format, GL_UNSIGNED_BYTE, 0 ); 815 /* 816 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, def.wrap ); 817 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, def.wrap ); 818 */ 819 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); 820 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); 821 goto build; 822 } 823 /* 824 else if( ur_isAWord(tos) && (ur_atom(tos) == UR_ATOM_SHADOW) ) 825 { 826 } 827 */ 828 } 829 ur_throwErr( UR_ERR_DATATYPE, 830 "framebuffer! make expected texture!/coord!" ); 831 return; 832 833 build: 834 835 glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, fbName ); 836 837 glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, 838 GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, 839 texName, 0 ); 840 841 if( (err = _framebufferStatus()) ) 842 { 843 ur_throwErr( UR_ERR_INTERNAL, err ); 844 return; 845 } 846 847 glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0 ); 848 849 ur_initType( res, UT_FBO ); 850 ur_fboPool(res) = fbPool; 851 ur_fboId(res) = fbName; 852 ur_fboTexPool(res) = texPool; 853 ur_fboTexId(res) = texName; 854 855 UR_S_DROP; 819 856 } 820 857 -
trunk/thune/gl/project.r
r325 r347 10 10 include_from %. 11 11 include_from %.. 12 ;include_from %hit 12 13 ;include_from %../util 13 14 libs_from %.. %thune0 … … 89 90 %shader.c 90 91 ;%perlin.c 92 ;%hit/AABBTree.c 93 ;%hit/build_bbt.c 91 94 92 95 ;%noise.c
