SleepingTroll
Newcomer
- Joined
- Feb 14, 2012
- Messages
- 12
(sorry about the repost, just realized the original was in the wrong place)
I create a form and it displays fine, however as soon as I create my directX device the form stops displaying!
Here is my code, please note that I can eliminate all of the DirectX code and the form displays, however just the line 'private Device device = null;' will prevent my form from displaying.
I am new at directX and will likely stay that way if I can't get by this!
I create a form and it displays fine, however as soon as I create my directX device the form stops displaying!
Here is my code, please note that I can eliminate all of the DirectX code and the form displays, however just the line 'private Device device = null;' will prevent my form from displaying.
Code:
using System;
using System.Drawing;
using System.Windows.Forms;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;
namespace Model
{
public partial class MainForm : Form
{
private Device device = null;
public MainForm()
{
InitializeComponent();
InitializeDevice();
}
private void InitializeDevice()
{
PresentParameters pp = new PresentParameters();
pp.Windowed = true;
pp.SwapEffect = SwapEffect.Discard;
device = new Device(0, DeviceType.Reference, this, CreateFlags.SoftwareVertexProcessing, pp);
}
protected override void OnPaint(PaintEventArgs e)
{
device.Clear(ClearFlags.Target, Color.CornflowerBlue, 0, 1);
device.Present();
}
}
}