DirectX SDK

E

emr

Hi, just downloaded DirectX SDK (latest one) and found an example but it
doesn't work. So any1 can tell me what the heck is with the Main() method
what did this guy do? Thanks.

using System;

using System.Drawing;

using System.Collections;

using System.ComponentModel;

using System.Windows.Forms;

using System.Data;

using Microsoft.DirectX;

using Microsoft.DirectX.Direct3D;


namespace DirectX_Tutorial

{


public class WinForm : System.Windows.Forms.Form

{

private Device device;

private System.ComponentModel.Container components = null;


public WinForm()

{

InitializeComponent();

}


public void InitializeDevice()

{

PresentParameters presentParams = new PresentParameters();

presentParams.Windowed = true;

presentParams.SwapEffect = SwapEffect.Discard;

device = new Device(0, DeviceType.Hardware, this,
CreateFlags.SoftwareVertexProcessing, presentParams);

}



protected override void OnPaint(System.Windows.Forms.PaintEventArgs
e)

{

device.Clear(ClearFlags.Target, Color.DarkSlateBlue , 1.0f,
0);

device.Present();

}




protected override void Dispose (bool disposing)

{

if (disposing)

{

if (components != null)

{

components.Dispose();

}

}

base.Dispose(disposing);

}


private void InitializeComponent()

{

this.components = new System.ComponentModel.Container();

this.Size = new System.Drawing.Size(500,500);

this.Text = "DirectX Tutotial";

}



static void Main()

{

using (WinForm dx_form = new WinForm())

{

dx_form.InitializeDevice();

Application.Run(dx_form);

}

}

}

}
 
B

Brendan Green

How about posting what error message you got (compiler errors and/or runtime
errors), and maybe the specs of the machine that you're running this on.
 
E

emr

I've solved my problem. I just wonder this

using (Form dx_form = new Form()) // why "using" is like this? what does
it do? //
{
dx_form.InitializeDevice();
Application.Run(dx_form);
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top