נשלח בתאריך: 01 May 2008 בשעה 21:40 | | IP רשוּם
|
|
|
|
שלום התחלתי ללמוד DIRECTX ב C# ולקחתי תוכנית מאתר
http://csharp-home.com/index/tiki-print_article.php?articleId=105
using System;
using System.Drawing;
using System.Windows.Forms;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;
public class MainForm : Form
{
Device device = null;
/// <summary>
/// When the form is clicked, we close it and stop
/// the application
/// </summary>
protected override void OnClick(EventArgs e)
{
this.Close();
base.OnClick (e);
}
/// <summary>
/// In the constructor we initialize the device using
/// the default adapter and the current display mode
/// </summary>
public MainForm()
{
AdapterInformation adapter = Manager.Adapters.Default;
PresentParameters presentation = new PresentParameters ();
presentation.BackBufferFormat = adapter.CurrentDisplayMode.Format;
presentation.BackBufferWidth = adapter.CurrentDisplayMode.Width;
presentation.BackBufferHeight = adapter.CurrentDisplayMode.Height;
presentation.SwapEffect = SwapEffect.Flip;
presentation.Windowed = false;
// Place it in a try catch block just
//in case it goes wrong for
// some reason.
try
{
// To make things simple, we'll just
//use the reference device, and
// software vertex processing.
//Although this will be extrelemly slow
// it doesn't matter in this case.
// It will definetly work on
// all machines, so it saves us doing
//enumeration for now.
device = new Device (adapter.Adapter,
DeviceType.Reference,
this,
CreateFlags.SoftwareVertexProcessing,
presentation);
}
ca tch (DirectXException e)
{
MessageBox.Show (e.Message);
return;
}
}
/// <summary>
/// Clear the screen with a blue color
/// </summary>
public void Render()
{
device.Clear(ClearFlags.Target, Color.Blue, 1.0f, 0);
device.Present();
}
/// <summary>
/// The entry point where the main render loop goes
/// </summary>
static void Main()
{
using (MainForm form = new MainForm())
{
form.Show();
while (form.Created)
{
form.Render();
Application.DoEvents();
}
}
}
}
כאשר אני מריץ את את התוכנית הקומפילר כותב לי שיש יותר מכניסה אחת has more then one entry point
|