, Visual C#


         

Form1


this, CreateFlags.SoftwareVertexProcessing,
myPresentParameters);
return true;
}
catch (DirectXException)
{
return false;
}
}
// :
public void myRendering()
{
if (myDevice == null)
return;
// - Form1:
myDevice.Clear(ClearFlags.Target,
System.Drawing.Color.White, 1.0f, 0);
// :
myDevice.BeginScene();
// :
myDevice.EndScene();
myDevice.Present();
}
// Form1 Esc:
protected override void OnKeyPress(
System.Windows.Forms.KeyPressEventArgs e)
{
if ((int)(byte)e.KeyChar ==
(int)System.Windows.Forms.Keys.Escape)
this.Close();
}
44.3. .
// :
Device myDevice = null;
VertexBuffer myVertexBuffer = null;
// Direct3D:
public bool InitializeDirectX()
{
try
{
PresentParameters myPresentParameters =
new PresentParameters();
myPresentParameters.Windowed = true;
myPresentParameters.SwapEffect = SwapEffect.Discard;
myDevice = new Device(0, DeviceType.Hardware, this,
CreateFlags.SoftwareVertexProcessing,
myPresentParameters);
this.OnCreateDevice(myDevice, null);
return true;
}
catch (DirectXException)
{
return false;
}
}
// :
public void OnCreateDevice(object sender, EventArgs e)
{
// 3-x :
myVertexBuffer = new VertexBuffer(
typeof(CustomVertex.TransformedColored), 3,
myDevice, 0, CustomVertex.TransformedColored.Format,
Pool.Default);
myVertexBuffer.Created += new System.EventHandler(
this.OnCreateVertexBuffer);