I try to start c# directX programming with this tutorial: http://www.riemers.net/eng/Tutorials/DirectX/Csharp/Series1/tut2.php I'm using visual Studion Community 2015, my code is like this:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;
namespace DirecxTest01
{
public partial class Form1 : Form
{
private Device device;
public Form1()
{
InitializeComponent();
InitializeDevice();
}
private void InitializeDevice()
{
PresentParameters presentParams = new PresentParameters();
presentParams.Windowed = true;
presentParams.SwapEffect = SwapEffect.Discard;
device = new Device(0, DeviceType.Hardware, this, CreateFlags.SoftwareVertexProcessing, presentParams);
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
device.Clear(ClearFlags.Target, Color.DarkSlateBlue, 1.0f, 0);
device.Present();
}
}
}
I also addesd References to all the DirectX dll's. Whe I run the Programm nothing happened, not even the Form Window appers. No error message, just nothing. I tried to comment out the DirectX Stuff line by line. Even with this code the Programm hangs up:
private void InitializeDevice()
{
PresentParameters presentParams = new PresentParameters();
//presentParams.Windowed = true;
//presentParams.SwapEffect = SwapEffect.Discard;
//device = new Device(0, DeviceType.Hardware, this, CreateFlags.SoftwareVertexProcessing, presentParams);
}
When I out comment
//PresentParameters presentParams = new PresentParameters();
to, at least the Windowas Form apperears.
Whats wrong with my code?