Changeset 330 for trunk/thune/gl
- Timestamp:
- 01/02/07 02:19:55 (2 years ago)
- Location:
- trunk/thune/gl
- Files:
-
- 9 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/thune/gl/draw_list.c
r315 r330 487 487 488 488 489 #if 0489 #if 1 490 490 // Transform from -1..1 to 0..1 491 491 const GLdouble bias[] = … … 498 498 499 499 500 static void dop_shadowmap( /*UThread* ur_thread,*/ UCell* fbCell ) 501 { 500 GLdouble lightModelMatrix[ 16 ]; 501 GLdouble lightProjMatrix[ 16 ]; 502 503 //#define SHADOW_BACK_FACES 1 504 505 static void dop_shadow_begin( /*UThread* ur_thread,*/ UCell* fbCell ) 506 { 507 glGetDoublev( GL_MODELVIEW_MATRIX, lightModelMatrix ); 508 glGetDoublev( GL_PROJECTION_MATRIX, lightProjMatrix ); 509 510 502 511 glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, ur_fboId(fbCell) ); 503 glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); 504 512 glClear( GL_DEPTH_BUFFER_BIT ); 513 514 #ifdef SHADOW_BACK_FACES 515 glEnable( GL_CULL_FACE ); 516 glCullFace( GL_FRONT ); 517 #else 505 518 //glPolygonOffset( polygon_offset_scale, polygon_offset_bias ); 506 519 glPolygonOffset( 2.0f, 10.0f ); 520 //glPolygonOffset( 2.0f, 2.0f ); 507 521 glEnable( GL_POLYGON_OFFSET_FILL ); 522 #endif 523 524 525 #if 0 526 glMatrixMode( GL_TEXTURE ); 527 glLoadIdentity(); 528 glMatrixMode( GL_MODELVIEW ); 529 #endif 530 531 } 532 533 534 static void dop_shadow_end() 535 { 536 #ifdef SHADOW_BACK_FACES 537 glCullFace( GL_BACK ); 538 #else 539 glDisable( GL_POLYGON_OFFSET_FILL ); 540 #endif 541 glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0 ); 542 543 544 //glActiveTextureARB(GL_TEXTURE1_ARB); 508 545 509 546 glMatrixMode( GL_TEXTURE ); 510 547 glLoadMatrixd( bias ); 511 #if 1548 #if 0 512 549 gluPerspective( fov, 1, near, far ); 513 550 #else 514 glMultMatrixd( l ->get_proj_matrix());515 glMultMatrixd( l ->get_model_matrix());551 glMultMatrixd( lightProjMatrix ); 552 glMultMatrixd( lightModelMatrix ); 516 553 #endif 517 554 glMatrixMode( GL_MODELVIEW ); 518 } 519 520 521 static void dop_shadowmap_end() 522 { 523 glDisable( GL_POLYGON_OFFSET_FILL ); 524 glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0 ); 555 556 //glActiveTextureARB(GL_TEXTURE0_ARB); 525 557 } 526 558 #endif … … 876 908 glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0 ); 877 909 break; 878 #if 0 879 case DOP_SHADOW MAP:910 911 case DOP_SHADOW_BEGIN: 880 912 ++pc; 881 913 VAL_WORD_OR_PC 882 914 if( ur_is(val, UT_FBO) ) 883 dop_shadowmap( /*ur_thread,*/ val ); 884 else 885 dop_shadowmap_end(); 886 break; 887 #endif 915 dop_shadow_begin( /*ur_thread,*/ val ); 916 break; 917 918 case DOP_SHADOW_END: 919 dop_shadow_end(); 920 break; 921 888 922 default: 889 923 assert( 0 && "Invalid Draw List Opcode" ); -
trunk/thune/gl/draw_ops.h
r312 r330 32 32 #define DOP_SHADER 29 33 33 #define DOP_FRAMEBUFFER 30 34 #define DOP_SHADOWMAP 31 34 #define DOP_SHADOW_BEGIN 31 35 #define DOP_SHADOW_END 32 -
trunk/thune/gl/gx.c
r325 r330 1241 1241 ur_throwErr( UR_ERR_DATATYPE, "perlin expected raster! int! decimal!" ); 1242 1242 } 1243 #endif 1243 1244 1244 1245 … … 1259 1260 1260 1261 glGetIntegerv( GL_DEPTH_BITS, &depthBits ); 1261 printf( "KR depthBits %d\n", depthBits ); 1262 1263 // TODO: Hold texture! (return context?) 1262 //printf( "KR depthBits %d\n", depthBits ); 1263 1264 1264 texName = gltex_alloc( &texPool ); 1265 1265 glBindTexture( GL_TEXTURE_2D, texName ); … … 1290 1290 GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, texName, 0 ); 1291 1291 glDrawBuffer( GL_NONE ); 1292 //glReadBuffer( GL_FALSE );1292 glReadBuffer( GL_NONE ); 1293 1293 1294 1294 if( (err = _framebufferStatus()) ) … … 1300 1300 glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0 ); 1301 1301 1302 ur_initType( tos, UT_FBO ); 1303 ur_fboPool(tos) = fboPool; 1304 ur_fboId(tos) = fboName; 1302 ur_initType(tos, UT_FBO); 1303 ur_fboPool(tos) = fboPool; 1304 ur_fboId(tos) = fboName; 1305 ur_fboTexPool(tos) = texPool; 1306 ur_fboTexId(tos) = texName; 1305 1307 return; 1306 1308 } 1307 1309 ur_throwErr( UR_ERR_DATATYPE, "shadowmap expected coord!" ); 1308 1310 } 1309 #endif1310 1311 1311 1312 … … 1343 1344 { uc_gl_max_textures,"gl-max-textures" }, 1344 1345 //{ uc_perlin, "perlin" }, 1345 //{ uc_shadowmap, "shadowmap" }1346 { uc_shadowmap, "shadowmap" } 1346 1347 }; 1347 1348 … … 1370 1371 FIXED_ATOM( "rect", 4, UR_ATOM_RECT ) 1371 1372 FIXED_ATOM( "raster", 6, UR_ATOM_RASTER ) 1373 FIXED_ATOM( "texture", 7, UR_ATOM_TEXTURE ) 1372 1374 FIXED_ATOM( "elem", 4, UR_ATOM_ELEM ) 1373 1375 FIXED_ATOM( "close", 5, UR_ATOM_CLOSE ) -
trunk/thune/gl/gx.h
r321 r330 67 67 uint8_t type; 68 68 uint8_t flags; 69 uint16_t glTex IdPool;69 uint16_t glTexPool; 70 70 UIndex rasterN; // Raster binary 71 71 UIndex fontN; // TexFont binary … … 76 76 77 77 typedef UCellRasterFont UCellTexture; 78 79 80 typedef struct 81 { 82 uint8_t type; 83 uint8_t flags; 84 uint16_t glTexPool; 85 uint16_t glFboPool; 86 uint16_t _pad; 87 GLuint glFboId; 88 GLuint glTexId; 89 } 90 UCellFramebuffer; 78 91 79 92 … … 173 186 #define ur_fontTF(c) ((UCellRasterFont*) (c))->fontN 174 187 #define ur_fontTexId(c) ((UCellRasterFont*) (c))->glTexId 188 #define ur_fontTexPool(c) ((UCellRasterFont*) (c))->glTexPool 175 189 176 190 #define ur_texRast(c) ((UCellTexture*) (c))->rasterN 177 191 #define ur_texId(c) ((UCellTexture*) (c))->glTexId 178 #define ur_texPool(c) ((UCellTexture*) (c))->glTexIdPool 179 180 #define ur_fboId(c) ((UCellTexture*) (c))->glTexId 181 #define ur_fboPool(c) ((UCellTexture*) (c))->glTexIdPool 192 #define ur_texPool(c) ((UCellTexture*) (c))->glTexPool 193 194 #define ur_fboId(c) ((UCellFramebuffer*) (c))->glFboId 195 #define ur_fboPool(c) ((UCellFramebuffer*) (c))->glFboPool 196 #define ur_fboTexId(c) ((UCellFramebuffer*) (c))->glTexId 197 #define ur_fboTexPool(c) ((UCellFramebuffer*) (c))->glTexPool 182 198 183 199 -
trunk/thune/gl/gx.t
r325 r330 135 135 shader 136 136 framebuffer 137 shadowmap 137 shadow-begin 138 shadow-end 138 139 ] 139 140 make-opcodes :draw-list-opcodes -
trunk/thune/gl/gx_atoms.h
r311 r330 6 6 #define UR_ATOM_RECT 306 7 7 #define UR_ATOM_RASTER 307 8 #define UR_ATOM_ELEM 308 8 #define UR_ATOM_TEXTURE 308 9 #define UR_ATOM_ELEM 309 9 10 #define UR_ATOM_CLOSE 171 10 #define UR_ATOM_FOCUS 3 0911 #define UR_ATOM_RESIZE 31 012 #define UR_ATOM_KEY_DOWN 31 113 #define UR_ATOM_KEY_UP 31 214 #define UR_ATOM_MOUSE_MOVE 31 315 #define UR_ATOM_MOUSE_UP 31 416 #define UR_ATOM_MOUSE_DOWN 31 517 #define UR_ATOM_MOUSE_WHEEL 31 618 #define UR_ATOM_AMBIENT 31 719 #define UR_ATOM_DIFFUSE 31 820 #define UR_ATOM_SPECULAR 3 1921 #define UR_ATOM_POS 32 022 #define UR_ATOM_SHADER 32 123 #define UR_ATOM_VERTEX 32 224 #define UR_ATOM_FRAGMENT 32 325 #define UR_ATOM_DEFAULT 32 426 #define UR_ATOM_RGB 32 527 #define UR_ATOM_RGBA 32 628 #define UR_ATOM_DEPTH 32 729 #define UR_ATOM_CLAMP 32 830 #define UR_ATOM_REPEAT 3 2931 #define UR_ATOM_NEAREST 33 032 #define UR_ATOM_LINEAR 33 133 #define UR_ATOM_MIN 33 234 #define UR_ATOM_MAG 33 335 #define UR_ATOM_MIPMAP 33 411 #define UR_ATOM_FOCUS 310 12 #define UR_ATOM_RESIZE 311 13 #define UR_ATOM_KEY_DOWN 312 14 #define UR_ATOM_KEY_UP 313 15 #define UR_ATOM_MOUSE_MOVE 314 16 #define UR_ATOM_MOUSE_UP 315 17 #define UR_ATOM_MOUSE_DOWN 316 18 #define UR_ATOM_MOUSE_WHEEL 317 19 #define UR_ATOM_AMBIENT 318 20 #define UR_ATOM_DIFFUSE 319 21 #define UR_ATOM_SPECULAR 320 22 #define UR_ATOM_POS 321 23 #define UR_ATOM_SHADER 322 24 #define UR_ATOM_VERTEX 323 25 #define UR_ATOM_FRAGMENT 324 26 #define UR_ATOM_DEFAULT 325 27 #define UR_ATOM_RGB 326 28 #define UR_ATOM_RGBA 327 29 #define UR_ATOM_DEPTH 328 30 #define UR_ATOM_CLAMP 329 31 #define UR_ATOM_REPEAT 330 32 #define UR_ATOM_NEAREST 331 33 #define UR_ATOM_LINEAR 332 34 #define UR_ATOM_MIN 333 35 #define UR_ATOM_MAG 334 36 #define UR_ATOM_MIPMAP 335 36 37 #define UR_ATOM_ON 247 37 38 #define UR_ATOM_OFF 249 38 39 #define UR_ATOM_ADD 190 39 #define UR_ATOM_BURN 33 540 #define UR_ATOM_COLOR 33 641 #define UR_ATOM_TRANS 33 740 #define UR_ATOM_BURN 336 41 #define UR_ATOM_COLOR 337 42 #define UR_ATOM_TRANS 338 -
trunk/thune/gl/gx_dt.c
r321 r330 485 485 static void mark_texture( UCollector* gc, UCell* cell ) 486 486 { 487 UCellTexture* tc = (UCellTexture*) cell; 488 ur_gcMarkBin( gc, tc->rasterN ); 489 gltex_gcMark( tc->glTexIdPool, tc->glTexId ); 487 ur_gcMarkBin( gc, ur_texRast(cell) ); 488 gltex_gcMark( ur_texPool(cell), ur_texId(cell) ); 490 489 } 491 490 … … 570 569 { 571 570 case UR_ATOM_RASTER: 572 {573 UCellRasterFont* fc = (UCellRasterFont*) val;574 571 ur_initType(res, UT_RASTER); 575 ur_setSeries(res, fc->rasterN, 0); 576 } 572 ur_setSeries(res, ur_fontRast(val), 0); 573 break; 574 575 case UR_ATOM_TEXTURE: 576 ur_initType(res, UT_TEXTURE); 577 ur_texPool(res) = ur_fontTexPool(val); 578 ur_texId(res) = ur_fontTexId(val); 579 ur_texRast(res) = ur_fontRast(val); 577 580 break; 578 581 … … 588 591 { 589 592 UCellRasterFont* fc = (UCellRasterFont*) cell; 590 ur_gcMarkBin( gc, fc->rasterN ); 591 ur_gcMarkBin( gc, fc->fontN ); 592 //gltexture_gcMark( fc->glTexIdPool, fc->glTexId ); 593 if( fc->rasterN ) 594 ur_gcMarkBin( gc, fc->rasterN ); 595 if( fc->fontN ) 596 ur_gcMarkBin( gc, fc->fontN ); 597 gltex_gcMark( fc->glTexPool, fc->glTexId ); 593 598 } 594 599 … … 775 780 776 781 ur_initType( res, UT_FBO ); 777 ur_fboPool(res) = pool; 778 ur_fboId(res) = name; 782 ur_fboPool(res) = pool; 783 ur_fboId(res) = name; 784 ur_fboTexPool(res) = ur_texPool(tos); 785 ur_fboTexId(res) = ur_texId(tos); 779 786 780 787 UR_S_DROP; … … 794 801 795 802 803 static int select_fbo( UThread* ur_thread, UCell* val, const UCell* sel, 804 UCell* res ) 805 { 806 switch( ur_sel(sel) ) 807 { 808 /* 809 case UR_ATOM_RASTER: 810 ur_initType(res, UT_RASTER); 811 ur_setSeries(res, ur_fontRast(val), 0); 812 break; 813 */ 814 815 case UR_ATOM_TEXTURE: 816 ur_initType(res, UT_TEXTURE); 817 ur_texPool(res) = ur_fboTexPool(val); 818 ur_texId(res) = ur_fboTexId(val); 819 ur_texRast(res) = 0; 820 break; 821 822 default: 823 ur_throwErr( UR_ERR_SCRIPT, "Invalid select!" ); 824 return 0; 825 } 826 return 1; 827 } 828 829 796 830 static void mark_fbo( UCollector* gc, UCell* cell ) 797 831 { 798 832 (void) gc; 799 833 glfbo_gcMark( ur_fboPool(cell), ur_fboId(cell) ); 834 gltex_gcMark( ur_fboTexPool(cell), ur_fboTexId(cell) ); 800 835 } 801 836 … … 857 892 {"framebuffer!", 0, 0, 858 893 make_fbo, to_nop, toStr_fbo, toStr_fbo, 859 select_ nop, recycle_nop, mark_fbo, rmres_nop },894 select_fbo, recycle_nop, mark_fbo, rmres_nop }, 860 895 }; 861 896 -
trunk/thune/gl/rfont.c
r321 r330 12 12 #include "gx.h" 13 13 #include "rfont.h" 14 15 16 static GLuint buildFontTexture( RasterHead* img ) 14 #include "gltex.h" 15 16 17 static void buildFontTexture( RasterHead* img, GLuint id ) 17 18 { 18 GLuint id;19 19 GLenum format; 20 20 GLint comp; … … 40 40 41 41 default: 42 return 0; 43 } 44 45 glGenTextures( 1, &id ); 42 return; 43 } 44 46 45 glBindTexture( GL_TEXTURE_2D, id ); 47 46 … … 76 75 77 76 glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); 78 79 return id;80 77 } 81 78 … … 101 98 { 102 99 #define ENV ur_thread->env 100 UIndex rastN; 103 101 UIndex binN; 104 102 UIndex hold; … … 114 112 cfg->pointSize = 100; 115 113 116 binN = ur_makeRaster( res, UR_RAST_GRAY, cfg->texW, cfg->texH, &bin );114 rastN = ur_makeRaster( res, UR_RAST_GRAY, cfg->texW, cfg->texH, &bin ); 117 115 if( bin->ptr.b ) 118 116 { 119 hold = ur_hold( ENV, UT_BINARY, binN );117 hold = ur_hold( ENV, UT_BINARY, rastN ); 120 118 121 119 fbm.width = cfg->texW; … … 135 133 TexGlyphInfo** src; 136 134 TexGlyphInfo** end; 137 138 // TODO: Track & delete texture.139 ur_fontTexId(res) = buildFontTexture( (RasterHead*) bin->ptr.v );140 135 141 136 … … 178 173 179 174 175 { 176 int texPool; 177 GLuint texId; 178 179 texId = gltex_alloc( &texPool ); 180 bin = ur_binPtr( rastN ); 181 buildFontTexture( (RasterHead*) bin->ptr.v, texId ); 182 183 // Should ditch raster? 184 180 185 ur_initType( res, UT_FONT ); 181 ur_fontTF(res) = binN; 186 //ur_fontRast(res) = // Already set by ur_makeRaster(). 187 ur_fontTF(res) = binN; 188 ur_fontTexId(res) = texId; 189 ur_fontTexPool(res) = texPool; 190 } 182 191 183 192 ok = 1; -
trunk/thune/gl/test_fw.t
r310 r330 76 76 key-down [ 77 77 esc [quit] 78 f10 [display.snapshot "snapshot.png" save.png] 78 79 ] 79 80
