Hi. Recently I decided to give another shot at managed DirectX.. so I installed SlimDX and on the first program I'm trying to do, I can't even create the device... It gives me an D3DERR_INVALIDCALL at this line:
Code:
D3DDev = new Device(D3D, 0, DeviceType.Hardware, IntPtr.Zero, CreateFlags.HardwareVertexProcessing, pp);
I have no idea what's wrong... Someone can help me?
Here's my whole code.. that does nothing at all
Code:
using System;using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SlimDX.Direct3D9;
namespace ExternalCrosshair
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Direct3D D3D;
Device D3DDev;
IntPtr handle = new IntPtr();
bool stop = false;
private void button1_Click(object sender, EventArgs e)
{
CreateCrosshairWindow();
}
private void CreateCrosshairWindow()
{
D3DStartup();
Thread.Sleep(500);
timer1.Enabled = true;
if (stop)
D3DShutDown();
}
private void timer1_Tick(object sender, EventArgs e)
{
Render();
}
private void D3DStartup()
{
PresentParameters pp = new PresentParameters();
pp.Multisample = MultisampleType.None;
pp.Windowed = true;
pp.SwapEffect = SwapEffect.Discard;
pp.BackBufferFormat = Format.Unknown;
pp.BackBufferHeight = 600;
pp.BackBufferWidth = 800;
D3D = new Direct3D();
D3DDev = new Device(D3D, 0, DeviceType.Hardware, IntPtr.Zero, CreateFlags.HardwareVertexProcessing, pp);
}
private void Render()
{
D3DDev.Clear(ClearFlags.All, new SlimD*****lor4(Color.Blue), (float)1.0, 0);
}
private void D3DShutDown()
{
D3D.Dispose();
D3DDev.Dispose();
}
}
}