• R/O
  • SSH
  • HTTPS

dxruby: Commit


Commit MetaInfo

Révision549 (tree)
l'heure2017-03-12 18:07:06
Auteurmirichi

Message de Log

自動クリアができていない不具合修正、Window.draw_lineのズレ修正

Change Summary

Modification

--- branches/1.5dev/dxruby.c (revision 548)
+++ branches/1.5dev/dxruby.c (revision 549)
@@ -567,13 +567,6 @@
567567 if( ret == 0 )
568568 {
569569 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- }
577570 }
578571
579572 // Windowに関連付けられた内部生成Imageの破棄
@@ -590,6 +583,15 @@
590583 rb_ary_clear( g_WindowInfo.image_array );
591584 }
592585
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+
593595 CleanRenderTargetList();
594596 g_RunningTime = GetSystemCounter() - g_StartTime;
595597
@@ -2398,20 +2400,7 @@
23982400 {
23992401 if( DXRUBY_CHECK( RenderTarget, vrt ) )
24002402 {
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 );
24152404 }
24162405 }
24172406
@@ -2452,9 +2441,9 @@
24522441 rt->r = 0;
24532442 rt->g = 0;
24542443 rt->b = 0;
2455- rt->clearflag = 0;
24562444 rt->ox = 0;
24572445 rt->oy = 0;
2446+ rt->cleared_flag = 0;
24582447
24592448 return obj;
24602449 }
@@ -2586,11 +2575,11 @@
25862575 rt->y = 0;
25872576 rt->width = width;
25882577 rt->height = height;
2589- rt->clearflag = 0;
25902578 rt->PictureCount = 0;
25912579 rt->PictureSize = 0;
25922580 rt->PictureDecideCount = 0;
25932581 rt->PictureDecideSize = 0;
2582+ rt->cleared_flag = 0;
25942583
25952584 return self;
25962585 }
@@ -2915,13 +2904,13 @@
29152904 }
29162905 else if( picture->x1 > picture->x2 )
29172906 {
2918- VertexDataTbl[0].x = (float)picture->x1 + 1.0f;
2907+ VertexDataTbl[0].x = (float)picture->x1 + 0.5f;
29192908 VertexDataTbl[1].x = (float)picture->x2;
29202909 }
29212910 else
29222911 {
29232912 VertexDataTbl[0].x = (float)picture->x1;
2924- VertexDataTbl[1].x = (float)picture->x2 + 1.0f;
2913+ VertexDataTbl[1].x = (float)picture->x2 + 0.5f;
29252914 }
29262915
29272916 /* 頂点1と2のy */
@@ -2932,13 +2921,13 @@
29322921 }
29332922 else if( picture->y1 > picture->y2 )
29342923 {
2935- VertexDataTbl[0].y = (float)picture->y1 + 1.0f;
2924+ VertexDataTbl[0].y = (float)picture->y1 + 0.5f;
29362925 VertexDataTbl[1].y = (float)picture->y2;
29372926 }
29382927 else
29392928 {
29402929 VertexDataTbl[0].y = (float)picture->y1;
2941- VertexDataTbl[1].y = (float)picture->y2 + 1.0f;
2930+ VertexDataTbl[1].y = (float)picture->y2 + 0.5f;
29422931 }
29432932
29442933 /* 頂点色 */
@@ -5126,8 +5115,9 @@
51265115
51275116 DXRUBY_CHECK_DISPOSE( rt, surface );
51285117
5129- /* シーンのクリア */
5118+ if( rt->PictureCount > 0 || rt->cleared_flag == 0 )
51305119 {
5120+ /* シーンのクリア */
51315121 vp.X = x_2d = 0;
51325122 vp.Y = y_2d = 0;
51335123 if( rt->texture == NULL )
@@ -5134,12 +5124,13 @@
51345124 {
51355125 vp.Width = width_2d = g_D3DPP.BackBufferWidth;
51365126 vp.Height = height_2d = g_D3DPP.BackBufferHeight;
5127+ rt->cleared_flag = 0;
51375128 }
51385129 else
51395130 {
51405131 vp.Width = width_2d = (int)rt->texture->width;
51415132 vp.Height = height_2d = (int)rt->texture->height;
5142- rt->clearflag = 0;
5133+ rt->cleared_flag = 1;
51435134 }
51445135 vp.MinZ = 0.0f;
51455136 vp.MaxZ = 1.0f;
@@ -5146,72 +5137,73 @@
51465137 g_pD3DDevice->lpVtbl->SetRenderTarget( g_pD3DDevice, 0, rt->surface );
51475138 g_pD3DDevice->lpVtbl->SetViewport( g_pD3DDevice, &vp );
51485139 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 );
51505141 }
51515142
5152- /* シーンの描画開始 */
5153- if( SUCCEEDED( g_pD3DDevice->lpVtbl->BeginScene( g_pD3DDevice ) ) )
5143+ if( rt->PictureCount > 0 )
51545144 {
5155- i = 0;
5145+ /* シーンの描画開始 */
5146+ if( SUCCEEDED( g_pD3DDevice->lpVtbl->BeginScene( g_pD3DDevice ) ) )
5147+ {
5148+ i = 0;
51565149
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);
51665159
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 );
51735166
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 );
51775170
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 );
51815174
5182- g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_FOGENABLE, FALSE );
5175+ g_pD3DDevice->lpVtbl->SetRenderState( g_pD3DDevice, D3DRS_FOGENABLE, FALSE );
51835176
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 );
51865179
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;
51925187
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 );
51965200
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+ }
52095203
5210- RenderTarget_update_internal( rt, &vp, &matrix_view, &matrix_proj, 0, 0 );
5204+ /* シーンの描画終了 */
5205+ g_pD3DDevice->lpVtbl->EndScene( g_pD3DDevice );
52115206 }
5212-
5213- /* シーンの描画終了 */
5214- g_pD3DDevice->lpVtbl->EndScene( g_pD3DDevice );
52155207 }
52165208
52175209 rt->PictureCount = 0;
--- branches/1.5dev/dxruby.h (revision 548)
+++ branches/1.5dev/dxruby.h (revision 549)
@@ -170,8 +170,7 @@
170170 int g; /* 背景クリア色 緑成分 */
171171 int b; /* 背景クリア色 青成分 */
172172
173- int clearflag; /* 1フレーム1回のクリア処理をやったかどうか */
174-
173+ int cleared_flag; /* クリア済みフラグ */
175174 };
176175
177176 /* Viewportオブジェクトの中身 */
@@ -404,6 +403,8 @@
404403 extern VALUE symbol_discard;
405404 extern VALUE symbol_aa;
406405 extern VALUE symbol_call;
406+extern VALUE symbol_update;
407+extern VALUE symbol_custom_render;
407408
408409 extern int MainThreadError;
409410 #endif
--- branches/1.5dev/version.h (revision 548)
+++ branches/1.5dev/version.h (revision 549)
@@ -1,10 +1,10 @@
11 /*
22 ###################################
33 #
4-# DXRuby 1.5.22dev
4+# DXRuby 1.5.23dev
55 #
66 ###################################
77 */
8-#define DXRUBY_VERSION "1.5.22dev"
8+#define DXRUBY_VERSION "1.5.23dev"
99
1010 #define DXRUBY15
Afficher sur ancien navigateur de dépôt.