[SlimDX] Getting started with SlimDX & DirectX 9c

Started by
4 comments, last by jpetrie 13 years, 4 months ago
Hi,

I'm trying to learn SlimDX, but I only have XP and DirectX 9c available to me (I know, I know - it's a long story!). Consequently the excellent tutorials are rather hard to follow as they are aimed at SlimDX.Direct3D11.

I have tried to follow along and write the equivalent code (below) aimed at SlimDX.Direct3D9 - with some success as I get a window up, but it aint blue!

Any clues? Or is there a legacy tutorial somewhere aimed at SlimDX.Direct3D9 dinosaurs such as myself?

Here's what I see: http://www.flickr.com/photos/astronomytoolbox/5221607990/

And here's the code that makes those pretty patterns:

static void Main()
{
RenderForm form = new RenderForm("Tutorial 2: Device Creation");

PresentParameters presentParams = new PresentParameters();
presentParams.DeviceWindowHandle = form.Handle;
presentParams.Windowed = true; // We don't want to run fullscreen
presentParams.SwapEffect = SwapEffect.Discard; // Discard the frames
presentParams.EnableAutoDepthStencil = true; // Turn on a Depth stencil
presentParams.AutoDepthStencilFormat = Format.D24S8; // And the stencil format
presentParams.BackBufferFormat = Format.A8R8G8B8;
presentParams.PresentationInterval = PresentInterval.Default;
presentParams.BackBufferWidth = form.ClientSize.Width;
presentParams.BackBufferHeight = form.ClientSize.Height;

Device device = new Device(
new SlimDX.Direct3D9.Direct3D(), 0, DeviceType.Hardware, form.Handle, CreateFlags.HardwareVertexProcessing, presentParams);

SwapChain swapChain = new SwapChain(device, presentParams);

Viewport viewport = new Viewport(0, 0, form.ClientSize.Width, form.ClientSize.Height);

MessagePump.Run(form, () =>
{
device.Clear(ClearFlags.Target, new Color4(0.5f, 0.5f, 1.0f), 1.0f, 0);
swapChain.Present(Present.None);
});

swapChain.Dispose();
device.Dispose();
}
Advertisement
Check out the d3d9 samples that came with the framework.

In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.

In particular, look at MiniTri.
Specifically "program.cs".

Lines 65 through 76 or lines 85 through 96 depending on your revision.

In time the project grows, the ignorance of its devs it shows, with many a convoluted function, it plunges into deep compunction, the price of failure is high, Washu's mirth is nigh.

Thank you everyone! Works a charm.

I'm going to be using SlimDX to do some surface plots (3D data visualisation) of data in my astronomy application.

Do you have any useful links or info on 3D surface plots, meshing, colourising etc?
It's not an area I'm familiar with, in general, but I believe that another user on these forums (GoodFun, maybe?) is doing something similar. You may want to peruse his threads.

This topic is closed to new replies.

Advertisement