Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

(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.

 

 

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();
	}

}
}

I am new at directX and will likely stay that way if I can't get by this!

  • Leaders
Posted

Is there a reason why you are creating a reference device? I can't how this could cause a problem, but it seems unusual.

 

The problem might be related to the fact that you are creating the device before your form creates its handle. Try calling the InitializeDevice method from the OnLoad event method rather than the constructor.

[sIGPIC]e[/sIGPIC]
Posted (edited)

I do have more info, although it is not encouraging... It would seem that the compiler is having a problem with the DirectX framework, when it references it, it goes into limbo! I am redownloading the framework, somehow though... I don't expect that this is a solution, any ideas greatly appreciated!

 

AHA! When searching for the DirectX download I was directed(no pun intended) to DirectX 11! Downloading Version 9 now... I can't imagine all the trouble this is going to cause for nubes like myself...

Edited by SleepingTroll

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...