自動クリアができていない不具合修正、Window.draw_lineのズレ修正
@@ -567,13 +567,6 @@ | ||
567 | 567 | if( ret == 0 ) |
568 | 568 | { |
569 | 569 | rb_gc_start(); |
570 | - for( i = 0; i < g_RenderTargetList.count; i++ ) | |
571 | - { | |
572 | - if( g_RenderTargetList.pointer[i] ) | |
573 | - { | |
574 | - struct DXRubyRenderTarget *rt = (struct DXRubyRenderTarget *)g_RenderTargetList.pointer[i]; | |
575 | - } | |
576 | - } | |
577 | 570 | } |
578 | 571 | |
579 | 572 | // Windowに関連付けられた内部生成Imageの破棄 |
@@ -590,6 +583,15 @@ | ||
590 | 583 | rb_ary_clear( g_WindowInfo.image_array ); |
591 | 584 | } |
592 | 585 | |
586 | + for( i = 0; i < g_RenderTargetList.count; i++ ) | |
587 | + { | |
588 | + if( g_RenderTargetList.pointer[i] ) | |
589 | + { | |
590 | + struct DXRubyRenderTarget *rt = (struct DXRubyRenderTarget *)g_RenderTargetList.pointer[i]; | |
591 | + rt->cleared_flag = 0; | |
592 | + } | |
593 | + } | |
594 | + | |
593 | 595 | CleanRenderTargetList(); |
594 | 596 | g_RunningTime = GetSystemCounter() - g_StartTime; |
595 | 597 |
@@ -2398,20 +2400,7 @@ | ||
2398 | 2400 | { |
2399 | 2401 | if( DXRUBY_CHECK( RenderTarget, vrt ) ) |
2400 | 2402 | { |
2401 | - struct DXRubyRenderTarget *src_rt = DXRUBY_GET_STRUCT( RenderTarget, vrt ); | |
2402 | - int customflag = RTEST(rb_obj_is_kind_of(vrt, cCustomRenderTarget)); | |
2403 | - | |
2404 | - if( src_rt->clearflag == 0 && src_rt->PictureCount == 0 && !customflag ) | |
2405 | - { | |
2406 | - g_pD3DDevice->lpVtbl->SetRenderTarget( g_pD3DDevice, 0, src_rt->surface ); | |
2407 | - g_pD3DDevice->lpVtbl->Clear( g_pD3DDevice, 0, NULL, D3DCLEAR_TARGET, | |
2408 | - D3DCOLOR_ARGB( src_rt->a, src_rt->r, src_rt->g, src_rt->b ), 1.0f, 0 ); | |
2409 | - src_rt->clearflag = 1; | |
2410 | - } | |
2411 | - else if( src_rt->PictureCount > 0 || customflag ) | |
2412 | - { | |
2413 | - rb_funcall( vrt, SYM2ID( symbol_update ), 0 ); | |
2414 | - } | |
2403 | + rb_funcall( vrt, SYM2ID( symbol_update ), 0 ); | |
2415 | 2404 | } |
2416 | 2405 | } |
2417 | 2406 |
@@ -2452,9 +2441,9 @@ | ||
2452 | 2441 | rt->r = 0; |
2453 | 2442 | rt->g = 0; |
2454 | 2443 | rt->b = 0; |
2455 | - rt->clearflag = 0; | |
2456 | 2444 | rt->ox = 0; |
2457 | 2445 | rt->oy = 0; |
2446 | + rt->cleared_flag = 0; | |
2458 | 2447 | |
2459 | 2448 | return obj; |
2460 | 2449 | } |
@@ -2586,11 +2575,11 @@ | ||
2586 | 2575 | rt->y = 0; |
2587 | 2576 | rt->width = width; |
2588 | 2577 | rt->height = height; |
2589 | - rt->clearflag = 0; | |
2590 | 2578 | rt->PictureCount = 0; |
2591 | 2579 | rt->PictureSize = 0; |
2592 | 2580 | rt->PictureDecideCount = 0; |
2593 | 2581 | rt->PictureDecideSize = 0; |
2582 | + rt->cleared_flag = 0; | |
2594 | 2583 | |
2595 | 2584 | return self; |
2596 | 2585 | } |
@@ -2915,13 +2904,13 @@ | ||
2915 | 2904 | } |
2916 | 2905 | else if( picture->x1 > picture->x2 ) |
2917 | 2906 | { |
2918 | - VertexDataTbl[0].x = (float)picture->x1 + 1.0f; | |
2907 | + VertexDataTbl[0].x = (float)picture->x1 + 0.5f; | |
2919 | 2908 | VertexDataTbl[1].x = (float)picture->x2; |
2920 | 2909 | } |
2921 | 2910 | else |
2922 | 2911 | { |
2923 | 2912 | VertexDataTbl[0].x = (float)picture->x1; |
2924 | - VertexDataTbl[1].x = (float)picture->x2 + 1.0f; | |
2913 | + VertexDataTbl[1].x = (float)picture->x2 + 0.5f; | |
2925 | 2914 | } |
2926 | 2915 | |
2927 | 2916 | /* 頂点1と2のy */ |
@@ -2932,13 +2921,13 @@ | ||
2932 | 2921 | } |
2933 | 2922 | else if( picture->y1 > picture->y2 ) |
2934 | 2923 | { |
2935 | - VertexDataTbl[0].y = (float)picture->y1 + 1.0f; | |
2924 | + VertexDataTbl[0].y = (float)picture->y1 + 0.5f; | |
2936 | 2925 | VertexDataTbl[1].y = (float)picture->y2; |
2937 | 2926 | } |
2938 | 2927 | else |
2939 | 2928 | { |
2940 | 2929 | VertexDataTbl[0].y = (float)picture->y1; |
2941 | - VertexDataTbl[1].y = (float)picture->y2 + 1.0f; | |
2930 | + VertexDataTbl[1].y = (float)picture->y2 + 0.5f; | |
2942 | 2931 | } |
2943 | 2932 | |
2944 | 2933 | /* 頂点色 */ |
@@ -5126,8 +5115,9 @@ | ||
5126 | 5115 | |
5127 | 5116 | DXRUBY_CHECK_DISPOSE( rt, surface ); |
5128 | 5117 | |
5129 | - /* シーンのクリア */ | |
5118 | + if( rt->PictureCount > 0 || rt->cleared_flag == 0 ) | |
5130 | 5119 | { |
5120 | + /* シーンのクリア */ | |
5131 | 5121 | vp.X = x_2d = 0; |
5132 | 5122 | vp.Y = y_2d = 0; |
5133 | 5123 | if( rt->texture == NULL ) |
@@ -5134,12 +5124,13 @@ | ||
5134 | 5124 | { |
5135 | 5125 | vp.Width = width_2d = g_D3DPP.BackBufferWidth; |
5136 | 5126 | vp.Height = height_2d = g_D3DPP.BackBufferHeight; |
5127 | + rt->cleared_flag = 0; | |
5137 | 5128 | } |
5138 | 5129 | else |
5139 | 5130 | { |
5140 | 5131 | vp.Width = width_2d = (int)rt->texture->width; |
5141 | 5132 | vp.Height = height_2d = (int)rt->texture->height; |
5142 | - rt->clearflag = 0; | |
5133 | + rt->cleared_flag = 1; | |
5143 | 5134 | } |
5144 | 5135 | vp.MinZ = 0.0f; |
5145 | 5136 | vp.MaxZ = 1.0f; |
@@ -5146,72 +5137,73 @@ | ||
5146 | 5137 | g_pD3DDevice->lpVtbl->SetRenderTarget( g_pD3DDevice, 0, rt->surface ); |
5147 | 5138 | g_pD3DDevice->lpVtbl->SetViewport( g_pD3DDevice, &vp ); |
5148 | 5139 | g_pD3DDevice->lpVtbl->Clear( g_pD3DDevice, 0, NULL, D3DCLEAR_TARGET, |
5149 | - D3DCOLOR_ARGB( rt->a, rt->r, rt->g, rt->b ), 1.0f, 0 ); | |
5140 | + D3DCOLOR_ARGB( rt->a, rt->r, rt->g, rt->b ), 1.0f, 0 ); | |
5150 | 5141 | } |
5151 | 5142 | |
5152 | - /* シーンの描画開始 */ | |
5153 | - if( SUCCEEDED( g_pD3DDevice->lpVtbl->BeginScene( g_pD3DDevice ) ) ) | |
5143 | + if( rt->PictureCount > 0 ) | |
5154 | 5144 | { |
5155 | - i = 0; | |
5145 | + /* シーンの描画開始 */ | |
5146 | + if( SUCCEEDED( g_pD3DDevice->lpVtbl->BeginScene( g_pD3DDevice ) ) ) | |
5147 | + { | |
5148 | + i = 0; | |
5156 | 5149 | |
5157 | - g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_ZENABLE,D3DZB_FALSE ); | |
5158 | - g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_ZWRITEENABLE, FALSE ); | |
5159 | - g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_LIGHTING, FALSE); | |
5160 | - g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_FOGENABLE, FALSE ); | |
5161 | - g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_SHADEMODE, D3DSHADE_GOURAUD ); | |
5162 | - g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_SRGBWRITEENABLE, FALSE ); | |
5163 | - g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_VERTEXBLEND, FALSE ); | |
5164 | - g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_WRAP0, 0 ); | |
5165 | - g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_CULLMODE, D3DCULL_NONE); | |
5150 | + g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_ZENABLE,D3DZB_FALSE ); | |
5151 | + g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_ZWRITEENABLE, FALSE ); | |
5152 | + g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_LIGHTING, FALSE); | |
5153 | + g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_FOGENABLE, FALSE ); | |
5154 | + g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_SHADEMODE, D3DSHADE_GOURAUD ); | |
5155 | + g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_SRGBWRITEENABLE, FALSE ); | |
5156 | + g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_VERTEXBLEND, FALSE ); | |
5157 | + g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_WRAP0, 0 ); | |
5158 | + g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_CULLMODE, D3DCULL_NONE); | |
5166 | 5159 | |
5167 | - g_pD3DDevice->lpVtbl->SetTextureStageState( g_pD3DDevice, 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); | |
5168 | - g_pD3DDevice->lpVtbl->SetTextureStageState( g_pD3DDevice, 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE ); | |
5169 | - g_pD3DDevice->lpVtbl->SetTextureStageState( g_pD3DDevice, 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE ); | |
5170 | - g_pD3DDevice->lpVtbl->SetTextureStageState( g_pD3DDevice, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); | |
5171 | - g_pD3DDevice->lpVtbl->SetTextureStageState( g_pD3DDevice, 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); | |
5172 | - g_pD3DDevice->lpVtbl->SetTextureStageState( g_pD3DDevice, 0, D3DTSS_COLOROP, D3DTOP_MODULATE ); | |
5160 | + g_pD3DDevice->lpVtbl->SetTextureStageState( g_pD3DDevice, 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ); | |
5161 | + g_pD3DDevice->lpVtbl->SetTextureStageState( g_pD3DDevice, 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE ); | |
5162 | + g_pD3DDevice->lpVtbl->SetTextureStageState( g_pD3DDevice, 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE ); | |
5163 | + g_pD3DDevice->lpVtbl->SetTextureStageState( g_pD3DDevice, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); | |
5164 | + g_pD3DDevice->lpVtbl->SetTextureStageState( g_pD3DDevice, 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); | |
5165 | + g_pD3DDevice->lpVtbl->SetTextureStageState( g_pD3DDevice, 0, D3DTSS_COLOROP, D3DTOP_MODULATE ); | |
5173 | 5166 | |
5174 | - g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_ALPHABLENDENABLE, TRUE ); | |
5175 | - g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA ); | |
5176 | - g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_SRCBLEND, D3DBLEND_SRCALPHA ); | |
5167 | + g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_ALPHABLENDENABLE, TRUE ); | |
5168 | + g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA ); | |
5169 | + g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_SRCBLEND, D3DBLEND_SRCALPHA ); | |
5177 | 5170 | |
5178 | - g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_SEPARATEALPHABLENDENABLE, TRUE ); | |
5179 | - g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_SRCBLENDALPHA, D3DBLEND_ONE ); | |
5180 | - g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_DESTBLENDALPHA, D3DBLEND_INVSRCALPHA ); | |
5171 | + g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_SEPARATEALPHABLENDENABLE, TRUE ); | |
5172 | + g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_SRCBLENDALPHA, D3DBLEND_ONE ); | |
5173 | + g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_DESTBLENDALPHA, D3DBLEND_INVSRCALPHA ); | |
5181 | 5174 | |
5182 | - g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_FOGENABLE, FALSE ); | |
5175 | + g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_FOGENABLE, FALSE ); | |
5183 | 5176 | |
5184 | - g_pD3DDevice->lpVtbl->SetSamplerState( g_pD3DDevice, 0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP ); | |
5185 | - g_pD3DDevice->lpVtbl->SetSamplerState( g_pD3DDevice, 0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP ); | |
5177 | + g_pD3DDevice->lpVtbl->SetSamplerState( g_pD3DDevice, 0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP ); | |
5178 | + g_pD3DDevice->lpVtbl->SetSamplerState( g_pD3DDevice, 0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP ); | |
5186 | 5179 | |
5187 | - /* 拡大縮小フィルタ設定 */ | |
5188 | - g_pD3DDevice->lpVtbl->SetSamplerState(g_pD3DDevice, 0, D3DSAMP_MINFILTER, | |
5189 | - rt->minfilter); | |
5190 | - g_pD3DDevice->lpVtbl->SetSamplerState(g_pD3DDevice, 0, D3DSAMP_MAGFILTER, | |
5191 | - rt->magfilter); | |
5180 | + /* 拡大縮小フィルタ設定 */ | |
5181 | + g_pD3DDevice->lpVtbl->SetSamplerState(g_pD3DDevice, 0, D3DSAMP_MINFILTER, | |
5182 | + rt->minfilter); | |
5183 | + g_pD3DDevice->lpVtbl->SetSamplerState(g_pD3DDevice, 0, D3DSAMP_MAGFILTER, | |
5184 | + rt->magfilter); | |
5185 | + { | |
5186 | + D3DMATRIX matrix_view, matrix_t, matrix_proj; | |
5192 | 5187 | |
5193 | - if( rt->PictureCount > 0 ) | |
5194 | - { | |
5195 | - D3DMATRIX matrix_view, matrix_t, matrix_proj; | |
5188 | + /* 2D描画行列 */ | |
5189 | + D3DXMatrixScaling ( &matrix_view, 1, -1, 1 ); | |
5190 | + D3DXMatrixTranslation( &matrix_t, (float)-(width_2d)/2.0f, (float)(height_2d)/2.0f, 0 ); | |
5191 | + D3DXMatrixMultiply( &matrix_view, &matrix_view, &matrix_t ); | |
5192 | + g_pD3DDevice->lpVtbl->SetTransform( g_pD3DDevice, D3DTS_VIEW, &matrix_view ); | |
5193 | + matrix_proj._11 = 2.0f / width_2d; | |
5194 | + matrix_proj._12 = matrix_proj._13 = matrix_proj._14 = 0; | |
5195 | + matrix_proj._22 = 2.0f / height_2d; | |
5196 | + matrix_proj._21 = matrix_proj._23 = matrix_proj._24 = 0; | |
5197 | + matrix_proj._31 = matrix_proj._32 = 0;matrix_proj._33 = 0; matrix_proj._34 = 0; | |
5198 | + matrix_proj._41 = matrix_proj._42 = 0;matrix_proj._43 = 1; matrix_proj._44 = 1; | |
5199 | + g_pD3DDevice->lpVtbl->SetTransform( g_pD3DDevice, D3DTS_PROJECTION, &matrix_proj ); | |
5196 | 5200 | |
5197 | - /* 2D描画行列 */ | |
5198 | - D3DXMatrixScaling ( &matrix_view, 1, -1, 1 ); | |
5199 | - D3DXMatrixTranslation( &matrix_t, (float)-(width_2d)/2.0f, (float)(height_2d)/2.0f, 0 ); | |
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 ); | |
5201 | + RenderTarget_update_internal( rt, &vp, &matrix_view, &matrix_proj, 0, 0 ); | |
5202 | + } | |
5209 | 5203 | |
5210 | - RenderTarget_update_internal( rt, &vp, &matrix_view, &matrix_proj, 0, 0 ); | |
5204 | + /* シーンの描画終了 */ | |
5205 | + g_pD3DDevice->lpVtbl->EndScene( g_pD3DDevice ); | |
5211 | 5206 | } |
5212 | - | |
5213 | - /* シーンの描画終了 */ | |
5214 | - g_pD3DDevice->lpVtbl->EndScene( g_pD3DDevice ); | |
5215 | 5207 | } |
5216 | 5208 | |
5217 | 5209 | rt->PictureCount = 0; |
@@ -170,8 +170,7 @@ | ||
170 | 170 | int g; /* 背景クリア色 緑成分 */ |
171 | 171 | int b; /* 背景クリア色 青成分 */ |
172 | 172 | |
173 | - int clearflag; /* 1フレーム1回のクリア処理をやったかどうか */ | |
174 | - | |
173 | + int cleared_flag; /* クリア済みフラグ */ | |
175 | 174 | }; |
176 | 175 | |
177 | 176 | /* Viewportオブジェクトの中身 */ |
@@ -404,6 +403,8 @@ | ||
404 | 403 | extern VALUE symbol_discard; |
405 | 404 | extern VALUE symbol_aa; |
406 | 405 | extern VALUE symbol_call; |
406 | +extern VALUE symbol_update; | |
407 | +extern VALUE symbol_custom_render; | |
407 | 408 | |
408 | 409 | extern int MainThreadError; |
409 | 410 | #endif |
@@ -1,10 +1,10 @@ | ||
1 | 1 | /* |
2 | 2 | ################################### |
3 | 3 | # |
4 | -# DXRuby 1.5.22dev | |
4 | +# DXRuby 1.5.23dev | |
5 | 5 | # |
6 | 6 | ################################### |
7 | 7 | */ |
8 | -#define DXRUBY_VERSION "1.5.22dev" | |
8 | +#define DXRUBY_VERSION "1.5.23dev" | |
9 | 9 | |
10 | 10 | #define DXRUBY15 |