OSDN Git Service

ApplicationForm クラスを StrokeStyleT クラスに改名。
[strokestylet/CsWin10Desktop3.git] / StrokeStyleT / StrokeStyleT.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Diagnostics;
4 using System.Linq;
5 using System.Windows.Forms;
6
7 namespace StrokeStyleT
8 {
9         class StrokeStyleT : FDK.ApplicationFormBase
10         {
11                 public override void 初期化する()
12                 {
13                         Debug.Assert( null == this.デバイスリソース );  // 作成される前である。
14
15                         this.Text = $"StrokeStyle<T> {System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString()}";
16                         this.ClientSize = new System.Drawing.Size( 640, 480 );  // 初期サイズ
17
18                         this.KeyDown += ( target, arg ) => {
19                                 // Esc → アプリ終了。
20                                 if( arg.KeyCode == System.Windows.Forms.Keys.Escape )
21                                         this.アプリを終了せよ = true;
22                         };
23                 }
24                 public override void 終了する()
25                 {
26                         Debug.Assert( null == this.デバイスリソース );  // 解放された後である。
27
28 #warning " テストコード。"
29                         if( null != this.testTexture )
30                         {
31                                 this.testTexture.非活性化する( this.デバイスリソース );
32                                 this.testTexture = null;
33                         }
34                 }
35                 public override void シーンを描画する()
36                 {
37                         //------------------
38                         // 以下は、実装例。
39                         //------------------
40
41 #warning " テストコード。"
42                         if( null == this.testTexture )
43                         {
44                                 this.testTexture = new FDK.メディア.テクスチャ( "テスト用テクスチャ画像.jpg" );
45                                 this.testTexture.活性化する( this.デバイスリソース );
46                                 this.testTexture.不透明度 = 1f;
47                                 this.testTexture.加算合成する = false;
48                         }
49
50                         var d3dDevice = (SharpDX.Direct3D11.Device) null;
51                         using( var d3dLock = new FDK.同期.AutoD3DDeviceLock( this.デバイスリソース.DXGIDeviceManager, out d3dDevice ) )
52                         {
53                                 #region " ビューをクリアする。"
54                                 //----------------
55                                 d3dDevice.ImmediateContext.ClearRenderTargetView(
56                                         this.デバイスリソース.D3DRenderTargetView, SharpDX.Color4.Black );
57
58                                 d3dDevice.ImmediateContext.ClearDepthStencilView(
59                                         this.デバイスリソース.D3DDepthStencilView,
60                                         SharpDX.Direct3D11.DepthStencilClearFlags.Depth,    // ここでは深度バッファのみ。
61                                         depth: 1.0f,
62                                         stencil: 0 );
63                                 //----------------
64                                 #endregion
65                         }
66
67 #warning " テストコード。"
68                         var matScale = SharpDX.Matrix.Scaling( 320f, 240f, 1.0f );
69                         var matY = SharpDX.Matrix.RotationY( (float) ( Math.PI * ( timeGetTime() % 3000 ) ) / 1500.0f );
70                         var matX = SharpDX.Matrix.RotationX( (float) ( Math.PI * ( timeGetTime() % 1500 ) ) / 750.0f );
71                         var mat = matScale * matY * matX;
72                         this.testTexture?.進行描画する( this.デバイスリソース, mat, new SharpDX.RectangleF( 0f, 0f, 0.5f, 0.5f ) );
73                 }
74
75 #warning " テストコード。"
76                 private FDK.メディア.テクスチャ testTexture = null;
77                 [System.Runtime.InteropServices.DllImport( "winmm.dll" )]
78                 private static extern uint timeGetTime();
79         }
80 }