Viewport、CustomRenderTarget、VertexBuffer追加。1.5.21dev
@@ -22,8 +22,12 @@ | ||
22 | 22 | VALUE eDXRubyError; /* 例外 */ |
23 | 23 | VALUE mWindow; /* ウィンドウモジュール */ |
24 | 24 | VALUE cRenderTarget; /* レンダーターゲットクラス */ |
25 | +VALUE cCustomRenderTarget; /* カスタムレンダーターゲットクラス */ | |
26 | +VALUE cViewport; /* ビューポートクラス */ | |
25 | 27 | VALUE cShaderCore; /* シェーダコアクラス */ |
26 | -VALUE cShader; /* シェーダクラス */ | |
28 | +VALUE cShader; /* シェーダクラス */ | |
29 | +VALUE mLowLevelInterface; /* 低レベルインターフェイスモジュール */ | |
30 | +VALUE cVertexBuffer; /* 頂点バッファクラス */ | |
27 | 31 | |
28 | 32 | extern VALUE cImage; |
29 | 33 |
@@ -142,6 +146,8 @@ | ||
142 | 146 | VALUE symbol_discard = Qundef; |
143 | 147 | VALUE symbol_aa = Qundef; |
144 | 148 | VALUE symbol_call = Qundef; |
149 | +VALUE symbol_update = Qundef; | |
150 | +VALUE symbol_custom_render = Qundef; | |
145 | 151 | |
146 | 152 | /* プロトタイプ宣言 */ |
147 | 153 | static void InitWindow( void ); |
@@ -566,14 +572,6 @@ | ||
566 | 572 | if( g_RenderTargetList.pointer[i] ) |
567 | 573 | { |
568 | 574 | struct DXRubyRenderTarget *rt = (struct DXRubyRenderTarget *)g_RenderTargetList.pointer[i]; |
569 | -#ifdef DXRUBY15 | |
570 | - // 再生成Procが設定されている場合 | |
571 | - if( rt->vregenerate_proc != Qnil ) | |
572 | - { | |
573 | - rb_funcall( rt->vregenerate_proc, SYM2ID( symbol_call ), 0 ); | |
574 | - rt->clearflag = 0; | |
575 | - } | |
576 | -#endif | |
577 | 575 | } |
578 | 576 | } |
579 | 577 | } |
@@ -754,9 +752,6 @@ | ||
754 | 752 | free( rt->PictureList ); |
755 | 753 | free( rt->PictureStruct ); |
756 | 754 | rt->PictureCount = 0; |
757 | -#ifdef DXRUBY15 | |
758 | - rt->vregenerate_proc = Qnil; | |
759 | -#endif | |
760 | 755 | ExitMessageThread(); |
761 | 756 | |
762 | 757 | /* マウスカーソルを戻す */ |
@@ -779,7 +774,7 @@ | ||
779 | 774 | { |
780 | 775 | if( !g_WindowInfo.created ) |
781 | 776 | { |
782 | - rb_raise( eDXRubyError, "ウィンドウ作成前に実行することはできません - Window_running_time" ); | |
777 | + return rb_float_new( 0.0 ); | |
783 | 778 | } |
784 | 779 | |
785 | 780 | return rb_float_new( g_RunningTime * 1000.0 / g_OneSecondCount ); |
@@ -867,7 +862,7 @@ | ||
867 | 862 | { |
868 | 863 | if( g_WindowInfo.created ) |
869 | 864 | { |
870 | - rb_raise( eDXRubyError, "ウィンドウ作成後に設定を変更することはできません - Window_setx" ); | |
865 | + rb_raise( eDXRubyError, "It is not possible to change the setting after window creation. - Window_setx" ); | |
871 | 866 | } |
872 | 867 | |
873 | 868 | g_WindowInfo.x = NUM2INT( x ); |
@@ -882,7 +877,7 @@ | ||
882 | 877 | { |
883 | 878 | if( g_WindowInfo.created ) |
884 | 879 | { |
885 | - rb_raise( eDXRubyError, "ウィンドウ作成後に設定を変更することはできません - Window_sety" ); | |
880 | + rb_raise( eDXRubyError, "It is not possible to change the setting after window creation. - Window_sety" ); | |
886 | 881 | } |
887 | 882 | |
888 | 883 | g_WindowInfo.y = NUM2INT( y ); |
@@ -899,7 +894,7 @@ | ||
899 | 894 | |
900 | 895 | if( g_WindowInfo.created ) |
901 | 896 | { |
902 | - rb_raise( eDXRubyError, "ウィンドウ作成後に設定を変更することはできません - Window_setwidth" ); | |
897 | + rb_raise( eDXRubyError, "It is not possible to change the setting after window creation. - Window_setwidth" ); | |
903 | 898 | } |
904 | 899 | |
905 | 900 | width = NUM2INT( vwidth ); |
@@ -922,7 +917,7 @@ | ||
922 | 917 | |
923 | 918 | if( g_WindowInfo.created ) |
924 | 919 | { |
925 | - rb_raise( eDXRubyError, "ウィンドウ作成後に設定を変更することはできません - Window_setheight" ); | |
920 | + rb_raise( eDXRubyError, "It is not possible to change the setting after window creation. - Window_setheight" ); | |
926 | 921 | } |
927 | 922 | |
928 | 923 | height = NUM2INT( vheight ); |
@@ -1790,33 +1785,6 @@ | ||
1790 | 1785 | } |
1791 | 1786 | |
1792 | 1787 | |
1793 | -#ifdef DXRUBY15 | |
1794 | -/*-------------------------------------------------------------------- | |
1795 | - デバイスロストのような動作を再現するテストメソッド | |
1796 | - ---------------------------------------------------------------------*/ | |
1797 | -static VALUE Window_test_device_lost( VALUE obj ) | |
1798 | -{ | |
1799 | - int i; | |
1800 | - | |
1801 | - for( i = 0; i < g_RenderTargetList.count; i++ ) | |
1802 | - { | |
1803 | - struct DXRubyRenderTarget *rt = (struct DXRubyRenderTarget *)g_RenderTargetList.pointer[i]; | |
1804 | - g_pD3DDevice->lpVtbl->SetRenderTarget( g_pD3DDevice, 0, rt->surface ); | |
1805 | - g_pD3DDevice->lpVtbl->Clear( g_pD3DDevice, 0, NULL, D3DCLEAR_TARGET, | |
1806 | - D3DCOLOR_ARGB( 255, 0, 0, 0 ), 1.0f, 0 ); | |
1807 | - | |
1808 | - // 再生成Procが設定されている場合 | |
1809 | - if( rt->vregenerate_proc != Qnil ) | |
1810 | - { | |
1811 | - rb_funcall( rt->vregenerate_proc, SYM2ID( symbol_call ), 0 ); | |
1812 | - } | |
1813 | - } | |
1814 | - | |
1815 | - return Qnil; | |
1816 | -} | |
1817 | -#endif | |
1818 | - | |
1819 | - | |
1820 | 1788 | /********************************************************************* |
1821 | 1789 | * ShaderCoreクラス |
1822 | 1790 | * |
@@ -1931,7 +1899,7 @@ | ||
1931 | 1899 | |
1932 | 1900 | /* DXRubyShaderCoreのメモリ取得&ShaderCoreオブジェクト生成 */ |
1933 | 1901 | core = malloc( sizeof( struct DXRubyShaderCore ) ); |
1934 | - if( core == NULL ) rb_raise( eDXRubyError, "メモリの取得に失敗しました - ShaderCore_allocate" ); | |
1902 | + if( core == NULL ) rb_raise( eDXRubyError, "Memory allocate error. - ShaderCore_allocate" ); | |
1935 | 1903 | #ifdef DXRUBY_USE_TYPEDDATA |
1936 | 1904 | obj = TypedData_Wrap_Struct( klass, &ShaderCore_data_type, core ); |
1937 | 1905 | #else |
@@ -2041,7 +2009,7 @@ | ||
2041 | 2009 | |
2042 | 2010 | /* DXRubyShaderのメモリ取得&ShaderCoreオブジェクト生成 */ |
2043 | 2011 | shader = malloc( sizeof( struct DXRubyShader ) ); |
2044 | - if( shader == NULL ) rb_raise( eDXRubyError, "メモリの取得に失敗しました - Shader_allocate" ); | |
2012 | + if( shader == NULL ) rb_raise( eDXRubyError, "Memory allocate error. - Shader_allocate" ); | |
2045 | 2013 | #ifdef DXRUBY_USE_TYPEDDATA |
2046 | 2014 | obj = TypedData_Wrap_Struct( klass, &Shader_data_type, shader ); |
2047 | 2015 | #else |
@@ -2137,6 +2105,151 @@ | ||
2137 | 2105 | |
2138 | 2106 | |
2139 | 2107 | /********************************************************************* |
2108 | + * Viewportクラス | |
2109 | + * | |
2110 | + * 描画のクリッピングをするためのクラス。 | |
2111 | + * RenderTargetと同様の使い方をする。 | |
2112 | + *********************************************************************/ | |
2113 | + | |
2114 | +/*-------------------------------------------------------------------- | |
2115 | + 参照されなくなったときにGCから呼ばれる関数 | |
2116 | + ---------------------------------------------------------------------*/ | |
2117 | +static void Viewport_free( struct DXRubyViewport *vp ) | |
2118 | +{ | |
2119 | + free( vp->PictureList ); | |
2120 | + free( vp->PictureStruct ); | |
2121 | + vp->PictureCount = 0; | |
2122 | + vp->PictureSize = 0; | |
2123 | + vp->PictureDecideCount = 0; | |
2124 | + vp->PictureDecideSize = 0; | |
2125 | +} | |
2126 | + | |
2127 | +void Viewport_release( struct DXRubyViewport *vp ) | |
2128 | +{ | |
2129 | + free( vp ); | |
2130 | + vp = NULL; | |
2131 | +} | |
2132 | + | |
2133 | +/*-------------------------------------------------------------------- | |
2134 | + Viewportクラスのmark | |
2135 | + ---------------------------------------------------------------------*/ | |
2136 | +static void Viewport_mark( struct DXRubyViewport *vp ) | |
2137 | +{ | |
2138 | + int i; | |
2139 | + | |
2140 | + for( i = 0; i < vp->PictureCount; i++ ) | |
2141 | + { | |
2142 | + rb_gc_mark( vp->PictureList[i].picture->value ); | |
2143 | + } | |
2144 | +} | |
2145 | + | |
2146 | +#ifdef DXRUBY_USE_TYPEDDATA | |
2147 | +const rb_data_type_t Viewport_data_type = { | |
2148 | + "Viewport", | |
2149 | + { | |
2150 | + Viewport_mark, | |
2151 | + Viewport_release, | |
2152 | + 0, | |
2153 | + }, | |
2154 | + NULL, NULL | |
2155 | +}; | |
2156 | +#endif | |
2157 | + | |
2158 | +/*-------------------------------------------------------------------- | |
2159 | + Viewportクラスのallocate。メモリを確保する為にinitialize前に呼ばれる。 | |
2160 | + ---------------------------------------------------------------------*/ | |
2161 | +static VALUE Viewport_allocate( VALUE klass ) | |
2162 | +{ | |
2163 | + VALUE obj; | |
2164 | + struct DXRubyViewport *vp; | |
2165 | + | |
2166 | + /* DXRubyViewportのメモリ取得&Viewportオブジェクト生成 */ | |
2167 | + vp = malloc(sizeof(struct DXRubyViewport)); | |
2168 | + if( vp == NULL ) rb_raise( eDXRubyError, "Memory allocate error. - Viewport_allocate" ); | |
2169 | +#ifdef DXRUBY_USE_TYPEDDATA | |
2170 | + obj = TypedData_Wrap_Struct( klass, &Viewport_data_type, vp ); | |
2171 | +#else | |
2172 | + obj = Data_Wrap_Struct(klass, Viewport_mark, Viewport_release, vp); | |
2173 | +#endif | |
2174 | + /* とりあえずテクスチャオブジェクトはNULLにしておく */ | |
2175 | + vp->texture = NULL; | |
2176 | + | |
2177 | + /* ピクチャ構造体の初期値設定 */ | |
2178 | + vp->PictureCount = 0; | |
2179 | + vp->PictureAllocateCount = 128; | |
2180 | + vp->PictureSize = 0; | |
2181 | + vp->PictureAllocateSize = 128*32; | |
2182 | + vp->PictureList = malloc( vp->PictureAllocateCount * sizeof(struct DXRubyPictureList) ); | |
2183 | + vp->PictureStruct = malloc( vp->PictureAllocateSize ); | |
2184 | + vp->PictureDecideCount = 0; | |
2185 | + vp->PictureDecideSize = 0; | |
2186 | + | |
2187 | + vp->ox = 0; | |
2188 | + vp->oy = 0; | |
2189 | + | |
2190 | + return obj; | |
2191 | +} | |
2192 | + | |
2193 | + | |
2194 | +/*-------------------------------------------------------------------- | |
2195 | + ViewportクラスのInitialize | |
2196 | + ---------------------------------------------------------------------*/ | |
2197 | +static VALUE Viewport_initialize( int argc, VALUE *argv, VALUE self ) | |
2198 | +{ | |
2199 | + struct DXRubyViewport *vp = DXRUBY_GET_STRUCT( Viewport, self ); | |
2200 | + VALUE vwidth, vheight; | |
2201 | + int width, height; | |
2202 | + | |
2203 | + rb_scan_args( argc, argv, "20", &vwidth, &vheight ); | |
2204 | + | |
2205 | + width = NUM2INT( vwidth ); | |
2206 | + height = NUM2INT( vheight ); | |
2207 | + | |
2208 | + if( width <= 0 || height <= 0 ) | |
2209 | + { | |
2210 | + rb_raise( eDXRubyError, "Failed to create Viewport object - Viewport_initialize" ); | |
2211 | + } | |
2212 | + | |
2213 | + vp->x = 0; | |
2214 | + vp->y = 0; | |
2215 | + vp->width = width; | |
2216 | + vp->height = height; | |
2217 | + | |
2218 | + return self; | |
2219 | +} | |
2220 | + | |
2221 | + | |
2222 | +/*-------------------------------------------------------------------- | |
2223 | + ViewportクラスのResize | |
2224 | + ---------------------------------------------------------------------*/ | |
2225 | +static VALUE Viewport_resize( VALUE self, VALUE vwidth, VALUE vheight ) | |
2226 | +{ | |
2227 | + struct DXRubyViewport *vp = DXRUBY_GET_STRUCT( Viewport, self ); | |
2228 | + HRESULT hr; | |
2229 | + int width, height; | |
2230 | + | |
2231 | + width = NUM2INT( vwidth ); | |
2232 | + height = NUM2INT( vheight ); | |
2233 | + | |
2234 | + if( width <= 0 || height <= 0 ) | |
2235 | + { | |
2236 | + rb_raise( eDXRubyError, "Failed to create Viewport object - Viewport_resize" ); | |
2237 | + } | |
2238 | + | |
2239 | + vp->x = 0; | |
2240 | + vp->y = 0; | |
2241 | + vp->width = width; | |
2242 | + vp->height = height; | |
2243 | + vp->PictureCount = 0; | |
2244 | + vp->PictureSize = 0; | |
2245 | + vp->PictureDecideCount = 0; | |
2246 | + vp->PictureDecideSize = 0; | |
2247 | + | |
2248 | + return self; | |
2249 | +} | |
2250 | + | |
2251 | + | |
2252 | +/********************************************************************* | |
2140 | 2253 | * RenderTargetクラス |
2141 | 2254 | * |
2142 | 2255 | * レンダーターゲットになれるImageクラス。 |
@@ -2210,9 +2323,6 @@ | ||
2210 | 2323 | rt->PictureSize = 0; |
2211 | 2324 | rt->PictureDecideCount = 0; |
2212 | 2325 | rt->PictureDecideSize = 0; |
2213 | -#ifdef DXRUBY15 | |
2214 | - rt->vregenerate_proc = Qnil; | |
2215 | -#endif | |
2216 | 2326 | } |
2217 | 2327 | |
2218 | 2328 | void RenderTarget_release( struct DXRubyRenderTarget *rt ) |
@@ -2243,10 +2353,6 @@ | ||
2243 | 2353 | { |
2244 | 2354 | rb_gc_mark( rt->PictureList[i].picture->value ); |
2245 | 2355 | } |
2246 | - | |
2247 | -#ifdef DXRUBY15 | |
2248 | - rb_gc_mark( rt->vregenerate_proc ); | |
2249 | -#endif | |
2250 | 2356 | } |
2251 | 2357 | |
2252 | 2358 | #ifdef DXRUBY_USE_TYPEDDATA |
@@ -2293,8 +2399,9 @@ | ||
2293 | 2399 | if( DXRUBY_CHECK( RenderTarget, vrt ) ) |
2294 | 2400 | { |
2295 | 2401 | struct DXRubyRenderTarget *src_rt = DXRUBY_GET_STRUCT( RenderTarget, vrt ); |
2402 | + int customflag = RTEST(rb_obj_is_kind_of(vrt, cCustomRenderTarget)); | |
2296 | 2403 | |
2297 | - if( src_rt->clearflag == 0 && src_rt->PictureCount == 0 ) | |
2404 | + if( src_rt->clearflag == 0 && src_rt->PictureCount == 0 && !customflag ) | |
2298 | 2405 | { |
2299 | 2406 | g_pD3DDevice->lpVtbl->SetRenderTarget( g_pD3DDevice, 0, src_rt->surface ); |
2300 | 2407 | g_pD3DDevice->lpVtbl->Clear( g_pD3DDevice, 0, NULL, D3DCLEAR_TARGET, |
@@ -2301,9 +2408,9 @@ | ||
2301 | 2408 | D3DCOLOR_ARGB( src_rt->a, src_rt->r, src_rt->g, src_rt->b ), 1.0f, 0 ); |
2302 | 2409 | src_rt->clearflag = 1; |
2303 | 2410 | } |
2304 | - else if( src_rt->PictureCount > 0 ) | |
2411 | + else if( src_rt->PictureCount > 0 || customflag ) | |
2305 | 2412 | { |
2306 | - RenderTarget_update( vrt ); | |
2413 | + rb_funcall( vrt, SYM2ID( symbol_update ), 0 ); | |
2307 | 2414 | } |
2308 | 2415 | } |
2309 | 2416 | } |
@@ -2318,7 +2425,7 @@ | ||
2318 | 2425 | |
2319 | 2426 | /* DXRubyRenderTargetのメモリ取得&RenderTargetオブジェクト生成 */ |
2320 | 2427 | rt = malloc(sizeof(struct DXRubyRenderTarget)); |
2321 | - if( rt == NULL ) rb_raise( eDXRubyError, "メモリの取得に失敗しました - RenderTarget_allocate" ); | |
2428 | + if( rt == NULL ) rb_raise( eDXRubyError, "Memory allocate error. - RenderTarget_allocate" ); | |
2322 | 2429 | #ifdef DXRUBY_USE_TYPEDDATA |
2323 | 2430 | obj = TypedData_Wrap_Struct( klass, &RenderTarget_data_type, rt ); |
2324 | 2431 | #else |
@@ -2345,15 +2452,10 @@ | ||
2345 | 2452 | rt->r = 0; |
2346 | 2453 | rt->g = 0; |
2347 | 2454 | rt->b = 0; |
2348 | -#ifdef DXRUBY15 | |
2349 | - rt->vregenerate_proc = Qnil; | |
2350 | -#endif | |
2351 | 2455 | rt->clearflag = 0; |
2352 | 2456 | rt->ox = 0; |
2353 | 2457 | rt->oy = 0; |
2354 | 2458 | |
2355 | -// rt->lockcount = 0; | |
2356 | - | |
2357 | 2459 | return obj; |
2358 | 2460 | } |
2359 | 2461 |
@@ -2387,7 +2489,7 @@ | ||
2387 | 2489 | |
2388 | 2490 | if( texture == NULL ) |
2389 | 2491 | { |
2390 | - rb_raise( eDXRubyError, "画像用メモリの取得に失敗しました - RenderTarget_initialize" ); | |
2492 | + rb_raise( eDXRubyError, "画像用Memory allocate error. - RenderTarget_initialize" ); | |
2391 | 2493 | } |
2392 | 2494 | |
2393 | 2495 | DXRUBY_RETRY_START; |
@@ -2518,17 +2620,7 @@ | ||
2518 | 2620 | DXRUBY_CHECK_DISPOSE( rt, surface ); |
2519 | 2621 | |
2520 | 2622 | /* 描画予約があればupdateする */ |
2521 | - if( rt->clearflag == 0 && rt->PictureCount == 0 ) | |
2522 | - { | |
2523 | - g_pD3DDevice->lpVtbl->SetRenderTarget( g_pD3DDevice, 0, rt->surface ); | |
2524 | - g_pD3DDevice->lpVtbl->Clear( g_pD3DDevice, 0, NULL, D3DCLEAR_TARGET, | |
2525 | - D3DCOLOR_ARGB( rt->a, rt->r, rt->g, rt->b ), 1.0f, 0 ); | |
2526 | - rt->clearflag = 1; | |
2527 | - } | |
2528 | - else if( rt->PictureCount > 0 ) | |
2529 | - { | |
2530 | - RenderTarget_update( self ); | |
2531 | - } | |
2623 | + RenderTerget_auto_update( self ); | |
2532 | 2624 | |
2533 | 2625 | vimage = Image_allocate( cImage ); |
2534 | 2626 | ary[0] = INT2FIX( rt->width ); |
@@ -2591,7 +2683,10 @@ | ||
2591 | 2683 | static VALUE RenderTarget_getWidth( VALUE self ) |
2592 | 2684 | { |
2593 | 2685 | struct DXRubyRenderTarget *rt = DXRUBY_GET_STRUCT( RenderTarget, self ); |
2594 | - DXRUBY_CHECK_DISPOSE( rt, surface ); | |
2686 | + if( !DXRUBY_CHECK( Viewport, self ) ) | |
2687 | + { | |
2688 | + DXRUBY_CHECK_DISPOSE( rt, surface ); | |
2689 | + } | |
2595 | 2690 | return INT2FIX( rt->width ); |
2596 | 2691 | } |
2597 | 2692 |
@@ -2602,7 +2697,10 @@ | ||
2602 | 2697 | static VALUE RenderTarget_getHeight( VALUE self ) |
2603 | 2698 | { |
2604 | 2699 | struct DXRubyRenderTarget *rt = DXRUBY_GET_STRUCT( RenderTarget, self ); |
2605 | - DXRUBY_CHECK_DISPOSE( rt, surface ); | |
2700 | + if( !DXRUBY_CHECK( Viewport, self ) ) | |
2701 | + { | |
2702 | + DXRUBY_CHECK_DISPOSE( rt, surface ); | |
2703 | + } | |
2606 | 2704 | return INT2FIX( rt->height ); |
2607 | 2705 | } |
2608 | 2706 |
@@ -2613,7 +2711,10 @@ | ||
2613 | 2711 | static VALUE RenderTarget_getOx( VALUE self ) |
2614 | 2712 | { |
2615 | 2713 | struct DXRubyRenderTarget *rt = DXRUBY_GET_STRUCT( RenderTarget, self ); |
2616 | - DXRUBY_CHECK_DISPOSE( rt, surface ); | |
2714 | + if( !DXRUBY_CHECK( Viewport, self ) ) | |
2715 | + { | |
2716 | + DXRUBY_CHECK_DISPOSE( rt, surface ); | |
2717 | + } | |
2617 | 2718 | return INT2FIX( rt->ox ); |
2618 | 2719 | } |
2619 | 2720 |
@@ -2624,7 +2725,10 @@ | ||
2624 | 2725 | static VALUE RenderTarget_getOy( VALUE self ) |
2625 | 2726 | { |
2626 | 2727 | struct DXRubyRenderTarget *rt = DXRUBY_GET_STRUCT( RenderTarget, self ); |
2627 | - DXRUBY_CHECK_DISPOSE( rt, surface ); | |
2728 | + if( !DXRUBY_CHECK( Viewport, self ) ) | |
2729 | + { | |
2730 | + DXRUBY_CHECK_DISPOSE( rt, surface ); | |
2731 | + } | |
2628 | 2732 | return INT2FIX( rt->oy ); |
2629 | 2733 | } |
2630 | 2734 |
@@ -2635,7 +2739,10 @@ | ||
2635 | 2739 | static VALUE RenderTarget_setOx( VALUE self, VALUE vox ) |
2636 | 2740 | { |
2637 | 2741 | struct DXRubyRenderTarget *rt = DXRUBY_GET_STRUCT( RenderTarget, self ); |
2638 | - DXRUBY_CHECK_DISPOSE( rt, surface ); | |
2742 | + if( !DXRUBY_CHECK( Viewport, self ) ) | |
2743 | + { | |
2744 | + DXRUBY_CHECK_DISPOSE( rt, surface ); | |
2745 | + } | |
2639 | 2746 | rt->ox = NUM2INT( vox ); |
2640 | 2747 | return vox; |
2641 | 2748 | } |
@@ -2647,7 +2754,10 @@ | ||
2647 | 2754 | static VALUE RenderTarget_setOy( VALUE self, VALUE voy ) |
2648 | 2755 | { |
2649 | 2756 | struct DXRubyRenderTarget *rt = DXRUBY_GET_STRUCT( RenderTarget, self ); |
2650 | - DXRUBY_CHECK_DISPOSE( rt, surface ); | |
2757 | + if( !DXRUBY_CHECK( Viewport, self ) ) | |
2758 | + { | |
2759 | + DXRUBY_CHECK_DISPOSE( rt, surface ); | |
2760 | + } | |
2651 | 2761 | rt->oy = NUM2INT( voy ); |
2652 | 2762 | return voy; |
2653 | 2763 | } |
@@ -2856,7 +2966,6 @@ | ||
2856 | 2966 | int col; |
2857 | 2967 | struct DXRubyRenderTarget *rt = DXRUBY_GET_STRUCT( RenderTarget, obj ); |
2858 | 2968 | DXRUBY_CHECK_DISPOSE( rt, surface ); |
2859 | -// DXRUBY_CHECK_IMAGE_LOCK( rt ); | |
2860 | 2969 | |
2861 | 2970 | if( argc < 3 || argc > 4 ) rb_raise( rb_eArgError, "wrong number of arguments (%d for %d..%d)", argc, 3, 4 ); |
2862 | 2971 |
@@ -2896,7 +3005,6 @@ | ||
2896 | 3005 | int col; |
2897 | 3006 | struct DXRubyRenderTarget *rt = DXRUBY_GET_STRUCT( RenderTarget, obj ); |
2898 | 3007 | DXRUBY_CHECK_DISPOSE( rt, surface ); |
2899 | -// DXRUBY_CHECK_IMAGE_LOCK( rt ); | |
2900 | 3008 | |
2901 | 3009 | if( argc < 5 || argc > 6 ) rb_raise( rb_eArgError, "wrong number of arguments (%d for %d..%d)", argc, 5, 6 ); |
2902 | 3010 |
@@ -3456,9 +3564,6 @@ | ||
3456 | 3564 | |
3457 | 3565 | /* 描画 */ |
3458 | 3566 | g_pD3DDevice->lpVtbl->DrawPrimitiveUP(g_pD3DDevice, D3DPT_TRIANGLELIST, 2, VertexDataTbl, sizeof(TLVERTX)); |
3459 | - | |
3460 | - /* ロックカウントを減らす */ | |
3461 | -// image->lockcount--; | |
3462 | 3567 | } |
3463 | 3568 | |
3464 | 3569 | /*-------------------------------------------------------------------- |
@@ -3470,15 +3575,22 @@ | ||
3470 | 3575 | struct DXRubyPicture_draw *picture; |
3471 | 3576 | float z; |
3472 | 3577 | struct DXRubyRenderTarget *rt = DXRUBY_GET_STRUCT( RenderTarget, obj ); |
3473 | - DXRUBY_CHECK_DISPOSE( rt, surface ); | |
3474 | -// DXRUBY_CHECK_IMAGE_LOCK( rt ); | |
3475 | 3578 | |
3579 | + /* Viewprtの場合はdisposedチェックはしない */ | |
3580 | + if( !DXRUBY_CHECK( Viewport, obj ) ) | |
3581 | + { | |
3582 | + DXRUBY_CHECK_DISPOSE( rt, surface ); | |
3583 | + } | |
3584 | + | |
3476 | 3585 | if( argc < 3 || argc > 4 ) rb_raise( rb_eArgError, "wrong number of arguments (%d for %d..%d)", argc, 3, 4 ); |
3477 | 3586 | |
3478 | - /* 引数のイメージオブジェクトから中身を取り出す */ | |
3479 | - DXRUBY_CHECK_IMAGE( argv[2] ); | |
3480 | - image = DXRUBY_GET_STRUCT( Image, argv[2] ); | |
3481 | - DXRUBY_CHECK_DISPOSE( image, texture ); | |
3587 | + /* 引数のイメージオブジェクトから中身を取り出す(Viewportの場合は省略) */ | |
3588 | + if( !DXRUBY_CHECK( Viewport, argv[2] ) ) | |
3589 | + { | |
3590 | + DXRUBY_CHECK_IMAGE( argv[2] ); | |
3591 | + image = DXRUBY_GET_STRUCT( Image, argv[2] ); | |
3592 | + DXRUBY_CHECK_DISPOSE( image, texture ); | |
3593 | + } | |
3482 | 3594 | |
3483 | 3595 | picture = (struct DXRubyPicture_draw *)RenderTarget_AllocPictureList( rt, sizeof( struct DXRubyPicture_draw ) ); |
3484 | 3596 |
@@ -3500,9 +3612,6 @@ | ||
3500 | 3612 | /* RenderTargetだった場合に描画予約があればupdateする */ |
3501 | 3613 | RenderTerget_auto_update( argv[2] ); |
3502 | 3614 | |
3503 | - /* 使われたimageのロック */ | |
3504 | -// image->lockcount++; | |
3505 | - | |
3506 | 3615 | return obj; |
3507 | 3616 | } |
3508 | 3617 |
@@ -3516,7 +3625,6 @@ | ||
3516 | 3625 | float z; |
3517 | 3626 | struct DXRubyRenderTarget *rt = DXRUBY_GET_STRUCT( RenderTarget, obj ); |
3518 | 3627 | DXRUBY_CHECK_DISPOSE( rt, surface ); |
3519 | -// DXRUBY_CHECK_IMAGE_LOCK( rt ); | |
3520 | 3628 | |
3521 | 3629 | if( argc < 4 || argc > 5 ) rb_raise( rb_eArgError, "wrong number of arguments (%d for %d..%d)", argc, 4, 5 ); |
3522 | 3630 |
@@ -3545,9 +3653,6 @@ | ||
3545 | 3653 | /* RenderTargetだった場合に描画予約があればupdateする */ |
3546 | 3654 | RenderTerget_auto_update( argv[2] ); |
3547 | 3655 | |
3548 | - /* 使われたimageのロック */ | |
3549 | -// image->lockcount++; | |
3550 | - | |
3551 | 3656 | return obj; |
3552 | 3657 | } |
3553 | 3658 |
@@ -3562,7 +3667,6 @@ | ||
3562 | 3667 | float z; |
3563 | 3668 | struct DXRubyRenderTarget *rt = DXRUBY_GET_STRUCT( RenderTarget, obj ); |
3564 | 3669 | DXRUBY_CHECK_DISPOSE( rt, surface ); |
3565 | -// DXRUBY_CHECK_IMAGE_LOCK( rt ); | |
3566 | 3670 | |
3567 | 3671 | if( argc < 3 || argc > 4 ) rb_raise( rb_eArgError, "wrong number of arguments (%d for %d..%d)", argc, 3, 4 ); |
3568 | 3672 |
@@ -3591,9 +3695,6 @@ | ||
3591 | 3695 | /* RenderTargetだった場合に描画予約があればupdateする */ |
3592 | 3696 | RenderTerget_auto_update( argv[2] ); |
3593 | 3697 | |
3594 | - /* 使われたimageのロック */ | |
3595 | -// image->lockcount++; | |
3596 | - | |
3597 | 3698 | return obj; |
3598 | 3699 | } |
3599 | 3700 |
@@ -3608,7 +3709,6 @@ | ||
3608 | 3709 | float z; |
3609 | 3710 | struct DXRubyRenderTarget *rt = DXRUBY_GET_STRUCT( RenderTarget, obj ); |
3610 | 3711 | DXRUBY_CHECK_DISPOSE( rt, surface ); |
3611 | -// DXRUBY_CHECK_IMAGE_LOCK( rt ); | |
3612 | 3712 | |
3613 | 3713 | if( argc < 3 || argc > 4 ) rb_raise( rb_eArgError, "wrong number of arguments (%d for %d..%d)", argc, 3, 4); |
3614 | 3714 |
@@ -3637,9 +3737,6 @@ | ||
3637 | 3737 | /* RenderTargetだった場合に描画予約があればupdateする */ |
3638 | 3738 | RenderTerget_auto_update( argv[2] ); |
3639 | 3739 | |
3640 | - /* 使われたimageのロック */ | |
3641 | -// image->lockcount++; | |
3642 | - | |
3643 | 3740 | return obj; |
3644 | 3741 | } |
3645 | 3742 |
@@ -3696,13 +3793,10 @@ | ||
3696 | 3793 | DXRUBY_CHECK_DISPOSE( DXRUBY_GET_STRUCT( Image, value ), texture ); |
3697 | 3794 | core->pD3DXEffect->lpVtbl->SetTexture( core->pD3DXEffect, str , |
3698 | 3795 | (IDirect3DBaseTexture9*)(DXRUBY_GET_STRUCT( Image, value )->texture->pD3DTexture) ); |
3699 | - /* ロックカウントを減らす */ | |
3700 | -// DXRUBY_GET_STRUCT( Image, value )->lockcount--; | |
3701 | - | |
3702 | 3796 | } |
3703 | 3797 | else |
3704 | 3798 | { |
3705 | - rb_raise( eDXRubyError, "textureパラメータに画像以外が渡されています - Window_draw" ); | |
3799 | + rb_raise( eDXRubyError, "Non-image is set in texture parameter - Shader" ); | |
3706 | 3800 | } |
3707 | 3801 | } |
3708 | 3802 | else if( vtype == symbol_int ) |
@@ -3738,7 +3832,7 @@ | ||
3738 | 3832 | } |
3739 | 3833 | else |
3740 | 3834 | { |
3741 | - rb_raise( eDXRubyError, "Shaderオブジェクトのパラメータの型が不明です - Window_draw" ); | |
3835 | + rb_raise( eDXRubyError, "Unknown parameter type - Shader" ); | |
3742 | 3836 | } |
3743 | 3837 | |
3744 | 3838 | return ST_CONTINUE; |
@@ -3816,9 +3910,6 @@ | ||
3816 | 3910 | core->pD3DXEffect->lpVtbl->EndPass( core->pD3DXEffect ); |
3817 | 3911 | } |
3818 | 3912 | core->pD3DXEffect->lpVtbl->End( core->pD3DXEffect ); |
3819 | - | |
3820 | - /* ロックカウントを減らす */ | |
3821 | -// image->lockcount--; | |
3822 | 3913 | } |
3823 | 3914 | |
3824 | 3915 | /*-------------------------------------------------------------------- |
@@ -3837,7 +3928,6 @@ | ||
3837 | 3928 | if( argc < 4 || argc > 5 ) rb_raise( rb_eArgError, "wrong number of arguments (%d for %d..%d)", argc, 4, 5 ); |
3838 | 3929 | |
3839 | 3930 | DXRUBY_CHECK_DISPOSE( rt, surface ); |
3840 | -// DXRUBY_CHECK_IMAGE_LOCK( rt ); | |
3841 | 3931 | |
3842 | 3932 | picture = (struct DXRubyPicture_draw *)RenderTarget_AllocPictureList( rt, sizeof( struct DXRubyPicture_draw ) ); |
3843 | 3933 |
@@ -3873,9 +3963,6 @@ | ||
3873 | 3963 | /* RenderTargetだった場合に描画予約があればupdateする */ |
3874 | 3964 | RenderTerget_auto_update( argv[2] ); |
3875 | 3965 | |
3876 | - /* 使われたimageのロック */ | |
3877 | -// DXRUBY_GET_STRUCT( Image, argv[2] )->lockcount++; | |
3878 | - | |
3879 | 3966 | return obj; |
3880 | 3967 | } |
3881 | 3968 |
@@ -3979,9 +4066,6 @@ | ||
3979 | 4066 | /* 描画 */ |
3980 | 4067 | g_pD3DDevice->lpVtbl->DrawPrimitiveUP( g_pD3DDevice, D3DPT_TRIANGLELIST, 2, VertexDataTbl, sizeof(TLVERTX) ); |
3981 | 4068 | } |
3982 | - | |
3983 | - /* ロックカウントを減らす */ | |
3984 | -// image->lockcount--; | |
3985 | 4069 | } |
3986 | 4070 | |
3987 | 4071 | /*-------------------------------------------------------------------- |
@@ -3995,7 +4079,6 @@ | ||
3995 | 4079 | struct DXRubyRenderTarget *rt = DXRUBY_GET_STRUCT( RenderTarget, obj ); |
3996 | 4080 | volatile VALUE temp; |
3997 | 4081 | DXRUBY_CHECK_DISPOSE( rt, surface ); |
3998 | -// DXRUBY_CHECK_IMAGE_LOCK( rt ); | |
3999 | 4082 | |
4000 | 4083 | if( argc < 5 || argc > 8 ) rb_raise( rb_eArgError, "wrong number of arguments (%d for %d..%d)", argc, 5, 8 ); |
4001 | 4084 |
@@ -4029,9 +4112,6 @@ | ||
4029 | 4112 | /* RenderTargetだった場合に描画予約があればupdateする */ |
4030 | 4113 | RenderTerget_auto_update( argv[2] ); |
4031 | 4114 | |
4032 | - /* 使われたimageのロック */ | |
4033 | -// image->lockcount++; | |
4034 | - | |
4035 | 4115 | return obj; |
4036 | 4116 | } |
4037 | 4117 |
@@ -4046,7 +4126,6 @@ | ||
4046 | 4126 | struct DXRubyRenderTarget *rt = DXRUBY_GET_STRUCT( RenderTarget, obj ); |
4047 | 4127 | volatile VALUE temp; |
4048 | 4128 | DXRUBY_CHECK_DISPOSE( rt, surface ); |
4049 | -// DXRUBY_CHECK_IMAGE_LOCK( rt ); | |
4050 | 4129 | |
4051 | 4130 | if( argc < 4 || argc > 7 ) rb_raise( rb_eArgError, "wrong number of arguments (%d for %d..%d)", argc, 4, 7 ); |
4052 | 4131 |
@@ -4080,9 +4159,6 @@ | ||
4080 | 4159 | /* RenderTargetだった場合に描画予約があればupdateする */ |
4081 | 4160 | RenderTerget_auto_update( argv[2] ); |
4082 | 4161 | |
4083 | - /* 使われたimageのロック */ | |
4084 | -// image->lockcount++; | |
4085 | - | |
4086 | 4162 | return obj; |
4087 | 4163 | } |
4088 | 4164 |
@@ -4098,7 +4174,6 @@ | ||
4098 | 4174 | volatile VALUE temp; |
4099 | 4175 | struct DXRubyRenderTarget *rt = DXRUBY_GET_STRUCT( RenderTarget, obj ); |
4100 | 4176 | DXRUBY_CHECK_DISPOSE( rt, surface ); |
4101 | -// DXRUBY_CHECK_IMAGE_LOCK( rt ); | |
4102 | 4177 | |
4103 | 4178 | if( argc < 3 || argc > 4 ) rb_raise( rb_eArgError, "wrong number of arguments (%d for %d..%d)", argc, 3, 4 ); |
4104 | 4179 |
@@ -4182,9 +4257,6 @@ | ||
4182 | 4257 | /* RenderTargetだった場合に描画予約があればupdateする */ |
4183 | 4258 | RenderTerget_auto_update( argv[2] ); |
4184 | 4259 | |
4185 | - /* 使われたimageのロック */ | |
4186 | -// image->lockcount++; | |
4187 | - | |
4188 | 4260 | return obj; |
4189 | 4261 | } |
4190 | 4262 |
@@ -4256,7 +4328,6 @@ | ||
4256 | 4328 | volatile VALUE temp; |
4257 | 4329 | |
4258 | 4330 | DXRUBY_CHECK_DISPOSE( rt, surface ); |
4259 | -// DXRUBY_CHECK_IMAGE_LOCK( rt ); | |
4260 | 4331 | |
4261 | 4332 | if( argc < 4 || argc > 5 ) rb_raise( rb_eArgError, "wrong number of arguments (%d for %d..%d)", argc, 4, 5 ); |
4262 | 4333 | Check_Type(argv[2], T_STRING); |
@@ -4368,7 +4439,6 @@ | ||
4368 | 4439 | VALUE vimage, voption, vedge_width, vedge, vshadow; |
4369 | 4440 | |
4370 | 4441 | DXRUBY_CHECK_DISPOSE( rt, surface ); |
4371 | -// DXRUBY_CHECK_IMAGE_LOCK( rt ); | |
4372 | 4442 | DXRUBY_CHECK_TYPE( Font, argv[3] ); |
4373 | 4443 | |
4374 | 4444 | if( argc < 4 || argc > 5 ) rb_raise( rb_eArgError, "wrong number of arguments (%d for %d..%d)", argc, 4, 5 ); |
@@ -4558,9 +4628,6 @@ | ||
4558 | 4628 | { |
4559 | 4629 | g_pD3DDevice->lpVtbl->SetTextureStageState( g_pD3DDevice, 0, D3DTSS_COLOROP, D3DTOP_MODULATE ); |
4560 | 4630 | } |
4561 | - | |
4562 | - /* ロックカウントを減らす */ | |
4563 | -// image->lockcount--; | |
4564 | 4631 | } |
4565 | 4632 | |
4566 | 4633 | /*-------------------------------------------------------------------- |
@@ -4575,7 +4642,6 @@ | ||
4575 | 4642 | VALUE vz, vdividex, vdividey, valpha, vblend, vcolor; |
4576 | 4643 | struct DXRubyRenderTarget *rt = DXRUBY_GET_STRUCT( RenderTarget, obj ); |
4577 | 4644 | DXRUBY_CHECK_DISPOSE( rt, surface ); |
4578 | -// DXRUBY_CHECK_IMAGE_LOCK( rt ); | |
4579 | 4645 | |
4580 | 4646 | if( argc < 9 || argc > 10 ) rb_raise( rb_eArgError, "wrong number of arguments (%d for %d..%d)", argc, 9, 10 ); |
4581 | 4647 |
@@ -4626,7 +4692,7 @@ | ||
4626 | 4692 | |
4627 | 4693 | if( picture->dividex <= 0 || picture->dividey <= 0 ) |
4628 | 4694 | { |
4629 | - rb_raise( eDXRubyError, "分割数に0以下は指定できません"); | |
4695 | + rb_raise( eDXRubyError, "parameter is invalid(dividex or dividey) - RenderTarget#draw_morph"); | |
4630 | 4696 | } |
4631 | 4697 | |
4632 | 4698 | if( vcolor != Qnil ) |
@@ -4663,9 +4729,6 @@ | ||
4663 | 4729 | /* RenderTargetだった場合に描画予約があればupdateする */ |
4664 | 4730 | RenderTerget_auto_update( argv[8] ); |
4665 | 4731 | |
4666 | - /* 使われたimageのロック */ | |
4667 | -// image->lockcount++; | |
4668 | - | |
4669 | 4732 | return obj; |
4670 | 4733 | } |
4671 | 4734 |
@@ -4747,7 +4810,7 @@ | ||
4747 | 4810 | { |
4748 | 4811 | index = NUM2INT( arr2[mx] ); |
4749 | 4812 | |
4750 | - if( index >= RARRAY_LEN( vmapdata ) ) rb_raise(eDXRubyError, "マップチップ番号がイメージ配列の範囲を超えています - Window_drawTile"); | |
4813 | + if( index >= RARRAY_LEN( vmapdata ) ) rb_raise(eDXRubyError, "invalid MapChipNumber - RenderTarget#draw_tile"); | |
4751 | 4814 | |
4752 | 4815 | /* イメージオブジェクトから中身を取り出す */ |
4753 | 4816 | image = (struct DXRubyImage *)DATA_PTR( mapdata[index] ); |
@@ -4784,12 +4847,6 @@ | ||
4784 | 4847 | } |
4785 | 4848 | y = y + height; |
4786 | 4849 | } |
4787 | - | |
4788 | - /* ロックカウントを減らす */ | |
4789 | -// for( i = 0; i < RARRAY_LEN( vmapdata ); i++ ) | |
4790 | -// { | |
4791 | -// DXRUBY_GET_STRUCT( Image, mapdata[i] )->lockcount--; | |
4792 | -// } | |
4793 | 4850 | } |
4794 | 4851 | |
4795 | 4852 | /*-------------------------------------------------------------------- |
@@ -4806,7 +4863,6 @@ | ||
4806 | 4863 | int i; |
4807 | 4864 | |
4808 | 4865 | DXRUBY_CHECK_DISPOSE( rt, surface ); |
4809 | -// DXRUBY_CHECK_IMAGE_LOCK( rt ); | |
4810 | 4866 | |
4811 | 4867 | rb_scan_args( argc, argv, "81", &vbasex, &vbasey, &vmap, &vmapdata, &vstartx, &vstarty, &vsizex, &vsizey, &vz ); |
4812 | 4868 |
@@ -4823,9 +4879,6 @@ | ||
4823 | 4879 | |
4824 | 4880 | /* RenderTargetだった場合に描画予約があればupdateする */ |
4825 | 4881 | RenderTerget_auto_update( RARRAY_AREF(vmapdata_f, i) ); |
4826 | - | |
4827 | - /* 使われたimageのロック */ | |
4828 | -// image->lockcount++; | |
4829 | 4882 | } |
4830 | 4883 | |
4831 | 4884 | picture = (struct DXRubyPicture_drawTile *)RenderTarget_AllocPictureList( rt, sizeof( struct DXRubyPicture_drawTile ) ); |
@@ -4898,6 +4951,167 @@ | ||
4898 | 4951 | } |
4899 | 4952 | |
4900 | 4953 | |
4954 | +void RenderTarget_update_internal(struct DXRubyRenderTarget *rt, D3DVIEWPORT9 *old_viewport, D3DMATRIX *old_matrix_view, D3DMATRIX *old_matrix_proj, int dx, int dy ) | |
4955 | +{ | |
4956 | + int i; | |
4957 | + int oldflag = -1; | |
4958 | + | |
4959 | + RenderTarget_SortPictureList( rt ); | |
4960 | + | |
4961 | + for( i = 0; i < rt->PictureCount; i++ ) | |
4962 | + { | |
4963 | + struct DXRubyPicture_draw *temp = (struct DXRubyPicture_draw *)rt->PictureList[i].picture; | |
4964 | + | |
4965 | + /* 描画対象がViewportオブジェクトの場合、再帰呼び出ししてViewport内の描画予約を処理する */ | |
4966 | + if( DXRUBY_CHECK( Viewport, temp->value ) ) | |
4967 | + { | |
4968 | + struct DXRubyViewport *vp = DXRUBY_GET_STRUCT( Viewport, temp->value ); | |
4969 | + D3DVIEWPORT9 viewport; | |
4970 | + D3DMATRIX matrix_view, matrix_t, matrix_proj; | |
4971 | + int new_x = dx + temp->x; | |
4972 | + int new_y = dy + temp->y; | |
4973 | + /* DirectXのViewportを設定 */ | |
4974 | + if( old_viewport->X < new_x ) | |
4975 | + { | |
4976 | + viewport.X = new_x; | |
4977 | + if( old_viewport->X + old_viewport->Width > new_x + vp->width ) | |
4978 | + { | |
4979 | + viewport.Width = vp->width; | |
4980 | + } | |
4981 | + else | |
4982 | + { | |
4983 | + viewport.Width = old_viewport->X + old_viewport->Width - new_x; | |
4984 | + } | |
4985 | + } | |
4986 | + else | |
4987 | + { | |
4988 | + viewport.X = old_viewport->X; | |
4989 | + if( old_viewport->X + old_viewport->Width < new_x + vp->width ) | |
4990 | + { | |
4991 | + viewport.Width = old_viewport->Width; | |
4992 | + } | |
4993 | + else | |
4994 | + { | |
4995 | + viewport.Width = new_x + vp->width - old_viewport->X; | |
4996 | + } | |
4997 | + } | |
4998 | +// printf("old_x = %d\n", old_viewport->X); | |
4999 | +// printf("new_x = %d\n", new_x); | |
5000 | +// printf("vp_x = %d\n", viewport.X); | |
5001 | +// printf("old_w = %d\n", old_viewport->Width); | |
5002 | +// printf("vp_w = %d\n", viewport.Width); | |
5003 | + | |
5004 | + if( old_viewport->Y < new_y ) | |
5005 | + { | |
5006 | + viewport.Y = new_y; | |
5007 | + if( old_viewport->Y + old_viewport->Height > new_y + vp->height ) | |
5008 | + { | |
5009 | + viewport.Height = vp->height; | |
5010 | + } | |
5011 | + else | |
5012 | + { | |
5013 | + viewport.Height = old_viewport->Y + old_viewport->Height - new_y; | |
5014 | + } | |
5015 | + } | |
5016 | + else | |
5017 | + { | |
5018 | + viewport.Y = old_viewport->Y; | |
5019 | + if( old_viewport->Y + old_viewport->Height < new_y + vp->height ) | |
5020 | + { | |
5021 | + viewport.Height = old_viewport->Height; | |
5022 | + } | |
5023 | + else | |
5024 | + { | |
5025 | + viewport.Height = new_y + vp->height - old_viewport->Y; | |
5026 | + } | |
5027 | + } | |
5028 | +// printf("old_y = %d\n", old_viewport->Y); | |
5029 | +// printf("new_y = %d\n", new_y); | |
5030 | +// printf("vp_y = %d\n", viewport.Y); | |
5031 | +// printf("old_h = %d\n", old_viewport->Height); | |
5032 | +// printf("vp_h = %d\n", viewport.Height); | |
5033 | + viewport.MinZ = 0.0f; | |
5034 | + viewport.MaxZ = 1.0f; | |
5035 | + | |
5036 | + /* DirectXのビュー行列、射影行列を設定 */ | |
5037 | + D3DXMatrixScaling ( &matrix_view, 1, -1, 1 ); | |
5038 | + D3DXMatrixTranslation( &matrix_t, (float)-((int)viewport.Width)/2.0f, (float)((int)viewport.Height)/2.0f, 0 ); | |
5039 | + D3DXMatrixMultiply( &matrix_view, &matrix_view, &matrix_t ); | |
5040 | + g_pD3DDevice->lpVtbl->SetTransform( g_pD3DDevice, D3DTS_VIEW, &matrix_view ); | |
5041 | + matrix_proj._11 = 2.0f / viewport.Width; | |
5042 | + matrix_proj._12 = matrix_proj._13 = matrix_proj._14 = 0; | |
5043 | + matrix_proj._22 = 2.0f / viewport.Height; | |
5044 | + matrix_proj._21 = matrix_proj._23 = matrix_proj._24 = 0; | |
5045 | + matrix_proj._31 = matrix_proj._32 = 0;matrix_proj._33 = 0; matrix_proj._34 = 0; | |
5046 | + matrix_proj._41 = matrix_proj._42 = 0;matrix_proj._43 = 1; matrix_proj._44 = 1; | |
5047 | + g_pD3DDevice->lpVtbl->SetTransform( g_pD3DDevice, D3DTS_PROJECTION, &matrix_proj ); | |
5048 | + | |
5049 | + g_pD3DDevice->lpVtbl->SetViewport( g_pD3DDevice, &viewport ); | |
5050 | + | |
5051 | + /* 再帰呼び出し */ | |
5052 | + RenderTarget_update_internal( (struct DXRubyRenderTarget *)vp, &viewport, &matrix_view, &matrix_proj, new_x, new_y ); | |
5053 | + | |
5054 | + /* DirectXの行列とViewportを戻す */ | |
5055 | + g_pD3DDevice->lpVtbl->SetTransform( g_pD3DDevice, D3DTS_VIEW, old_matrix_view ); | |
5056 | + g_pD3DDevice->lpVtbl->SetTransform( g_pD3DDevice, D3DTS_PROJECTION, old_matrix_proj ); | |
5057 | + g_pD3DDevice->lpVtbl->SetViewport( g_pD3DDevice, old_viewport ); | |
5058 | + | |
5059 | + continue; | |
5060 | + } | |
5061 | + | |
5062 | + if( temp->blendflag != oldflag ) | |
5063 | + { | |
5064 | + switch( temp->blendflag ) | |
5065 | + { | |
5066 | + case 0: /* 半透明合成 */ | |
5067 | + g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_SRCBLEND, D3DBLEND_SRCALPHA ); | |
5068 | + g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA ); | |
5069 | + g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_SRCBLENDALPHA, D3DBLEND_ONE ); | |
5070 | + g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_DESTBLENDALPHA, D3DBLEND_INVSRCALPHA ); | |
5071 | + break; | |
5072 | + case 1: /* 単純上書き */ | |
5073 | + g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_SRCBLEND, D3DBLEND_ONE ); | |
5074 | + g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_DESTBLEND, D3DBLEND_ZERO ); | |
5075 | + g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_SRCBLENDALPHA, D3DBLEND_ONE ); | |
5076 | + g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_DESTBLENDALPHA, D3DBLEND_ZERO ); | |
5077 | + break; | |
5078 | + case 4: /* 加算合成1の設定 */ | |
5079 | + g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_SRCBLEND, D3DBLEND_SRCALPHA ); | |
5080 | + g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_DESTBLEND, D3DBLEND_ONE ); | |
5081 | + g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_SRCBLENDALPHA, D3DBLEND_ONE ); | |
5082 | + g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_DESTBLENDALPHA, D3DBLEND_INVSRCALPHA ); | |
5083 | + break; | |
5084 | + case 5: /* 加算合成2の設定 */ | |
5085 | + g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_SRCBLEND, D3DBLEND_ONE ); | |
5086 | + g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA ); | |
5087 | + g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_SRCBLENDALPHA, D3DBLEND_ONE ); | |
5088 | + g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_DESTBLENDALPHA, D3DBLEND_INVSRCALPHA ); | |
5089 | + break; | |
5090 | + case 6: /* 減算合成1の設定 */ | |
5091 | + g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_SRCBLEND, D3DBLEND_ZERO ); | |
5092 | + g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA ); | |
5093 | + g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_SRCBLENDALPHA, D3DBLEND_ONE ); | |
5094 | + g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_DESTBLENDALPHA, D3DBLEND_INVSRCALPHA ); | |
5095 | + break; | |
5096 | + case 7: /* 減算合成2の設定 */ | |
5097 | + g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_SRCBLEND, D3DBLEND_ZERO ); | |
5098 | + g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_DESTBLEND, D3DBLEND_INVSRCCOLOR ); | |
5099 | + g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_SRCBLENDALPHA, D3DBLEND_ONE ); | |
5100 | + g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_DESTBLENDALPHA, D3DBLEND_INVSRCALPHA ); | |
5101 | + break; | |
5102 | + } | |
5103 | + } | |
5104 | + | |
5105 | + oldflag = temp->blendflag; | |
5106 | + temp->func( temp ); | |
5107 | + } | |
5108 | + | |
5109 | + rt->PictureCount = 0; | |
5110 | + rt->PictureSize = 0; | |
5111 | + rt->PictureDecideCount = 0; | |
5112 | + rt->PictureDecideSize = 0; | |
5113 | +} | |
5114 | + | |
4901 | 5115 | /*-------------------------------------------------------------------- |
4902 | 5116 | RenderTarget更新 |
4903 | 5117 | ---------------------------------------------------------------------*/ |
@@ -4908,12 +5122,12 @@ | ||
4908 | 5122 | int y_2d, height_2d; |
4909 | 5123 | struct DXRubyRenderTarget *rt = DXRUBY_GET_STRUCT( RenderTarget, self ); /* 出力先 */ |
4910 | 5124 | int i; |
5125 | + D3DVIEWPORT9 vp; | |
4911 | 5126 | |
4912 | 5127 | DXRUBY_CHECK_DISPOSE( rt, surface ); |
4913 | 5128 | |
4914 | 5129 | /* シーンのクリア */ |
4915 | 5130 | { |
4916 | - D3DVIEWPORT9 vp; | |
4917 | 5131 | vp.X = x_2d = 0; |
4918 | 5132 | vp.Y = y_2d = 0; |
4919 | 5133 | if( rt->texture == NULL ) |
@@ -4925,22 +5139,14 @@ | ||
4925 | 5139 | { |
4926 | 5140 | vp.Width = width_2d = (int)rt->texture->width; |
4927 | 5141 | vp.Height = height_2d = (int)rt->texture->height; |
4928 | - rt->clearflag = 1; | |
5142 | + rt->clearflag = 0; | |
4929 | 5143 | } |
4930 | 5144 | vp.MinZ = 0.0f; |
4931 | 5145 | vp.MaxZ = 1.0f; |
4932 | 5146 | g_pD3DDevice->lpVtbl->SetRenderTarget( g_pD3DDevice, 0, rt->surface ); |
4933 | 5147 | g_pD3DDevice->lpVtbl->SetViewport( g_pD3DDevice, &vp ); |
4934 | -#ifdef DXRUBY15 | |
4935 | - if( rt->vregenerate_proc == Qnil ) | |
4936 | - { | |
4937 | - g_pD3DDevice->lpVtbl->Clear( g_pD3DDevice, 0, NULL, D3DCLEAR_TARGET, | |
4938 | - D3DCOLOR_ARGB( rt->a, rt->r, rt->g, rt->b ), 1.0f, 0 ); | |
4939 | - } | |
4940 | -#else | |
4941 | 5148 | g_pD3DDevice->lpVtbl->Clear( g_pD3DDevice, 0, NULL, D3DCLEAR_TARGET, |
4942 | 5149 | D3DCOLOR_ARGB( rt->a, rt->r, rt->g, rt->b ), 1.0f, 0 ); |
4943 | -#endif | |
4944 | 5150 | } |
4945 | 5151 | |
4946 | 5152 | /* シーンの描画開始 */ |
@@ -4986,74 +5192,22 @@ | ||
4986 | 5192 | |
4987 | 5193 | if( rt->PictureCount > 0 ) |
4988 | 5194 | { |
4989 | - D3DMATRIX matrix, matrix_t; | |
4990 | - int oldflag = 0; | |
5195 | + D3DMATRIX matrix_view, matrix_t, matrix_proj; | |
4991 | 5196 | |
4992 | - RenderTarget_SortPictureList( rt ); | |
4993 | - | |
4994 | - /* 2D描画 */ | |
4995 | - D3DXMatrixScaling ( &matrix, 1, -1, 1 ); | |
5197 | + /* 2D描画行列 */ | |
5198 | + D3DXMatrixScaling ( &matrix_view, 1, -1, 1 ); | |
4996 | 5199 | D3DXMatrixTranslation( &matrix_t, (float)-(width_2d)/2.0f, (float)(height_2d)/2.0f, 0 ); |
4997 | - D3DXMatrixMultiply( &matrix, &matrix, &matrix_t ); | |
4998 | - g_pD3DDevice->lpVtbl->SetTransform( g_pD3DDevice, D3DTS_VIEW, &matrix ); | |
4999 | - matrix._11 = 2.0f / width_2d; | |
5000 | - matrix._12 = matrix._13 = matrix._14 = 0; | |
5001 | - matrix._22 = 2.0f / height_2d; | |
5002 | - matrix._21 = matrix._23 = matrix._24 = 0; | |
5003 | - matrix._31 = matrix._32 = 0;matrix._33 = 0; matrix._34 = 0; | |
5004 | - matrix._41 = matrix._42 = 0;matrix._43 = 1; matrix._44 = 1; | |
5005 | - g_pD3DDevice->lpVtbl->SetTransform( g_pD3DDevice, D3DTS_PROJECTION, &matrix ); | |
5200 | + D3DXMatrixMultiply( &matrix_view, &matrix_view, &matrix_t ); | |
5201 | + g_pD3DDevice->lpVtbl->SetTransform( g_pD3DDevice, D3DTS_VIEW, &matrix_view ); | |
5202 | + matrix_proj._11 = 2.0f / width_2d; | |
5203 | + matrix_proj._12 = matrix_proj._13 = matrix_proj._14 = 0; | |
5204 | + matrix_proj._22 = 2.0f / height_2d; | |
5205 | + matrix_proj._21 = matrix_proj._23 = matrix_proj._24 = 0; | |
5206 | + matrix_proj._31 = matrix_proj._32 = 0;matrix_proj._33 = 0; matrix_proj._34 = 0; | |
5207 | + matrix_proj._41 = matrix_proj._42 = 0;matrix_proj._43 = 1; matrix_proj._44 = 1; | |
5208 | + g_pD3DDevice->lpVtbl->SetTransform( g_pD3DDevice, D3DTS_PROJECTION, &matrix_proj ); | |
5006 | 5209 | |
5007 | - for( i = 0; i < rt->PictureCount; i++ ) | |
5008 | - { | |
5009 | - struct DXRubyPicture_draw *temp = (struct DXRubyPicture_draw *)rt->PictureList[i].picture; | |
5010 | - | |
5011 | - if( temp->blendflag != oldflag ) | |
5012 | - { | |
5013 | - switch( temp->blendflag ) | |
5014 | - { | |
5015 | - case 0: /* 半透明合成 */ | |
5016 | - g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_SRCBLEND, D3DBLEND_SRCALPHA ); | |
5017 | - g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA ); | |
5018 | - g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_SRCBLENDALPHA, D3DBLEND_ONE ); | |
5019 | - g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_DESTBLENDALPHA, D3DBLEND_INVSRCALPHA ); | |
5020 | - break; | |
5021 | - case 1: /* 単純上書き */ | |
5022 | - g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_SRCBLEND, D3DBLEND_ONE ); | |
5023 | - g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_DESTBLEND, D3DBLEND_ZERO ); | |
5024 | - g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_SRCBLENDALPHA, D3DBLEND_ONE ); | |
5025 | - g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_DESTBLENDALPHA, D3DBLEND_ZERO ); | |
5026 | - break; | |
5027 | - case 4: /* 加算合成1の設定 */ | |
5028 | - g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_SRCBLEND, D3DBLEND_SRCALPHA ); | |
5029 | - g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_DESTBLEND, D3DBLEND_ONE ); | |
5030 | - g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_SRCBLENDALPHA, D3DBLEND_ONE ); | |
5031 | - g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_DESTBLENDALPHA, D3DBLEND_INVSRCALPHA ); | |
5032 | - break; | |
5033 | - case 5: /* 加算合成2の設定 */ | |
5034 | - g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_SRCBLEND, D3DBLEND_ONE ); | |
5035 | - g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA ); | |
5036 | - g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_SRCBLENDALPHA, D3DBLEND_ONE ); | |
5037 | - g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_DESTBLENDALPHA, D3DBLEND_INVSRCALPHA ); | |
5038 | - break; | |
5039 | - case 6: /* 減算合成1の設定 */ | |
5040 | - g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_SRCBLEND, D3DBLEND_ZERO ); | |
5041 | - g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA ); | |
5042 | - g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_SRCBLENDALPHA, D3DBLEND_ONE ); | |
5043 | - g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_DESTBLENDALPHA, D3DBLEND_INVSRCALPHA ); | |
5044 | - break; | |
5045 | - case 7: /* 減算合成2の設定 */ | |
5046 | - g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_SRCBLEND, D3DBLEND_ZERO ); | |
5047 | - g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_DESTBLEND, D3DBLEND_INVSRCCOLOR ); | |
5048 | - g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_SRCBLENDALPHA, D3DBLEND_ONE ); | |
5049 | - g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_DESTBLENDALPHA, D3DBLEND_INVSRCALPHA ); | |
5050 | - break; | |
5051 | - } | |
5052 | - } | |
5053 | - | |
5054 | - oldflag = temp->blendflag; | |
5055 | - temp->func( temp ); | |
5056 | - } | |
5210 | + RenderTarget_update_internal( rt, &vp, &matrix_view, &matrix_proj, 0, 0 ); | |
5057 | 5211 | } |
5058 | 5212 | |
5059 | 5213 | /* シーンの描画終了 */ |
@@ -5141,32 +5295,7 @@ | ||
5141 | 5295 | } |
5142 | 5296 | |
5143 | 5297 | |
5144 | -#ifdef DXRUBY15 | |
5145 | 5298 | /*-------------------------------------------------------------------- |
5146 | - 再生成Proc取得 | |
5147 | - ---------------------------------------------------------------------*/ | |
5148 | -static VALUE RenderTarget_getRegenerateProc( VALUE self ) | |
5149 | -{ | |
5150 | - struct DXRubyRenderTarget *rt = DXRUBY_GET_STRUCT( RenderTarget, self ); | |
5151 | - DXRUBY_CHECK_DISPOSE( rt, surface ); | |
5152 | - return rt->vregenerate_proc; | |
5153 | -} | |
5154 | - | |
5155 | - | |
5156 | -/*-------------------------------------------------------------------- | |
5157 | - 再生成Proc設定 | |
5158 | - ---------------------------------------------------------------------*/ | |
5159 | -static VALUE RenderTarget_setRegenerateProc( VALUE self, VALUE vregenerate_proc ) | |
5160 | -{ | |
5161 | - struct DXRubyRenderTarget *rt = DXRUBY_GET_STRUCT( RenderTarget, self ); | |
5162 | - DXRUBY_CHECK_DISPOSE( rt, surface ); | |
5163 | - rt->vregenerate_proc = vregenerate_proc; | |
5164 | - return vregenerate_proc; | |
5165 | -} | |
5166 | -#endif | |
5167 | - | |
5168 | - | |
5169 | -/*-------------------------------------------------------------------- | |
5170 | 5299 | (内部関数)フレーム調整初期化 |
5171 | 5300 | ---------------------------------------------------------------------*/ |
5172 | 5301 | static void InitSync( void ) |
@@ -5192,7 +5321,557 @@ | ||
5192 | 5321 | |
5193 | 5322 | |
5194 | 5323 | |
5324 | +/********************************************************************* | |
5325 | + * VertexBufferクラス | |
5326 | + * | |
5327 | + * 頂点バッファを管理する | |
5328 | + *********************************************************************/ | |
5195 | 5329 | |
5330 | +/*-------------------------------------------------------------------- | |
5331 | + 参照されなくなったときにGCから呼ばれる関数 | |
5332 | + ---------------------------------------------------------------------*/ | |
5333 | +static void VertexBuffer_free( struct DXRubyVertexBuffer *vb) | |
5334 | +{ | |
5335 | + if( vb->pVertexBuffer != (LPDIRECT3DVERTEXBUFFER9)vb ) | |
5336 | + { | |
5337 | + RELEASE( vb->pVertexBuffer ); | |
5338 | + } | |
5339 | + vb->pVertexBuffer = 0; | |
5340 | + vb->vtype = Qnil; | |
5341 | +} | |
5342 | + | |
5343 | +void VertexBuffer_release( struct DXRubyVertexBuffer *vb ) | |
5344 | +{ | |
5345 | + if( vb->pVertexBuffer ) | |
5346 | + { | |
5347 | + VertexBuffer_free( vb ); | |
5348 | + } | |
5349 | + free( vb ); | |
5350 | + | |
5351 | + g_iRefAll--; | |
5352 | + if( g_iRefAll == 0 ) | |
5353 | + { | |
5354 | + CoUninitialize(); | |
5355 | + } | |
5356 | +} | |
5357 | + | |
5358 | +/*-------------------------------------------------------------------- | |
5359 | + GCから呼ばれるマーク関数 | |
5360 | + ---------------------------------------------------------------------*/ | |
5361 | +static void VertexBuffer_mark( struct DXRubyVertexBuffer *vb ) | |
5362 | +{ | |
5363 | + rb_gc_mark( vb->vtype ); | |
5364 | +} | |
5365 | + | |
5366 | +#ifdef DXRUBY_USE_TYPEDDATA | |
5367 | +const rb_data_type_t VertexBuffer_data_type = { | |
5368 | + "VertexBuffer", | |
5369 | + { | |
5370 | + VertexBuffer_mark, | |
5371 | + VertexBuffer_release, | |
5372 | + 0, | |
5373 | + }, | |
5374 | + NULL, NULL | |
5375 | +}; | |
5376 | +#endif | |
5377 | + | |
5378 | +/*-------------------------------------------------------------------- | |
5379 | + VertexBufferクラスのdispose。 | |
5380 | + ---------------------------------------------------------------------*/ | |
5381 | +static VALUE VertexBuffer_dispose( VALUE self ) | |
5382 | +{ | |
5383 | + struct DXRubyVertexBuffer *vb = DXRUBY_GET_STRUCT( VertexBuffer, self ); | |
5384 | + DXRUBY_CHECK_DISPOSE( vb, pVertexBuffer ); | |
5385 | + VertexBuffer_free( vb ); | |
5386 | + return Qnil; | |
5387 | +} | |
5388 | + | |
5389 | +/*-------------------------------------------------------------------- | |
5390 | + VertexBufferクラスのdisposed?。 | |
5391 | + ---------------------------------------------------------------------*/ | |
5392 | +static VALUE VertexBuffer_check_disposed( VALUE self ) | |
5393 | +{ | |
5394 | + if( DXRUBY_GET_STRUCT( VertexBuffer, self )->pVertexBuffer == NULL ) | |
5395 | + { | |
5396 | + return Qtrue; | |
5397 | + } | |
5398 | + | |
5399 | + return Qfalse; | |
5400 | +} | |
5401 | + | |
5402 | +/*-------------------------------------------------------------------- | |
5403 | + VertexBufferクラスのallocate。メモリを確保する為にinitialize前に呼ばれる。 | |
5404 | + ---------------------------------------------------------------------*/ | |
5405 | +static VALUE VertexBuffer_allocate( VALUE klass ) | |
5406 | +{ | |
5407 | + VALUE obj; | |
5408 | + struct DXRubyVertexBuffer *vb; | |
5409 | + | |
5410 | + /* DXRubyVertexBufferのメモリ取得&VertexBufferオブジェクト生成 */ | |
5411 | + vb = malloc( sizeof( struct DXRubyVertexBuffer ) ); | |
5412 | + if( vb == NULL ) rb_raise( eDXRubyError, "Memory allocate error. - VertexBuffer_allocate" ); | |
5413 | +#ifdef DXRUBY_USE_TYPEDDATA | |
5414 | + obj = TypedData_Wrap_Struct( klass, &VertexBuffer_data_type, vb ); | |
5415 | +#else | |
5416 | + obj = Data_Wrap_Struct( klass, VertexBuffer_mark, VertexBuffer_release, vb ); | |
5417 | +#endif | |
5418 | + /* 未初期化(かつ未回収)を判別するためpVertexBufferには自分自身のポインタを入れておく。回収されたらNULLになる。 */ | |
5419 | + vb->pVertexBuffer = (LPDIRECT3DVERTEXBUFFER9)vb; | |
5420 | + vb->vtype = Qnil; | |
5421 | + vb->vertex_size = 0; | |
5422 | + | |
5423 | + return obj; | |
5424 | +} | |
5425 | + | |
5426 | + | |
5427 | +/*-------------------------------------------------------------------- | |
5428 | + VertexBufferクラスのInitialize | |
5429 | + ---------------------------------------------------------------------*/ | |
5430 | + static VALUE VertexBuffer_initialize( VALUE self, VALUE vtype ) | |
5431 | +{ | |
5432 | + struct DXRubyVertexBuffer *vb = DXRUBY_GET_STRUCT( VertexBuffer, self ); | |
5433 | + int vertex_size = 0; | |
5434 | + int vertex_num_count = 0; | |
5435 | + int i; | |
5436 | + | |
5437 | + Check_Type( vtype, T_ARRAY ); | |
5438 | + | |
5439 | + for( i = 0; i < RARRAY_LEN(vtype); i++) { | |
5440 | + VALUE vtypeary = rb_ary_entry(vtype, i); | |
5441 | + Check_Type( vtypeary, T_ARRAY ); | |
5442 | + | |
5443 | + switch(NUM2INT(rb_ary_entry(vtypeary, 0))) { | |
5444 | + case D3DDECLTYPE_FLOAT1: | |
5445 | + vertex_size += 4; | |
5446 | + vertex_num_count += 1; | |
5447 | + break; | |
5448 | + case D3DDECLTYPE_UBYTE4: | |
5449 | + vertex_size += 4; | |
5450 | + vertex_num_count += 4; | |
5451 | + break; | |
5452 | + case D3DDECLTYPE_FLOAT2: | |
5453 | + vertex_size += 8; | |
5454 | + vertex_num_count += 2; | |
5455 | + break; | |
5456 | + case D3DDECLTYPE_FLOAT3: | |
5457 | + vertex_size += 12; | |
5458 | + vertex_num_count += 3; | |
5459 | + break; | |
5460 | + case D3DDECLTYPE_FLOAT4: | |
5461 | + vertex_size += 16; | |
5462 | + vertex_num_count += 4; | |
5463 | + break; | |
5464 | + case D3DDECLTYPE_D3DCOLOR: | |
5465 | + vertex_size += 4; | |
5466 | + vertex_num_count += 1; | |
5467 | + break; | |
5468 | + default: | |
5469 | + rb_raise( eDXRubyError, "No support D3DDECLTYPE. - VertexBuffer_initialize" ); | |
5470 | + break; | |
5471 | + } | |
5472 | + } | |
5473 | + | |
5474 | + vb->vtype = vtype; | |
5475 | + vb->vertex_size = vertex_size; | |
5476 | + vb->vertex_num_count = vertex_num_count; | |
5477 | + | |
5478 | + return self; | |
5479 | +} | |
5480 | + | |
5481 | + | |
5482 | +static VALUE VertexBuffer_set_buf( VALUE self, VALUE vstr ) | |
5483 | +{ | |
5484 | + struct DXRubyVertexBuffer *vb = DXRUBY_GET_STRUCT( VertexBuffer, self ); | |
5485 | + void *p; | |
5486 | + | |
5487 | + DXRUBY_CHECK_DISPOSE( vb, pVertexBuffer ); | |
5488 | + Check_Type( vstr, T_STRING ); | |
5489 | + | |
5490 | + if( vb->pVertexBuffer == (LPDIRECT3DVERTEXBUFFER9)vb ) /* 未初期化 */ | |
5491 | + { | |
5492 | + g_iRefAll++; | |
5493 | + } | |
5494 | + else /* 初期化済の再割り当て */ | |
5495 | + { | |
5496 | + RELEASE( vb->pVertexBuffer ); | |
5497 | + } | |
5498 | + | |
5499 | + g_pD3DDevice->lpVtbl->CreateVertexBuffer( g_pD3DDevice, RSTRING_LEN(vstr), 0, 0, D3DPOOL_MANAGED, &vb->pVertexBuffer, NULL ); | |
5500 | + | |
5501 | + vb->pVertexBuffer->lpVtbl->Lock( vb->pVertexBuffer, 0, 0, &p, 0 ); | |
5502 | + | |
5503 | + memcpy( p, RSTRING_PTR(vstr), RSTRING_LEN(vstr) ); | |
5504 | + | |
5505 | + vb->pVertexBuffer->lpVtbl->Unlock( vb->pVertexBuffer ); | |
5506 | + | |
5507 | + return vstr; | |
5508 | +} | |
5509 | + | |
5510 | +static VALUE VertexBuffer_get_buf( VALUE self ) | |
5511 | +{ | |
5512 | + struct DXRubyVertexBuffer *vb = DXRUBY_GET_STRUCT( VertexBuffer, self ); | |
5513 | + VALUE vstr; | |
5514 | + void *p; | |
5515 | + D3DVERTEXBUFFER_DESC desc; | |
5516 | + | |
5517 | + DXRUBY_CHECK_DISPOSE( vb, pVertexBuffer ); | |
5518 | + vb->pVertexBuffer->lpVtbl->GetDesc( vb->pVertexBuffer, &desc ); | |
5519 | + | |
5520 | + vb->pVertexBuffer->lpVtbl->Lock( vb->pVertexBuffer, 0, 0, &p, 0 ); | |
5521 | + vstr = rb_str_new( p, desc.Size ); | |
5522 | + vb->pVertexBuffer->lpVtbl->Unlock( vb->pVertexBuffer ); | |
5523 | + | |
5524 | + return vstr; | |
5525 | +} | |
5526 | + | |
5527 | +static VALUE VertexBuffer_set_vertices( VALUE self, VALUE vary ) | |
5528 | +{ | |
5529 | + struct DXRubyVertexBuffer *vb = DXRUBY_GET_STRUCT( VertexBuffer, self ); | |
5530 | + char *p; | |
5531 | + int vertex_count, size, i, j, k; | |
5532 | + | |
5533 | + DXRUBY_CHECK_DISPOSE( vb, pVertexBuffer ); | |
5534 | + Check_Type( vary, T_ARRAY ); | |
5535 | + | |
5536 | + if( vb->pVertexBuffer == (LPDIRECT3DVERTEXBUFFER9)vb ) /* 未初期化 */ | |
5537 | + { | |
5538 | + g_iRefAll++; | |
5539 | + } | |
5540 | + else /* 初期化済の再割り当て */ | |
5541 | + { | |
5542 | + RELEASE( vb->pVertexBuffer ); | |
5543 | + } | |
5544 | + | |
5545 | + /* 頂点の数 */ | |
5546 | + vertex_count = RARRAY_LEN(vary) / vb->vertex_num_count; | |
5547 | + | |
5548 | + /* 頂点バッファに必要なバイト数算出 */ | |
5549 | + size = vertex_count * vb->vertex_size; | |
5550 | + | |
5551 | + /* 頂点バッファ生成 */ | |
5552 | + g_pD3DDevice->lpVtbl->CreateVertexBuffer( g_pD3DDevice, size, 0, 0, D3DPOOL_MANAGED, &vb->pVertexBuffer, NULL ); | |
5553 | + | |
5554 | + vb->pVertexBuffer->lpVtbl->Lock( vb->pVertexBuffer, 0, 0, &(void*)p, 0 ); | |
5555 | + | |
5556 | + k = 0; | |
5557 | + for( i = 0; i < vertex_count; i++ ) | |
5558 | + { | |
5559 | + for( j = 0; j < RARRAY_LEN(vb->vtype); j++ ) | |
5560 | + { | |
5561 | + VALUE vtypeary = rb_ary_entry(vb->vtype, j); | |
5562 | + switch(NUM2INT(rb_ary_entry(vtypeary, 0))) { | |
5563 | + case D3DDECLTYPE_FLOAT1: | |
5564 | + *(float*)p = NUM2FLOAT(rb_ary_entry(vary, k)); | |
5565 | + k++; | |
5566 | + p += 4; | |
5567 | + break; | |
5568 | + case D3DDECLTYPE_UBYTE4: | |
5569 | + *(unsigned char*)p = (unsigned char)NUM2UINT(rb_ary_entry(vary, k)); | |
5570 | + k++; | |
5571 | + p += 1; | |
5572 | + *(unsigned char*)p = (unsigned char)NUM2UINT(rb_ary_entry(vary, k)); | |
5573 | + k++; | |
5574 | + p += 1; | |
5575 | + *(unsigned char*)p = (unsigned char)NUM2UINT(rb_ary_entry(vary, k)); | |
5576 | + k++; | |
5577 | + p += 1; | |
5578 | + *(unsigned char*)p = (unsigned char)NUM2UINT(rb_ary_entry(vary, k)); | |
5579 | + k++; | |
5580 | + p += 1; | |
5581 | + break; | |
5582 | + case D3DDECLTYPE_FLOAT2: | |
5583 | + *(float*)p = NUM2FLOAT(rb_ary_entry(vary, k)); | |
5584 | + p += 4; | |
5585 | + k++; | |
5586 | + *(float*)p = NUM2FLOAT(rb_ary_entry(vary, k)); | |
5587 | + k++; | |
5588 | + p += 4; | |
5589 | + break; | |
5590 | + case D3DDECLTYPE_FLOAT3: | |
5591 | + *(float*)p = NUM2FLOAT(rb_ary_entry(vary, k)); | |
5592 | + p += 4; | |
5593 | + k++; | |
5594 | + *(float*)p = NUM2FLOAT(rb_ary_entry(vary, k)); | |
5595 | + k++; | |
5596 | + p += 4; | |
5597 | + *(float*)p = NUM2FLOAT(rb_ary_entry(vary, k)); | |
5598 | + k++; | |
5599 | + p += 4; | |
5600 | + break; | |
5601 | + case D3DDECLTYPE_FLOAT4: | |
5602 | + *(float*)p = NUM2FLOAT(rb_ary_entry(vary, k)); | |
5603 | + k++; | |
5604 | + p += 4; | |
5605 | + *(float*)p = NUM2FLOAT(rb_ary_entry(vary, k)); | |
5606 | + k++; | |
5607 | + p += 4; | |
5608 | + *(float*)p = NUM2FLOAT(rb_ary_entry(vary, k)); | |
5609 | + k++; | |
5610 | + p += 4; | |
5611 | + *(float*)p = NUM2FLOAT(rb_ary_entry(vary, k)); | |
5612 | + k++; | |
5613 | + p += 4; | |
5614 | + break; | |
5615 | + case D3DDECLTYPE_D3DCOLOR: | |
5616 | + *(unsigned int*)p = NUM2UINT(rb_ary_entry(vary, k)); | |
5617 | + k++; | |
5618 | + p += 4; | |
5619 | + break; | |
5620 | + default: | |
5621 | + break; | |
5622 | + } | |
5623 | + } | |
5624 | + | |
5625 | + } | |
5626 | + | |
5627 | + vb->pVertexBuffer->lpVtbl->Unlock( vb->pVertexBuffer ); | |
5628 | + | |
5629 | + return vary; | |
5630 | +} | |
5631 | + | |
5632 | +static VALUE VertexBuffer_get_vertices( VALUE self ) | |
5633 | +{ | |
5634 | + // struct DXRubyVertexBuffer *vb = DXRUBY_GET_STRUCT( VertexBuffer, self ); | |
5635 | + // VALUE vstr; | |
5636 | + // void *p; | |
5637 | + // D3DVERTEXBUFFER_DESC desc; | |
5638 | + | |
5639 | + // DXRUBY_CHECK_DISPOSE( vb, pVertexBuffer ); | |
5640 | + // vb->pVertexBuffer->lpVtbl->GetDesc( vb->pVertexBuffer, &desc ); | |
5641 | + | |
5642 | + // vb->pVertexBuffer->lpVtbl->Lock( vb->pVertexBuffer, 0, 0, &p, 0 ); | |
5643 | + // vstr = rb_str_new( p, desc.Size ); | |
5644 | + // vb->pVertexBuffer->lpVtbl->Unlock( vb->pVertexBuffer ); | |
5645 | + | |
5646 | + // return vstr; | |
5647 | + return self; | |
5648 | +} | |
5649 | + | |
5650 | +static VALUE VertexBuffer_get_size( VALUE self ) | |
5651 | +{ | |
5652 | + struct DXRubyVertexBuffer *vb = DXRUBY_GET_STRUCT( VertexBuffer, self ); | |
5653 | + D3DVERTEXBUFFER_DESC desc; | |
5654 | + DXRUBY_CHECK_DISPOSE( vb, pVertexBuffer ); | |
5655 | + | |
5656 | + vb->pVertexBuffer->lpVtbl->GetDesc( vb->pVertexBuffer, &desc ); | |
5657 | + return INT2NUM(desc.Size); | |
5658 | +} | |
5659 | + | |
5660 | +static VALUE VertexBuffer_get_vertex_type( VALUE self ) | |
5661 | +{ | |
5662 | + struct DXRubyVertexBuffer *vb = DXRUBY_GET_STRUCT( VertexBuffer, self ); | |
5663 | + DXRUBY_CHECK_DISPOSE( vb, pVertexBuffer ); | |
5664 | + return vb->vtype; | |
5665 | +} | |
5666 | + | |
5667 | +static VALUE VertexBuffer_get_vertex_count( VALUE self ) | |
5668 | +{ | |
5669 | + struct DXRubyVertexBuffer *vb = DXRUBY_GET_STRUCT( VertexBuffer, self ); | |
5670 | + D3DVERTEXBUFFER_DESC desc; | |
5671 | + DXRUBY_CHECK_DISPOSE( vb, pVertexBuffer ); | |
5672 | + | |
5673 | + vb->pVertexBuffer->lpVtbl->GetDesc( vb->pVertexBuffer, &desc ); | |
5674 | + return INT2NUM(desc.Size / vb->vertex_size); | |
5675 | +} | |
5676 | + | |
5677 | + | |
5678 | + | |
5679 | +/********************************************************************* | |
5680 | + * CustomRenderTargetクラス | |
5681 | + * | |
5682 | + * 描画周りの処理をRubyで記述できる低レベルRenderTarget。 | |
5683 | + *********************************************************************/ | |
5684 | + | |
5685 | +/*-------------------------------------------------------------------- | |
5686 | + CustomRenderTarget更新 | |
5687 | + ---------------------------------------------------------------------*/ | |
5688 | +VALUE CustomRenderTarget_update( VALUE self ) | |
5689 | +{ | |
5690 | + struct DXRubyRenderTarget *rt = DXRUBY_GET_STRUCT( RenderTarget, self ); | |
5691 | + DXRUBY_CHECK_DISPOSE( rt, surface ); | |
5692 | + RenderTarget_clear( self ); | |
5693 | + g_pD3DDevice->lpVtbl->Clear( g_pD3DDevice, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_STENCIL | D3DCLEAR_ZBUFFER, | |
5694 | + D3DCOLOR_ARGB( rt->a, rt->r, rt->g, rt->b ), 1.0f, 0 ); | |
5695 | + | |
5696 | + rb_funcall( self, SYM2ID( symbol_custom_render ), 1, mLowLevelInterface ); | |
5697 | + | |
5698 | + rt->PictureCount = 0; | |
5699 | + rt->PictureSize = 0; | |
5700 | + rt->PictureDecideCount = 0; | |
5701 | + rt->PictureDecideSize = 0; | |
5702 | + | |
5703 | + return Qnil; | |
5704 | +} | |
5705 | + | |
5706 | +VALUE LLI_set_viewport( VALUE obj, VALUE vx, VALUE vy, VALUE vwidth, VALUE vheight, VALUE vminz, VALUE vmaxz ) | |
5707 | +{ | |
5708 | + D3DVIEWPORT9 vp; | |
5709 | + | |
5710 | + vp.X = NUM2INT(vx); | |
5711 | + vp.Y = NUM2INT(vy); | |
5712 | + vp.Width = NUM2INT(vwidth); | |
5713 | + vp.Height = NUM2INT(vheight); | |
5714 | + vp.MinZ = NUM2FLOAT(vminz); | |
5715 | + vp.MaxZ = NUM2FLOAT(vmaxz); | |
5716 | + | |
5717 | + return UINT2NUM(g_pD3DDevice->lpVtbl->SetViewport( g_pD3DDevice, &vp )); | |
5718 | +} | |
5719 | + | |
5720 | +VALUE LLI_begin_scene( VALUE obj ) | |
5721 | +{ | |
5722 | + return UINT2NUM(g_pD3DDevice->lpVtbl->BeginScene( g_pD3DDevice )); | |
5723 | +} | |
5724 | + | |
5725 | +VALUE LLI_end_scene( VALUE obj ) | |
5726 | +{ | |
5727 | + return UINT2NUM(g_pD3DDevice->lpVtbl->EndScene( g_pD3DDevice )); | |
5728 | +} | |
5729 | + | |
5730 | +VALUE LLI_set_fvf( VALUE obj, VALUE vfvf ) | |
5731 | +{ | |
5732 | + return UINT2NUM(g_pD3DDevice->lpVtbl->SetFVF( g_pD3DDevice, NUM2UINT(vfvf) )); | |
5733 | +} | |
5734 | + | |
5735 | +VALUE LLI_set_stream( int argc, VALUE *argv, VALUE obj ) | |
5736 | +{ | |
5737 | + int i, size; | |
5738 | + | |
5739 | + /* 引数は全て頂点バッファであり、disposeされておらず、初期化されていること */ | |
5740 | + for( i = 0; i < argc; i++ ) | |
5741 | + { | |
5742 | + struct DXRubyVertexBuffer *vb; | |
5743 | + DXRUBY_CHECK_TYPE( VertexBuffer, argv[i] ); | |
5744 | + vb = DXRUBY_GET_STRUCT( VertexBuffer, argv[i] ); | |
5745 | + DXRUBY_CHECK_DISPOSE( vb, pVertexBuffer ); | |
5746 | + if( vb->pVertexBuffer == (LPDIRECT3DVERTEXBUFFER9)vb ) rb_raise( eDXRubyError, "VertexBuffer object is not initialize. - LLI_set_stream" ); | |
5747 | + } | |
5748 | + | |
5749 | + size = 0; | |
5750 | + | |
5751 | + /* エレメント構造体の必要サイズを算出する */ | |
5752 | + for( i = 0; i < argc; i++ ) | |
5753 | + { | |
5754 | + struct DXRubyVertexBuffer *vb = DXRUBY_GET_STRUCT( VertexBuffer, argv[i] ); | |
5755 | + size += RARRAY_LEN(vb->vtype); | |
5756 | + } | |
5757 | + | |
5758 | + { | |
5759 | + int j, k = 0; | |
5760 | + D3DVERTEXELEMENT9 *decl = alloca(sizeof(D3DVERTEXELEMENT9) * (size+1)); | |
5761 | + | |
5762 | + /* 頂点情報のセット */ | |
5763 | + for( i = 0; i < argc; i++ ) | |
5764 | + { | |
5765 | + struct DXRubyVertexBuffer *vb = DXRUBY_GET_STRUCT( VertexBuffer, argv[i] ); | |
5766 | + int offset = 0; | |
5767 | + | |
5768 | + for( j = 0; j < RARRAY_LEN(vb->vtype); j++ ) | |
5769 | + { | |
5770 | + VALUE vtypeary = rb_ary_entry(vb->vtype, j); | |
5771 | + decl[k].Stream = i; | |
5772 | + decl[k].Offset = offset; | |
5773 | + decl[k].Type = NUM2INT(rb_ary_entry(vtypeary, 0)); | |
5774 | + decl[k].Method = D3DDECLMETHOD_DEFAULT; | |
5775 | + decl[k].Usage = NUM2INT(rb_ary_entry(vtypeary, 1)); | |
5776 | + decl[k].UsageIndex = NUM2INT(rb_ary_entry(vtypeary, 2)); | |
5777 | + k++; | |
5778 | + | |
5779 | + switch(NUM2INT(rb_ary_entry(vtypeary, 0))) { | |
5780 | + case D3DDECLTYPE_FLOAT1: | |
5781 | + case D3DDECLTYPE_UBYTE4: | |
5782 | + case D3DDECLTYPE_D3DCOLOR: | |
5783 | + offset += 4; | |
5784 | + break; | |
5785 | + case D3DDECLTYPE_FLOAT2: | |
5786 | + offset += 8; | |
5787 | + break; | |
5788 | + case D3DDECLTYPE_FLOAT3: | |
5789 | + offset += 12; | |
5790 | + break; | |
5791 | + case D3DDECLTYPE_FLOAT4: | |
5792 | + offset += 16; | |
5793 | + break; | |
5794 | + default: | |
5795 | + break; | |
5796 | + } | |
5797 | + } | |
5798 | + | |
5799 | + } | |
5800 | + | |
5801 | + /* 頂点の終端 */ | |
5802 | + decl[size].Stream = 0xff; | |
5803 | + decl[size].Offset = 0; | |
5804 | + decl[size].Type = D3DDECLTYPE_UNUSED; | |
5805 | + decl[size].Method = 0; | |
5806 | + decl[size].Usage = 0; | |
5807 | + decl[size].UsageIndex = 0; | |
5808 | + | |
5809 | + /* 頂点情報の定義 */ | |
5810 | + { | |
5811 | + LPDIRECT3DVERTEXDECLARATION9 pVertexDeclaration; | |
5812 | + g_pD3DDevice->lpVtbl->CreateVertexDeclaration( g_pD3DDevice, decl, &pVertexDeclaration ); | |
5813 | + g_pD3DDevice->lpVtbl->SetVertexDeclaration( g_pD3DDevice, pVertexDeclaration ); | |
5814 | + | |
5815 | + for( i = 0; i < argc; i++ ) | |
5816 | + { | |
5817 | + struct DXRubyVertexBuffer *vb = DXRUBY_GET_STRUCT( VertexBuffer, argv[i] ); | |
5818 | + g_pD3DDevice->lpVtbl->SetStreamSource( g_pD3DDevice, i, vb->pVertexBuffer, 0, vb->vertex_size ); | |
5819 | + } | |
5820 | + | |
5821 | + RELEASE( pVertexDeclaration ); | |
5822 | + } | |
5823 | + } | |
5824 | + | |
5825 | + return Qnil; | |
5826 | +} | |
5827 | + | |
5828 | +VALUE LLI_draw_primitive_up( VALUE obj, VALUE vtype, VALUE vcount, VALUE vstr, VALUE vstride ) | |
5829 | +{ | |
5830 | + Check_Type( vstr, T_STRING ); | |
5831 | + return UINT2NUM(g_pD3DDevice->lpVtbl->DrawPrimitiveUP( g_pD3DDevice, NUM2INT(vtype), NUM2UINT(vcount), RSTRING_PTR(vstr), NUM2UINT(vstride) )); | |
5832 | +} | |
5833 | + | |
5834 | +VALUE LLI_draw_primitive( VALUE obj, VALUE vtype, VALUE vcount ) | |
5835 | +{ | |
5836 | + return UINT2NUM(g_pD3DDevice->lpVtbl->DrawPrimitive( g_pD3DDevice, NUM2INT(vtype), 0, NUM2UINT(vcount) )); | |
5837 | +} | |
5838 | + | |
5839 | +VALUE LLI_using_shader( VALUE obj, VALUE vshader ) | |
5840 | +{ | |
5841 | + struct DXRubyShader *shader; | |
5842 | + struct DXRubyShaderCore *core; | |
5843 | + int i, pass; | |
5844 | + | |
5845 | + DXRUBY_CHECK_TYPE( Shader, vshader ); | |
5846 | + | |
5847 | + shader = DXRUBY_GET_STRUCT( Shader, vshader ); | |
5848 | + core = DXRUBY_GET_STRUCT( ShaderCore, shader->vcore ); | |
5849 | + | |
5850 | + DXRUBY_CHECK_DISPOSE( core, pD3DXEffect ); | |
5851 | + | |
5852 | + | |
5853 | + rb_hash_foreach( shader->vparam, Window_drawShader_func_foreach, shader->vcore ); | |
5854 | + | |
5855 | + core->pD3DXEffect->lpVtbl->Begin( core->pD3DXEffect, &pass, 0 ); | |
5856 | + for( i = 0; i < pass; i++ ) | |
5857 | + { | |
5858 | + /* 描画 */ | |
5859 | + core->pD3DXEffect->lpVtbl->BeginPass( core->pD3DXEffect, i ); | |
5860 | + rb_yield( obj ); | |
5861 | + core->pD3DXEffect->lpVtbl->EndPass( core->pD3DXEffect ); | |
5862 | + } | |
5863 | + core->pD3DXEffect->lpVtbl->End( core->pD3DXEffect ); | |
5864 | + | |
5865 | + return Qnil; | |
5866 | +} | |
5867 | + | |
5868 | +VALUE LLI_set_render_state( VALUE obj, VALUE vstate, VALUE vvalue ) | |
5869 | +{ | |
5870 | + return UINT2NUM(g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, NUM2UINT(vstate), NUM2UINT(vvalue) )); | |
5871 | +} | |
5872 | + | |
5873 | + | |
5874 | + | |
5196 | 5875 | /* |
5197 | 5876 | *************************************************************** |
5198 | 5877 | * |
@@ -5340,9 +6019,6 @@ | ||
5340 | 6019 | rb_define_singleton_method( mWindow, "ox=" , Window_setOx , 1 ); |
5341 | 6020 | rb_define_singleton_method( mWindow, "oy" , Window_getOy, 0 ); |
5342 | 6021 | rb_define_singleton_method( mWindow, "oy=" , Window_setOy, 1 ); |
5343 | -#ifdef DXRUBY15 | |
5344 | - rb_define_singleton_method( mWindow, "test_device_lost" , Window_test_device_lost, 0 ); | |
5345 | -#endif | |
5346 | 6022 | // rb_define_singleton_method( mWindow, "to_image", Window_to_image, 0 ); |
5347 | 6023 | // rb_define_singleton_method( mWindow, "toImage", Window_to_image, 0 ); |
5348 | 6024 |
@@ -5447,12 +6123,6 @@ | ||
5447 | 6123 | rb_define_method( cRenderTarget, "ox=" , RenderTarget_setOx , 1 ); |
5448 | 6124 | rb_define_method( cRenderTarget, "oy" , RenderTarget_getOy, 0 ); |
5449 | 6125 | rb_define_method( cRenderTarget, "oy=" , RenderTarget_setOy, 1 ); |
5450 | -#ifdef DXRUBY15 | |
5451 | - rb_define_method( cRenderTarget, "regenerate_proc" , RenderTarget_getRegenerateProc , 0 ); | |
5452 | - rb_define_method( cRenderTarget, "regenerate_proc=", RenderTarget_setRegenerateProc , 1 ); | |
5453 | - rb_define_method( cRenderTarget, "regenerateProc" , RenderTarget_getRegenerateProc , 0 ); | |
5454 | - rb_define_method( cRenderTarget, "regenerateProc=", RenderTarget_setRegenerateProc , 1 ); | |
5455 | -#endif | |
5456 | 6126 | rb_define_method( cRenderTarget, "clear" , RenderTarget_clear, 0 ); |
5457 | 6127 | |
5458 | 6128 | rb_define_method( cRenderTarget, "draw_shader", RenderTarget_drawShader, -1 ); |
@@ -5463,6 +6133,271 @@ | ||
5463 | 6133 | rb_define_alloc_func( cRenderTarget, RenderTarget_allocate ); |
5464 | 6134 | |
5465 | 6135 | |
6136 | + /* CustomRenderTargetクラス定義 */ | |
6137 | + cCustomRenderTarget = rb_define_class_under( mDXRuby, "CustomRenderTarget", cRenderTarget ); | |
6138 | + rb_define_method( cCustomRenderTarget, "update" , CustomRenderTarget_update , 0 ); | |
6139 | + | |
6140 | + rb_define_const( cCustomRenderTarget, "D3DFVF_RESERVED0", INT2NUM(D3DFVF_RESERVED0)); | |
6141 | + rb_define_const( cCustomRenderTarget, "D3DFVF_POSITION_MASK", INT2NUM(D3DFVF_POSITION_MASK)); | |
6142 | + rb_define_const( cCustomRenderTarget, "D3DFVF_XYZ", INT2NUM(D3DFVF_XYZ)); | |
6143 | + rb_define_const( cCustomRenderTarget, "D3DFVF_XYZRHW", INT2NUM(D3DFVF_XYZRHW)); | |
6144 | + rb_define_const( cCustomRenderTarget, "D3DFVF_XYZB1", INT2NUM(D3DFVF_XYZB1)); | |
6145 | + rb_define_const( cCustomRenderTarget, "D3DFVF_XYZB2", INT2NUM(D3DFVF_XYZB2)); | |
6146 | + rb_define_const( cCustomRenderTarget, "D3DFVF_XYZB3", INT2NUM(D3DFVF_XYZB3)); | |
6147 | + rb_define_const( cCustomRenderTarget, "D3DFVF_XYZB4", INT2NUM(D3DFVF_XYZB4)); | |
6148 | + rb_define_const( cCustomRenderTarget, "D3DFVF_XYZB5", INT2NUM(D3DFVF_XYZB5)); | |
6149 | + rb_define_const( cCustomRenderTarget, "D3DFVF_NORMAL", INT2NUM(D3DFVF_NORMAL)); | |
6150 | + rb_define_const( cCustomRenderTarget, "D3DFVF_PSIZE", INT2NUM(D3DFVF_PSIZE)); | |
6151 | + rb_define_const( cCustomRenderTarget, "D3DFVF_DIFFUSE", INT2NUM(D3DFVF_DIFFUSE)); | |
6152 | + rb_define_const( cCustomRenderTarget, "D3DFVF_SPECULAR", INT2NUM(D3DFVF_SPECULAR)); | |
6153 | + rb_define_const( cCustomRenderTarget, "D3DFVF_TEXCOUNT_MASK", INT2NUM(D3DFVF_TEXCOUNT_MASK)); | |
6154 | + rb_define_const( cCustomRenderTarget, "D3DFVF_TEXCOUNT_SHIFT", INT2NUM(D3DFVF_TEXCOUNT_SHIFT)); | |
6155 | + rb_define_const( cCustomRenderTarget, "D3DFVF_TEX0", INT2NUM(D3DFVF_TEX0)); | |
6156 | + rb_define_const( cCustomRenderTarget, "D3DFVF_TEX1", INT2NUM(D3DFVF_TEX1)); | |
6157 | + rb_define_const( cCustomRenderTarget, "D3DFVF_TEX2", INT2NUM(D3DFVF_TEX2)); | |
6158 | + rb_define_const( cCustomRenderTarget, "D3DFVF_TEX3", INT2NUM(D3DFVF_TEX3)); | |
6159 | + rb_define_const( cCustomRenderTarget, "D3DFVF_TEX4", INT2NUM(D3DFVF_TEX4)); | |
6160 | + rb_define_const( cCustomRenderTarget, "D3DFVF_TEX5", INT2NUM(D3DFVF_TEX5)); | |
6161 | + rb_define_const( cCustomRenderTarget, "D3DFVF_TEX6", INT2NUM(D3DFVF_TEX6)); | |
6162 | + rb_define_const( cCustomRenderTarget, "D3DFVF_TEX7", INT2NUM(D3DFVF_TEX7)); | |
6163 | + rb_define_const( cCustomRenderTarget, "D3DFVF_TEX8", INT2NUM(D3DFVF_TEX8)); | |
6164 | + rb_define_const( cCustomRenderTarget, "D3DFVF_LASTBETA_UBYTE4", INT2NUM(D3DFVF_LASTBETA_UBYTE4)); | |
6165 | + rb_define_const( cCustomRenderTarget, "D3DFVF_RESERVED2", INT2NUM(D3DFVF_RESERVED2)); | |
6166 | + | |
6167 | + rb_define_const( mDXRuby, "D3DDECLTYPE_FLOAT1", INT2NUM(D3DDECLTYPE_FLOAT1)); | |
6168 | + rb_define_const( mDXRuby, "D3DDECLTYPE_FLOAT2", INT2NUM(D3DDECLTYPE_FLOAT2)); | |
6169 | + rb_define_const( mDXRuby, "D3DDECLTYPE_FLOAT3", INT2NUM(D3DDECLTYPE_FLOAT3)); | |
6170 | + rb_define_const( mDXRuby, "D3DDECLTYPE_FLOAT4", INT2NUM(D3DDECLTYPE_FLOAT4)); | |
6171 | + rb_define_const( mDXRuby, "D3DDECLTYPE_D3DCOLOR", INT2NUM(D3DDECLTYPE_D3DCOLOR)); | |
6172 | + rb_define_const( mDXRuby, "D3DDECLTYPE_UBYTE4", INT2NUM(D3DDECLTYPE_UBYTE4)); | |
6173 | + rb_define_const( mDXRuby, "D3DDECLTYPE_SHORT2", INT2NUM(D3DDECLTYPE_SHORT2)); | |
6174 | + rb_define_const( mDXRuby, "D3DDECLTYPE_SHORT4", INT2NUM(D3DDECLTYPE_SHORT4)); | |
6175 | + rb_define_const( mDXRuby, "D3DDECLTYPE_UBYTE4N", INT2NUM(D3DDECLTYPE_UBYTE4N)); | |
6176 | + rb_define_const( mDXRuby, "D3DDECLTYPE_SHORT2N", INT2NUM(D3DDECLTYPE_SHORT2N)); | |
6177 | + rb_define_const( mDXRuby, "D3DDECLTYPE_SHORT4N", INT2NUM(D3DDECLTYPE_SHORT4N)); | |
6178 | + rb_define_const( mDXRuby, "D3DDECLTYPE_USHORT2N", INT2NUM(D3DDECLTYPE_USHORT2N)); | |
6179 | + rb_define_const( mDXRuby, "D3DDECLTYPE_USHORT4N", INT2NUM(D3DDECLTYPE_USHORT4N)); | |
6180 | + rb_define_const( mDXRuby, "D3DDECLTYPE_UDEC3", INT2NUM(D3DDECLTYPE_UDEC3)); | |
6181 | + rb_define_const( mDXRuby, "D3DDECLTYPE_DEC3N", INT2NUM(D3DDECLTYPE_DEC3N)); | |
6182 | + rb_define_const( mDXRuby, "D3DDECLTYPE_FLOAT16_2", INT2NUM(D3DDECLTYPE_FLOAT16_2)); | |
6183 | + rb_define_const( mDXRuby, "D3DDECLTYPE_FLOAT16_4", INT2NUM(D3DDECLTYPE_FLOAT16_4)); | |
6184 | + rb_define_const( mDXRuby, "D3DDECLTYPE_UNUSED", INT2NUM(D3DDECLTYPE_UNUSED)); | |
6185 | + | |
6186 | + rb_define_const( mDXRuby, "D3DDECLUSAGE_POSITION", INT2NUM(D3DDECLUSAGE_POSITION)); | |
6187 | + rb_define_const( mDXRuby, "D3DDECLUSAGE_BLENDWEIGHT", INT2NUM(D3DDECLUSAGE_BLENDWEIGHT)); | |
6188 | + rb_define_const( mDXRuby, "D3DDECLUSAGE_BLENDINDICES", INT2NUM(D3DDECLUSAGE_BLENDINDICES)); | |
6189 | + rb_define_const( mDXRuby, "D3DDECLUSAGE_NORMAL", INT2NUM(D3DDECLUSAGE_NORMAL)); | |
6190 | + rb_define_const( mDXRuby, "D3DDECLUSAGE_PSIZE", INT2NUM(D3DDECLUSAGE_PSIZE)); | |
6191 | + rb_define_const( mDXRuby, "D3DDECLUSAGE_TEXCOORD", INT2NUM(D3DDECLUSAGE_TEXCOORD)); | |
6192 | + rb_define_const( mDXRuby, "D3DDECLUSAGE_TANGENT", INT2NUM(D3DDECLUSAGE_TANGENT)); | |
6193 | + rb_define_const( mDXRuby, "D3DDECLUSAGE_BINORMAL", INT2NUM(D3DDECLUSAGE_BINORMAL)); | |
6194 | + rb_define_const( mDXRuby, "D3DDECLUSAGE_TESSFACTOR", INT2NUM(D3DDECLUSAGE_TESSFACTOR)); | |
6195 | + rb_define_const( mDXRuby, "D3DDECLUSAGE_POSITIONT", INT2NUM(D3DDECLUSAGE_POSITIONT)); | |
6196 | + rb_define_const( mDXRuby, "D3DDECLUSAGE_COLOR", INT2NUM(D3DDECLUSAGE_COLOR)); | |
6197 | + rb_define_const( mDXRuby, "D3DDECLUSAGE_FOG", INT2NUM(D3DDECLUSAGE_FOG)); | |
6198 | + rb_define_const( mDXRuby, "D3DDECLUSAGE_DEPTH", INT2NUM(D3DDECLUSAGE_DEPTH)); | |
6199 | + rb_define_const( mDXRuby, "D3DDECLUSAGE_SAMPLE", INT2NUM(D3DDECLUSAGE_SAMPLE)); | |
6200 | + | |
6201 | + rb_define_const( cCustomRenderTarget, "D3DPT_POINTLIST", INT2NUM(D3DPT_POINTLIST)); | |
6202 | + rb_define_const( cCustomRenderTarget, "D3DPT_LINELIST", INT2NUM(D3DPT_LINELIST)); | |
6203 | + rb_define_const( cCustomRenderTarget, "D3DPT_LINESTRIP", INT2NUM(D3DPT_LINESTRIP)); | |
6204 | + rb_define_const( cCustomRenderTarget, "D3DPT_TRIANGLELIST", INT2NUM(D3DPT_TRIANGLELIST)); | |
6205 | + rb_define_const( cCustomRenderTarget, "D3DPT_TRIANGLESTRIP", INT2NUM(D3DPT_TRIANGLESTRIP)); | |
6206 | + rb_define_const( cCustomRenderTarget, "D3DPT_TRIANGLEFAN", INT2NUM(D3DPT_TRIANGLEFAN)); | |
6207 | + | |
6208 | + rb_define_const( cCustomRenderTarget, "D3DRS_ZENABLE", INT2NUM(D3DRS_ZENABLE)); | |
6209 | + rb_define_const( cCustomRenderTarget, "D3DRS_FILLMODE", INT2NUM(D3DRS_FILLMODE)); | |
6210 | + rb_define_const( cCustomRenderTarget, "D3DRS_SHADEMODE", INT2NUM(D3DRS_SHADEMODE)); | |
6211 | + rb_define_const( cCustomRenderTarget, "D3DRS_ZWRITEENABLE", INT2NUM(D3DRS_ZWRITEENABLE)); | |
6212 | + rb_define_const( cCustomRenderTarget, "D3DRS_ALPHATESTENABLE", INT2NUM(D3DRS_ALPHATESTENABLE)); | |
6213 | + rb_define_const( cCustomRenderTarget, "D3DRS_LASTPIXEL", INT2NUM(D3DRS_LASTPIXEL)); | |
6214 | + rb_define_const( cCustomRenderTarget, "D3DRS_SRCBLEND", INT2NUM(D3DRS_SRCBLEND)); | |
6215 | + rb_define_const( cCustomRenderTarget, "D3DRS_DESTBLEND", INT2NUM(D3DRS_DESTBLEND)); | |
6216 | + rb_define_const( cCustomRenderTarget, "D3DRS_CULLMODE", INT2NUM(D3DRS_CULLMODE)); | |
6217 | + rb_define_const( cCustomRenderTarget, "D3DRS_ZFUNC", INT2NUM(D3DRS_ZFUNC)); | |
6218 | + rb_define_const( cCustomRenderTarget, "D3DRS_ALPHAREF", INT2NUM(D3DRS_ALPHAREF)); | |
6219 | + rb_define_const( cCustomRenderTarget, "D3DRS_ALPHAFUNC", INT2NUM(D3DRS_ALPHAFUNC)); | |
6220 | + rb_define_const( cCustomRenderTarget, "D3DRS_ALPHABLENDENABLE", INT2NUM(D3DRS_ALPHABLENDENABLE)); | |
6221 | + rb_define_const( cCustomRenderTarget, "D3DRS_STENCILENABLE", INT2NUM(D3DRS_STENCILENABLE)); | |
6222 | + rb_define_const( cCustomRenderTarget, "D3DRS_STENCILFAIL", INT2NUM(D3DRS_STENCILFAIL)); | |
6223 | + rb_define_const( cCustomRenderTarget, "D3DRS_STENCILZFAIL", INT2NUM(D3DRS_STENCILZFAIL)); | |
6224 | + rb_define_const( cCustomRenderTarget, "D3DRS_STENCILPASS", INT2NUM(D3DRS_STENCILPASS)); | |
6225 | + rb_define_const( cCustomRenderTarget, "D3DRS_STENCILFUNC", INT2NUM(D3DRS_STENCILFUNC)); | |
6226 | + rb_define_const( cCustomRenderTarget, "D3DRS_STENCILREF", INT2NUM(D3DRS_STENCILREF)); | |
6227 | + rb_define_const( cCustomRenderTarget, "D3DRS_STENCILMASK", INT2NUM(D3DRS_STENCILMASK)); | |
6228 | + rb_define_const( cCustomRenderTarget, "D3DRS_STENCILWRITEMASK", INT2NUM(D3DRS_STENCILWRITEMASK)); | |
6229 | + rb_define_const( cCustomRenderTarget, "D3DRS_CLIPPING", INT2NUM(D3DRS_CLIPPING)); | |
6230 | + rb_define_const( cCustomRenderTarget, "D3DRS_COLORWRITEENABLE", INT2NUM(D3DRS_COLORWRITEENABLE)); | |
6231 | + rb_define_const( cCustomRenderTarget, "D3DRS_BLENDOP", INT2NUM(D3DRS_BLENDOP)); | |
6232 | + rb_define_const( cCustomRenderTarget, "D3DRS_ANTIALIASEDLINEENABLE", INT2NUM(D3DRS_ANTIALIASEDLINEENABLE)); | |
6233 | + rb_define_const( cCustomRenderTarget, "D3DRS_TWOSIDEDSTENCILMODE", INT2NUM(D3DRS_TWOSIDEDSTENCILMODE)); | |
6234 | + rb_define_const( cCustomRenderTarget, "D3DRS_CCW_STENCILFAIL", INT2NUM(D3DRS_CCW_STENCILFAIL)); | |
6235 | + rb_define_const( cCustomRenderTarget, "D3DRS_CCW_STENCILZFAIL", INT2NUM(D3DRS_CCW_STENCILZFAIL)); | |
6236 | + rb_define_const( cCustomRenderTarget, "D3DRS_CCW_STENCILPASS", INT2NUM(D3DRS_CCW_STENCILPASS)); | |
6237 | + rb_define_const( cCustomRenderTarget, "D3DRS_CCW_STENCILFUNC", INT2NUM(D3DRS_CCW_STENCILFUNC)); | |
6238 | + rb_define_const( cCustomRenderTarget, "D3DRS_SRCBLENDALPHA", INT2NUM(D3DRS_SRCBLENDALPHA)); | |
6239 | + rb_define_const( cCustomRenderTarget, "D3DRS_DESTBLENDALPHA", INT2NUM(D3DRS_DESTBLENDALPHA)); | |
6240 | + rb_define_const( cCustomRenderTarget, "D3DRS_BLENDOPALPHA", INT2NUM(D3DRS_BLENDOPALPHA)); | |
6241 | + rb_define_const( cCustomRenderTarget, "D3DZB_FALSE", INT2NUM(D3DZB_FALSE)); | |
6242 | + rb_define_const( cCustomRenderTarget, "D3DZB_TRUE", INT2NUM(D3DZB_TRUE)); | |
6243 | + rb_define_const( cCustomRenderTarget, "D3DZB_USEW", INT2NUM(D3DZB_USEW)); | |
6244 | + | |
6245 | + rb_define_const( cCustomRenderTarget, "D3DFILL_POINT", INT2NUM(D3DFILL_POINT)); | |
6246 | + rb_define_const( cCustomRenderTarget, "D3DFILL_WIREFRAME", INT2NUM(D3DFILL_WIREFRAME)); | |
6247 | + rb_define_const( cCustomRenderTarget, "D3DFILL_SOLID", INT2NUM(D3DFILL_SOLID)); | |
6248 | + | |
6249 | + rb_define_const( cCustomRenderTarget, "D3DSHADE_FLAT", INT2NUM(D3DSHADE_FLAT)); | |
6250 | + rb_define_const( cCustomRenderTarget, "D3DSHADE_GOURAUD", INT2NUM(D3DSHADE_GOURAUD)); | |
6251 | + rb_define_const( cCustomRenderTarget, "D3DSHADE_PHONG", INT2NUM(D3DSHADE_PHONG)); | |
6252 | + | |
6253 | + rb_define_const( cCustomRenderTarget, "D3DBLEND_ZERO", INT2NUM(D3DBLEND_ZERO)); | |
6254 | + rb_define_const( cCustomRenderTarget, "D3DBLEND_ONE", INT2NUM(D3DBLEND_ONE)); | |
6255 | + rb_define_const( cCustomRenderTarget, "D3DBLEND_SRCCOLOR", INT2NUM(D3DBLEND_SRCCOLOR)); | |
6256 | + rb_define_const( cCustomRenderTarget, "D3DBLEND_INVSRCCOLOR", INT2NUM(D3DBLEND_INVSRCCOLOR)); | |
6257 | + rb_define_const( cCustomRenderTarget, "D3DBLEND_SRCALPHA", INT2NUM(D3DBLEND_SRCALPHA)); | |
6258 | + rb_define_const( cCustomRenderTarget, "D3DBLEND_INVSRCALPHA", INT2NUM(D3DBLEND_INVSRCALPHA)); | |
6259 | + rb_define_const( cCustomRenderTarget, "D3DBLEND_DESTALPHA", INT2NUM(D3DBLEND_DESTALPHA)); | |
6260 | + rb_define_const( cCustomRenderTarget, "D3DBLEND_INVDESTALPHA", INT2NUM(D3DBLEND_INVDESTALPHA)); | |
6261 | + rb_define_const( cCustomRenderTarget, "D3DBLEND_DESTCOLOR", INT2NUM(D3DBLEND_DESTCOLOR)); | |
6262 | + rb_define_const( cCustomRenderTarget, "D3DBLEND_INVDESTCOLOR", INT2NUM(D3DBLEND_INVDESTCOLOR)); | |
6263 | + rb_define_const( cCustomRenderTarget, "D3DBLEND_SRCALPHASAT", INT2NUM(D3DBLEND_SRCALPHASAT)); | |
6264 | + rb_define_const( cCustomRenderTarget, "D3DBLEND_BOTHSRCALPHA", INT2NUM(D3DBLEND_BOTHSRCALPHA)); | |
6265 | + rb_define_const( cCustomRenderTarget, "D3DBLEND_BOTHINVSRCALPHA", INT2NUM(D3DBLEND_BOTHINVSRCALPHA)); | |
6266 | + rb_define_const( cCustomRenderTarget, "D3DBLEND_BLENDFACTOR", INT2NUM(D3DBLEND_BLENDFACTOR)); | |
6267 | + rb_define_const( cCustomRenderTarget, "D3DBLEND_INVBLENDFACTOR", INT2NUM(D3DBLEND_INVBLENDFACTOR)); | |
6268 | + | |
6269 | + rb_define_const( cCustomRenderTarget, "D3DCULL_NONE", INT2NUM(D3DCULL_NONE)); | |
6270 | + rb_define_const( cCustomRenderTarget, "D3DCULL_CW", INT2NUM(D3DCULL_CW)); | |
6271 | + rb_define_const( cCustomRenderTarget, "D3DCULL_CCW", INT2NUM(D3DCULL_CCW)); | |
6272 | + | |
6273 | + rb_define_const( cCustomRenderTarget, "D3DCMP_NEVER", INT2NUM(D3DCMP_NEVER)); | |
6274 | + rb_define_const( cCustomRenderTarget, "D3DCMP_LESS", INT2NUM(D3DCMP_LESS)); | |
6275 | + rb_define_const( cCustomRenderTarget, "D3DCMP_EQUAL", INT2NUM(D3DCMP_EQUAL)); | |
6276 | + rb_define_const( cCustomRenderTarget, "D3DCMP_LESSEQUAL", INT2NUM(D3DCMP_LESSEQUAL)); | |
6277 | + rb_define_const( cCustomRenderTarget, "D3DCMP_GREATER", INT2NUM(D3DCMP_GREATER)); | |
6278 | + rb_define_const( cCustomRenderTarget, "D3DCMP_NOTEQUAL", INT2NUM(D3DCMP_NOTEQUAL)); | |
6279 | + rb_define_const( cCustomRenderTarget, "D3DCMP_GREATEREQUAL", INT2NUM(D3DCMP_GREATEREQUAL)); | |
6280 | + rb_define_const( cCustomRenderTarget, "D3DCMP_ALWAYS", INT2NUM(D3DCMP_ALWAYS)); | |
6281 | + | |
6282 | + rb_define_const( cCustomRenderTarget, "D3DSTENCILOP_KEEP", INT2NUM(D3DSTENCILOP_KEEP)); | |
6283 | + rb_define_const( cCustomRenderTarget, "D3DSTENCILOP_ZERO", INT2NUM(D3DSTENCILOP_ZERO)); | |
6284 | + rb_define_const( cCustomRenderTarget, "D3DSTENCILOP_REPLACE", INT2NUM(D3DSTENCILOP_REPLACE)); | |
6285 | + rb_define_const( cCustomRenderTarget, "D3DSTENCILOP_INCRSAT", INT2NUM(D3DSTENCILOP_INCRSAT)); | |
6286 | + rb_define_const( cCustomRenderTarget, "D3DSTENCILOP_DECRSAT", INT2NUM(D3DSTENCILOP_DECRSAT)); | |
6287 | + rb_define_const( cCustomRenderTarget, "D3DSTENCILOP_INVERT", INT2NUM(D3DSTENCILOP_INVERT)); | |
6288 | + rb_define_const( cCustomRenderTarget, "D3DSTENCILOP_INCR", INT2NUM(D3DSTENCILOP_INCR)); | |
6289 | + rb_define_const( cCustomRenderTarget, "D3DSTENCILOP_DECR", INT2NUM(D3DSTENCILOP_DECR)); | |
6290 | + | |
6291 | + rb_define_const( cCustomRenderTarget, "D3DBLENDOP_ADD", INT2NUM(D3DBLENDOP_ADD)); | |
6292 | + rb_define_const( cCustomRenderTarget, "D3DBLENDOP_SUBTRACT", INT2NUM(D3DBLENDOP_SUBTRACT)); | |
6293 | + rb_define_const( cCustomRenderTarget, "D3DBLENDOP_REVSUBTRACT", INT2NUM(D3DBLENDOP_REVSUBTRACT)); | |
6294 | + rb_define_const( cCustomRenderTarget, "D3DBLENDOP_MIN", INT2NUM(D3DBLENDOP_MIN)); | |
6295 | + rb_define_const( cCustomRenderTarget, "D3DBLENDOP_MAX", INT2NUM(D3DBLENDOP_MAX)); | |
6296 | + | |
6297 | + rb_define_const( cCustomRenderTarget, "D3DCOLORWRITEENABLE_RED", INT2NUM(D3DCOLORWRITEENABLE_RED)); | |
6298 | + rb_define_const( cCustomRenderTarget, "D3DCOLORWRITEENABLE_GREEN", INT2NUM(D3DCOLORWRITEENABLE_GREEN)); | |
6299 | + rb_define_const( cCustomRenderTarget, "D3DCOLORWRITEENABLE_BLUE", INT2NUM(D3DCOLORWRITEENABLE_BLUE)); | |
6300 | + rb_define_const( cCustomRenderTarget, "D3DCOLORWRITEENABLE_ALPHA", INT2NUM(D3DCOLORWRITEENABLE_ALPHA)); | |
6301 | + | |
6302 | + | |
6303 | + | |
6304 | + /* LowLevelInterfaceモジュール定義 */ | |
6305 | + mLowLevelInterface = rb_module_new(); | |
6306 | + rb_define_singleton_method( mLowLevelInterface, "set_viewport", LLI_set_viewport, 6 ); | |
6307 | + rb_define_singleton_method( mLowLevelInterface, "begin_scene", LLI_begin_scene, 0 ); | |
6308 | + rb_define_singleton_method( mLowLevelInterface, "end_scene", LLI_end_scene, 0 ); | |
6309 | + rb_define_singleton_method( mLowLevelInterface, "set_fvf", LLI_set_fvf, 1 ); | |
6310 | + rb_define_singleton_method( mLowLevelInterface, "set_stream", LLI_set_stream, -1 ); | |
6311 | + rb_define_singleton_method( mLowLevelInterface, "draw_primitive_up", LLI_draw_primitive_up, 4 ); | |
6312 | + rb_define_singleton_method( mLowLevelInterface, "draw_primitive", LLI_draw_primitive, 2 ); | |
6313 | + rb_define_singleton_method( mLowLevelInterface, "using_shader", LLI_using_shader, 1 ); | |
6314 | + rb_define_singleton_method( mLowLevelInterface, "set_render_state", LLI_set_render_state, 2 ); | |
6315 | + rb_global_variable( &mLowLevelInterface ); | |
6316 | + | |
6317 | + | |
6318 | + | |
6319 | + /* VertexBufferクラス定義 */ | |
6320 | + cVertexBuffer = rb_define_class_under( mDXRuby, "VertexBuffer", rb_cObject ); | |
6321 | + | |
6322 | + /* RenderTargetクラスにメソッド登録*/ | |
6323 | + rb_define_private_method( cVertexBuffer, "initialize", VertexBuffer_initialize, 1 ); | |
6324 | + rb_define_method( cVertexBuffer, "dispose" , VertexBuffer_dispose , 0 ); | |
6325 | + rb_define_method( cVertexBuffer, "disposed?" , VertexBuffer_check_disposed, 0 ); | |
6326 | + | |
6327 | + rb_define_method( cVertexBuffer, "buf=" , VertexBuffer_set_buf , 1 ); | |
6328 | + rb_define_method( cVertexBuffer, "buf" , VertexBuffer_get_buf , 0 ); | |
6329 | + rb_define_method( cVertexBuffer, "byte_size" , VertexBuffer_get_size , 0 ); | |
6330 | + rb_define_method( cVertexBuffer, "vertex_count" , VertexBuffer_get_vertex_count, 0 ); | |
6331 | + rb_define_method( cVertexBuffer, "vertices=", VertexBuffer_set_vertices , 1 ); | |
6332 | + rb_define_method( cVertexBuffer, "vertices" , VertexBuffer_get_vertices , 0 ); | |
6333 | + rb_define_method( cVertexBuffer, "vertex_type" , VertexBuffer_get_vertex_type , 0 ); | |
6334 | + | |
6335 | + /* VertexBufferオブジェクトを生成した時にinitializeの前に呼ばれるメモリ割り当て関数登録 */ | |
6336 | + rb_define_alloc_func( cVertexBuffer, VertexBuffer_allocate ); | |
6337 | + | |
6338 | + | |
6339 | + /* Viewportクラス定義 */ | |
6340 | + cViewport = rb_define_class_under( mDXRuby, "Viewport", rb_cObject ); | |
6341 | + | |
6342 | + /* Viewportクラスにメソッド登録*/ | |
6343 | + rb_define_private_method( cViewport, "initialize", Viewport_initialize, -1 ); | |
6344 | + rb_define_method( cViewport, "width" , RenderTarget_getWidth , 0 ); | |
6345 | + rb_define_method( cViewport, "height" , RenderTarget_getHeight , 0 ); | |
6346 | + rb_define_method( cViewport, "resize" , Viewport_resize , 2 ); | |
6347 | + rb_define_method( cViewport, "draw" , RenderTarget_draw , -1 ); | |
6348 | +// rb_define_method( cRenderTarget, "draw_scale", RenderTarget_drawScale , -1 ); | |
6349 | +// rb_define_method( cRenderTarget, "drawScale", RenderTarget_drawScale , -1 ); | |
6350 | +// rb_define_method( cRenderTarget, "draw_rot" , RenderTarget_drawRot , -1 ); | |
6351 | +// rb_define_method( cRenderTarget, "drawRot" , RenderTarget_drawRot , -1 ); | |
6352 | +// rb_define_method( cRenderTarget, "draw_alpha", RenderTarget_drawAlpha , -1 ); | |
6353 | +// rb_define_method( cRenderTarget, "drawAlpha", RenderTarget_drawAlpha , -1 ); | |
6354 | +// rb_define_method( cRenderTarget, "draw_add" , RenderTarget_drawAdd , -1 ); | |
6355 | +// rb_define_method( cRenderTarget, "drawAdd" , RenderTarget_drawAdd , -1 ); | |
6356 | +// rb_define_method( cRenderTarget, "draw_sub" , RenderTarget_drawSub , -1 ); | |
6357 | +// rb_define_method( cRenderTarget, "drawSub" , RenderTarget_drawSub , -1 ); | |
6358 | +// rb_define_method( cRenderTarget, "draw_ex" , RenderTarget_drawEx , -1 ); | |
6359 | +// rb_define_method( cRenderTarget, "drawEx" , RenderTarget_drawEx , -1 ); | |
6360 | +// rb_define_method( cRenderTarget, "draw_font", RenderTarget_drawFont , -1 ); | |
6361 | +// rb_define_method( cRenderTarget, "drawFont" , RenderTarget_drawFont , -1 ); | |
6362 | +// rb_define_method( cRenderTarget, "draw_font_ex", RenderTarget_drawFontEx , -1 ); | |
6363 | +// rb_define_method( cRenderTarget, "drawFontEx" , RenderTarget_drawFontEx , -1 ); | |
6364 | +// rb_define_method( cRenderTarget, "draw_text", RenderTarget_drawFont , -1 ); | |
6365 | +// rb_define_method( cRenderTarget, "drawText" , RenderTarget_drawFont , -1 ); | |
6366 | +// rb_define_method( cRenderTarget, "draw_text_ex", RenderTarget_drawFontEx , -1 ); | |
6367 | +// rb_define_method( cRenderTarget, "drawTextEx" , RenderTarget_drawFontEx , -1 ); | |
6368 | +// rb_define_method( cRenderTarget, "draw_tile", RenderTarget_drawTile , -1 ); | |
6369 | +// rb_define_method( cRenderTarget, "drawTile" , RenderTarget_drawTile , -1 ); | |
6370 | +// rb_define_method( cRenderTarget, "draw_tiles", RenderTarget_drawTile , -1 ); | |
6371 | +// rb_define_method( cRenderTarget, "drawTiles" , RenderTarget_drawTile , -1 ); | |
6372 | +// rb_define_method( cRenderTarget, "draw_morph", RenderTarget_drawMorph , -1 ); | |
6373 | +// rb_define_method( cRenderTarget, "drawMorph" , RenderTarget_drawMorph , -1 ); | |
6374 | +// rb_define_method( cRenderTarget, "draw_pixel", RenderTarget_drawPixel , -1 ); | |
6375 | +// rb_define_method( cRenderTarget, "drawPixel" , RenderTarget_drawPixel , -1 ); | |
6376 | +// rb_define_method( cRenderTarget, "draw_line" , RenderTarget_drawLine , -1 ); | |
6377 | +// rb_define_method( cRenderTarget, "drawLine" , RenderTarget_drawLine , -1 ); | |
6378 | +// rb_define_method( cRenderTarget, "draw_box" , RenderTarget_drawBox , -1 ); | |
6379 | +// rb_define_method( cRenderTarget, "drawBox" , RenderTarget_drawBox , -1 ); | |
6380 | +// rb_define_method( cRenderTarget, "draw_box_fill" , RenderTarget_drawBoxFill , -1 ); | |
6381 | +// rb_define_method( cRenderTarget, "drawBoxFill" , RenderTarget_drawBoxFill , -1 ); | |
6382 | +// rb_define_method( cRenderTarget, "draw_circle" , RenderTarget_drawCircle , -1 ); | |
6383 | +// rb_define_method( cRenderTarget, "drawCircle" , RenderTarget_drawCircle , -1 ); | |
6384 | +// rb_define_method( cRenderTarget, "draw_circle_fill", RenderTarget_drawCircleFill , -1 ); | |
6385 | +// rb_define_method( cRenderTarget, "drawCircleFill" , RenderTarget_drawCircleFill , -1 ); | |
6386 | +// rb_define_method( cRenderTarget, "update" , RenderTarget_update , 0 ); | |
6387 | +// rb_define_method( cRenderTarget, "decide" , RenderTarget_decide , 0 ); | |
6388 | +// rb_define_method( cRenderTarget, "discard" , RenderTarget_discard , 0 ); | |
6389 | + rb_define_method( cViewport, "ox" , RenderTarget_getOx , 0 ); | |
6390 | + rb_define_method( cViewport, "ox=" , RenderTarget_setOx , 1 ); | |
6391 | + rb_define_method( cViewport, "oy" , RenderTarget_getOy, 0 ); | |
6392 | + rb_define_method( cViewport, "oy=" , RenderTarget_setOy, 1 ); | |
6393 | +// rb_define_method( cRenderTarget, "draw_shader", RenderTarget_drawShader, -1 ); | |
6394 | +// rb_define_method( cRenderTarget, "drawShader" , RenderTarget_drawShader, -1 ); | |
6395 | + | |
6396 | + /* Viewportオブジェクトを生成した時にinitializeの前に呼ばれるメモリ割り当て関数登録 */ | |
6397 | + rb_define_alloc_func( cViewport, Viewport_allocate ); | |
6398 | + | |
6399 | + | |
6400 | + | |
5466 | 6401 | rb_define_const( mDXRuby, "FORMAT_JPEG" , INT2FIX(FORMAT_JPEG)); |
5467 | 6402 | rb_define_const( mDXRuby, "FORMAT_JPG" , INT2FIX(FORMAT_JPG) ); |
5468 | 6403 | rb_define_const( mDXRuby, "FORMAT_PNG" , INT2FIX(FORMAT_PNG) ); |
@@ -5536,6 +6471,8 @@ | ||
5536 | 6471 | symbol_discard = ID2SYM(rb_intern("discard")); |
5537 | 6472 | symbol_aa = ID2SYM(rb_intern("aa")); |
5538 | 6473 | symbol_call = ID2SYM(rb_intern("call")); |
6474 | + symbol_update = ID2SYM(rb_intern("update")); | |
6475 | + symbol_custom_render = ID2SYM(rb_intern("custom_render")); | |
5539 | 6476 | |
5540 | 6477 | /* 終了時に実行する関数 */ |
5541 | 6478 | rb_set_end_proc( Window_shutdown, Qnil ); |
@@ -55,9 +55,13 @@ | ||
55 | 55 | #endif |
56 | 56 | |
57 | 57 | #ifdef RUBY_VERSION_MAJOR |
58 | -# if !(RUBY_VERSION_MAJOR == 1 || RUBY_API_VERSION_MAJOR == 1 || (RUBY_API_VERSION_MAJOR == 2 && RUBY_API_VERSION_MINOR == 0)) | |
58 | +# if !(RUBY_VERSION_MAJOR == 1 || RUBY_API_VERSION_MAJOR == 1) | |
59 | 59 | # define DXRUBY_USE_TYPEDDATA |
60 | 60 | # endif |
61 | +#else | |
62 | +# if !(RUBY_API_VERSION_MAJOR == 2 && RUBY_API_VERSION_MINOR == 0) | |
63 | +# define DXRUBY_USE_TYPEDDATA | |
64 | +# endif | |
61 | 65 | #endif |
62 | 66 | |
63 | 67 | #ifdef DXRUBY_USE_TYPEDDATA |
@@ -142,8 +146,7 @@ | ||
142 | 146 | int y; /* y始点位置 */ |
143 | 147 | int width; /* イメージの幅 */ |
144 | 148 | int height;/* イメージの高さ */ |
145 | -// int lockcount; /* ロックカウント ここまでImageと共通 */ | |
146 | - IDirect3DSurface9 *surface; | |
149 | +/* ここまでImageと共通 */ | |
147 | 150 | |
148 | 151 | int PictureCount; /* ピクチャの登録数 */ |
149 | 152 | int PictureAllocateCount; /* ピクチャ登録のメモリ確保数 */ |
@@ -150,9 +153,15 @@ | ||
150 | 153 | int PictureSize; /* ピクチャデータの使用済みサイズ */ |
151 | 154 | int PictureAllocateSize; /* ピクチャデータのメモリ確保サイズ */ |
152 | 155 | char *PictureStruct; |
153 | - | |
154 | 156 | struct DXRubyPictureList *PictureList; |
157 | + int PictureDecideCount; /* ピクチャの登録確定数 */ | |
158 | + int PictureDecideSize; /* ピクチャデータの登録確定サイズ */ | |
159 | + int ox; /* ビュー変換補正x */ | |
160 | + int oy; /* ビュー変換補正y */ | |
161 | +/* ここまでViewportと共通 */ | |
155 | 162 | |
163 | + IDirect3DSurface9 *surface; | |
164 | + | |
156 | 165 | int minfilter; /* 縮小フィルタ */ |
157 | 166 | int magfilter; /* 拡大フィルタ */ |
158 | 167 |
@@ -161,14 +170,27 @@ | ||
161 | 170 | int g; /* 背景クリア色 緑成分 */ |
162 | 171 | int b; /* 背景クリア色 青成分 */ |
163 | 172 | |
164 | -#ifdef DXRUBY15 | |
165 | - VALUE vregenerate_proc; | |
166 | -#endif | |
173 | + int clearflag; /* 1フレーム1回のクリア処理をやったかどうか */ | |
167 | 174 | |
175 | +}; | |
176 | + | |
177 | +/* Viewportオブジェクトの中身 */ | |
178 | +struct DXRubyViewport { | |
179 | + struct DXRubyTexture *texture; | |
180 | + int x; /* x始点位置 */ | |
181 | + int y; /* y始点位置 */ | |
182 | + int width; /* イメージの幅 */ | |
183 | + int height;/* イメージの高さ */ | |
184 | +/* ここまでImageと共通 */ | |
185 | + | |
186 | + int PictureCount; /* ピクチャの登録数 */ | |
187 | + int PictureAllocateCount; /* ピクチャ登録のメモリ確保数 */ | |
188 | + int PictureSize; /* ピクチャデータの使用済みサイズ */ | |
189 | + int PictureAllocateSize; /* ピクチャデータのメモリ確保サイズ */ | |
190 | + char *PictureStruct; | |
191 | + struct DXRubyPictureList *PictureList; | |
168 | 192 | int PictureDecideCount; /* ピクチャの登録確定数 */ |
169 | 193 | int PictureDecideSize; /* ピクチャデータの登録確定サイズ */ |
170 | - int clearflag; /* 1フレーム1回のクリア処理をやったかどうか */ | |
171 | - | |
172 | 194 | int ox; /* ビュー変換補正x */ |
173 | 195 | int oy; /* ビュー変換補正y */ |
174 | 196 | }; |
@@ -299,7 +321,15 @@ | ||
299 | 321 | VALUE vname; |
300 | 322 | }; |
301 | 323 | |
324 | +/* VertexBuffer */ | |
325 | +struct DXRubyVertexBuffer { | |
326 | + LPDIRECT3DVERTEXBUFFER9 pVertexBuffer; | |
327 | + VALUE vtype; /* 用途と使用方法インデックスのセット */ | |
328 | + int vertex_size; /* 頂点1個あたりのバイト数 */ | |
329 | + int vertex_num_count; /* 頂点1個あたりの数値の数 */ | |
330 | +}; | |
302 | 331 | |
332 | + | |
303 | 333 | #ifdef DXRUBY_EXTERN |
304 | 334 | extern HINSTANCE g_hInstance; /* アプリケーションインスタンス */ |
305 | 335 | extern HANDLE g_hWnd; /* ウィンドウハンドル */ |
@@ -807,6 +807,22 @@ | ||
807 | 807 | return vresult; |
808 | 808 | } |
809 | 809 | |
810 | +static VALUE Vector_norm2( VALUE self ) | |
811 | +{ | |
812 | + struct DXRubyVector *vec = DXRUBY_GET_STRUCT( Vector, self ); | |
813 | + float magsq = vec->v1*vec->v1 + vec->v2*vec->v2 + vec->v3*vec->v3 + vec->v4*vec->v4; | |
814 | + | |
815 | + return rb_float_new( magsq ); | |
816 | +} | |
817 | + | |
818 | +static VALUE Vector_norm( VALUE self ) | |
819 | +{ | |
820 | + struct DXRubyVector *vec = DXRUBY_GET_STRUCT( Vector, self ); | |
821 | + float magsq = vec->v1*vec->v1 + vec->v2*vec->v2 + vec->v3*vec->v3 + vec->v4*vec->v4; | |
822 | + | |
823 | + return rb_float_new( sqrt(magsq) ); | |
824 | +} | |
825 | + | |
810 | 826 | static VALUE Vector_distance( VALUE klass, VALUE vvec1, VALUE vvec2 ) |
811 | 827 | { |
812 | 828 | struct DXRubyVector *vec1; |
@@ -1202,6 +1218,8 @@ | ||
1202 | 1218 | rb_define_method( cVector, "xyz", Vector_get_xyz, 0 ); |
1203 | 1219 | rb_define_method( cVector, "size", Vector_get_size, 0 ); |
1204 | 1220 | rb_define_method( cVector, "normalize", Vector_normalize, 0 ); |
1221 | + rb_define_method( cVector, "norm", Vector_norm, 0 ); | |
1222 | + rb_define_method( cVector, "norm2", Vector_norm2, 0 ); | |
1205 | 1223 | rb_define_method( cVector, "==", Vector_equal, 1 ); |
1206 | 1224 | rb_define_method( cVector, "translate", Vector_translate, -1 ); |
1207 | 1225 | rb_define_method( cVector, "rotate", Vector_rotate, -1 ); |
@@ -56,7 +56,7 @@ | ||
56 | 56 | "ok", |
57 | 57 | "out of memory", |
58 | 58 | "Internal Error", |
59 | - "not changed screen mode", | |
59 | + "failed chang screen mode", | |
60 | 60 | "failed create window", |
61 | 61 | "DirectX Graphics initialize error", |
62 | 62 | "DirectInput initialize error" |
@@ -173,6 +173,13 @@ | ||
173 | 173 | core->pD3DXEffect->lpVtbl->OnLostDevice( core->pD3DXEffect ); |
174 | 174 | } |
175 | 175 | |
176 | +// /* 頂点バッファのロスト */ | |
177 | +// for( i = 0; i < g_VertexBufferList.count; i++ ) | |
178 | +// { | |
179 | +// struct DXRubyVertexBuffer *vb = (struct DXRubyVertexBuffer *)g_VertexBufferList.pointer[i]; | |
180 | +// vb->pVertexBuffer->lpVtbl->OnLostDevice( vb->pVertexBuffer ); | |
181 | +// } | |
182 | + | |
176 | 183 | /* 設定変更 */ |
177 | 184 | hr = g_pD3DDevice->lpVtbl->Reset( g_pD3DDevice, &g_D3DPP ); |
178 | 185 | if( FAILED( hr ) ) return 1; |
@@ -207,6 +214,13 @@ | ||
207 | 214 | core->pD3DXEffect->lpVtbl->OnResetDevice( core->pD3DXEffect ); |
208 | 215 | } |
209 | 216 | |
217 | +// /* 頂点バッファの復帰 */ | |
218 | +// for( i = 0; i < g_VertexBufferList.count; i++ ) | |
219 | +// { | |
220 | +// struct DXRubyVertexBuffer *vb = (struct DXRubyVertexBuffer *)g_VertexBufferList.pointer[i]; | |
221 | +// vb->pVertexBuffer->lpVtbl->OnResetDevice( vb->pVertexBuffer ); | |
222 | +// } | |
223 | + | |
210 | 224 | /* D3DXSprite復帰 */ |
211 | 225 | if( g_pD3DXSprite ) |
212 | 226 | { |
@@ -374,6 +388,7 @@ | ||
374 | 388 | { |
375 | 389 | g_pD3DXSprite->lpVtbl->OnResetDevice( g_pD3DXSprite ); |
376 | 390 | } |
391 | + | |
377 | 392 | } |
378 | 393 | else if( hr == D3DERR_DEVICELOST ) /* デバイスはロスト状態である */ |
379 | 394 | { |
@@ -34,7 +34,6 @@ | ||
34 | 34 | ID id_hit; |
35 | 35 | ID id_update; |
36 | 36 | ID id_draw; |
37 | -ID id_render; | |
38 | 37 | ID id_vanished; |
39 | 38 | ID id_visible; |
40 | 39 |
@@ -1165,35 +1164,6 @@ | ||
1165 | 1164 | } |
1166 | 1165 | |
1167 | 1166 | |
1168 | -static VALUE Sprite_class_render( VALUE klass, VALUE ary ) | |
1169 | -{ | |
1170 | - int i; | |
1171 | - | |
1172 | - if( TYPE( ary ) != T_ARRAY ) | |
1173 | - { | |
1174 | - ary = rb_ary_new3( 1, ary ); | |
1175 | - } | |
1176 | - | |
1177 | - for( i = 0; i < RARRAY_LEN( ary ); i++ ) | |
1178 | - { | |
1179 | - VALUE p = RARRAY_AREF( ary, i ); | |
1180 | - | |
1181 | - if( TYPE( p ) == T_ARRAY ) | |
1182 | - { | |
1183 | - Sprite_class_draw( cSprite, p ); | |
1184 | - } | |
1185 | - else if( !rb_respond_to( p, id_vanished ) || !RTEST( rb_funcall2( p, id_vanished, 0, 0 ) ) ) | |
1186 | - { | |
1187 | - if( rb_respond_to( p, id_render ) ) | |
1188 | - { | |
1189 | - rb_funcall2( p, id_render, 0, 0 ); | |
1190 | - } | |
1191 | - } | |
1192 | - } | |
1193 | - return Qnil; | |
1194 | -} | |
1195 | - | |
1196 | - | |
1197 | 1167 | static VALUE Sprite_class_clean( VALUE klass, VALUE ary ) |
1198 | 1168 | { |
1199 | 1169 | int i; |
@@ -1291,7 +1261,6 @@ | ||
1291 | 1261 | rb_define_singleton_method( cSprite, "check", Sprite_check, -1 ); |
1292 | 1262 | rb_define_singleton_method( cSprite, "update", Sprite_class_update, 1 ); |
1293 | 1263 | rb_define_singleton_method( cSprite, "draw", Sprite_class_draw, 1 ); |
1294 | -// rb_define_singleton_method( cSprite, "render", Sprite_class_render, 1 ); | |
1295 | 1264 | rb_define_singleton_method( cSprite, "clean", Sprite_class_clean, 1 ); |
1296 | 1265 | |
1297 | 1266 | rb_define_alloc_func( cSprite, Sprite_allocate ); |
@@ -1300,7 +1269,6 @@ | ||
1300 | 1269 | id_hit = rb_intern("hit"); |
1301 | 1270 | id_update = rb_intern("update"); |
1302 | 1271 | id_draw = rb_intern("draw"); |
1303 | - id_render = rb_intern("render"); | |
1304 | 1272 | id_vanished = rb_intern("vanished?"); |
1305 | 1273 | id_visible = rb_intern("visible"); |
1306 | 1274 |
@@ -1,10 +1,10 @@ | ||
1 | 1 | /* |
2 | 2 | ################################### |
3 | 3 | # |
4 | -# DXRuby 1.5.20dev | |
4 | +# DXRuby 1.5.21 | |
5 | 5 | # |
6 | 6 | ################################### |
7 | 7 | */ |
8 | -#define DXRUBY_VERSION "1.5.20dev" | |
8 | +#define DXRUBY_VERSION "1.5.21" | |
9 | 9 | |
10 | 10 | #define DXRUBY15 |