Sign in to follow this  
r_g_bowman

[SlimDX] Getting started with SlimDX & DirectX 9c

Recommended Posts

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

Share this post


Link to post
Share on other sites
Specifically "program.cs".

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

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this