C#でツールを作る その1-Direct3Dの初期化-
DirectXの解説サイトはたくさんあるのでググって下さい。
とりあえずこことか
VisualC#2008ExpressEditionを使っています。
ソース
- デバイスの初期化、解放
- バックバッファの塗りつぶしとフォームの更新
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using Microsoft.DirectX; using Microsoft.DirectX.Direct3D; namespace WindowsFormsApplication1 { public partial class Form1 : Form { private Device device = null; public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { PresentParameters pp = new PresentParameters(); pp.Windowed = true; pp.SwapEffect = SwapEffect.Discard; device = new Device( 0, DeviceType.Hardware, this, CreateFlags.HardwareVertexProcessing, pp ); } private void Form1_FormClosed(object sender, FormClosedEventArgs e) { if( device != null ) { device.Dispose(); device = null; } } private void Form1_Paint(object sender, PaintEventArgs e) { device.Clear(ClearFlags.Target, Color.FromArgb( 0x333333 ), 1.0f, 0); device.BeginScene(); device.EndScene(); device.Present(); } } }
C++よりすっごい楽ですね。。。