views:

13

answers:

1

I am getting an unhandled exception when trying to create a D3d device.

This is literally the whole code in C#. I am just testing and trying to learn directx. I am getting the Unhandled exception on this line : device = new Device(0, DeviceType.Hardware, this,CreateFlags.SoftwareVertexProcessing, presentParams);

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using Microsoft.DirectX;
    using Microsoft.DirectX.Direct3D;

    namespace WindowsFormsApplication2
    {
    public partial class Form1 : Form
    {

        public Form1()
        {
            InitializeComponent();
            Device device = null;              // Create rendering device
            PresentParameters presentParams = new PresentParameters();

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

            RenderToSurface render = new RenderToSurface(device, 300, 300, Format.D32, true, DepthFormat.D32);           

        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }
    }
}

Kind of blowing my mind because it looks like all the params are right..

A: 

needed presentParams.Windowed = true in order for this to work.

Tyler