Skip to main content
GameDev.net gamedev.net
🔒 Locked

[SlimDX] DirectX 10 Tutorials

Started by Axiverse Sep 23, 2008 at 11:55 PM 11 replies 19.7k views
Original Post
Axiverse
Axiverse
Hello, I'm writing a few tutorials covering DirectX 10 using SlimDX. I've recently picked up SlimDX for a game that I'm programming and I thought it might be nice to do a small series on DirectX 10 and SlimDX. These tutorials require the following: -DirectX (this also means that these are Vista only) -SlimDX -C# 2008 Tutorial 1 This is a fairly quick tutorial covering the initialization process for DirectX 10. It's a bit different from DirectX 9 - a lot more verbose but very clear and easy to understand. Tutorial 2 Next we get into drawing out a triangle on the screen. The shader that's used in the tutorial basically just spits out what it takes in. Also this tutorial uses a more efficient game loop - basically the standard for C# game development at the moment. Tutorial 3 Onto the third dimension - This tutorial puts the camera matrices into the equation and renders a rotating square. Also it uses the index buffer in conjunction with the vertex buffer. I'm hoping that this will pick up pretty quick, though I guess that depends on how much time I have. I want to get into some advanced shader authoring. And since the game I'm working on is a RTS, I may get around to some steering behavior and AI algorithms as well. If you find anything wrong or are having trouble understanding anything don't hesitate to ask. Also I'm open for suggestions for future tutorials (after the basics). P.S. I want another release of SlimDX cause I'm too lazy to build it.
miroslav_karpis
miroslav_karpis
Hi,

at first many thanks for the turorials. I'm new in slimDX...
I was trying your tutorial no.1 and after I openeded the project in express visual c# I got several errors:

first one is:
Warning 1 The referenced component 'SlimDX' could not be found.


even I have added the component dll manually....I hope that correct.
Please can you help me with that?
miroslav_karpis
miroslav_karpis
hi again...

so I managed the first issue...now I don't have errors but when I want build I'm getting following error:


System.Runtime.InteropServices.SEHException was unhandled
Message="External component has thrown an exception."
Source="SlimDX"
ErrorCode=-2147467259
StackTrace:
at CreateDXGIFactory(_GUID* , Void** )
at SlimDX.DXGI.Factory..ctor()
at Axiverse.Tutorial1.Program.Main() in C:\Documents and Settings\mirkar\Desktop\Tutorial1\Tutorial1\Program.cs:line 43
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
davepermen
davepermen
just because I love it:

tutorial 1 in c# 3.0 'style'. (i love the initialisation that way)

using System;using System.Collections.Generic;using System.Drawing;using System.Linq;using System.Windows.Forms;using SlimDX;using SlimDX.DXGI;using SlimDX.Direct3D10;using Device = SlimDX.Direct3D10.Device;namespace Axiverse.Tutorial1{    static class Program    {        [STAThread]        static void Main()        {            var renderForm = new Form()            {                ClientSize = new Size(640, 480),                Text = "Axiverse's SlimDX Tutorial 1 - Initializing Direct3D 10"            };            renderForm.Show();            var swapDesc = new SwapChainDescription()            {                ModeDescription = new ModeDescription()                {                    Format = Format.R8G8B8A8_UNorm,                    RefreshRate = new Rational(60, 1),                    Scaling = DisplayModeScaling.Unspecified,                    ScanlineOrdering = DisplayModeScanlineOrdering.Unspecified,                    Width = renderForm.ClientSize.Width,                    Height = renderForm.ClientSize.Height                },                SampleDescription = new SampleDescription()                {                    Count = 1,                    Quality = 0                },                BufferCount = 1,                Flags = SwapChainFlags.None,                IsWindowed = true,                OutputHandle = renderForm.Handle,                SwapEffect = SwapEffect.Discard,                Usage = Usage.RenderTargetOutput            };            var device = new Device(DeviceCreationFlags.None);            var factory = new Factory();            var swapChain = new SwapChain(factory, device, swapDesc);            var renderTarget = new RenderTargetView(device, swapChain.GetBuffer<Texture2D>(0));            device.OutputMerger.SetTargets(renderTarget);            while (renderForm.Created)            {                int luminosity = (int)(127 * Math.Sin(DateTime.Now.TimeOfDay.Ticks / 5000000f) + 127);                device.ClearRenderTargetView(renderTarget, Color.FromArgb(luminosity, luminosity, luminosity));                swapChain.Present(0, PresentFlags.None);                Application.DoEvents();            }            device.ClearState();            renderTarget.Dispose();            device.Dispose();            swapChain.Dispose();            factory.Dispose();            renderForm.Dispose();        }    }}


and I guess one could just forget about the values that are default values, removing a lot of boilerplate code..
If that's not the help you're after then you're going to have to explain the problem better than what you have. - joanusdmentia
My Page davepermen.net | My Music on Bandcamp and on Soundcloud
miroslav_karpis
miroslav_karpis
at first many thanks for, but my problem is still a problem...

Mike.Popoloski: I have the last version of activeX
davepermen: I have tried also your code...but that one ended up with some other error.

Most probably I'm some really stupid mistake. Here is what I do:

1. downloaded the tutorial.zip file
2. unpacked + loaded in visual c# express the Tutorial1.sln
3. references added slimDX
4. builded solution (pf6) - build succeeded
5. pf5 debug - error in line (line higlighted)

var device = new Device(DeviceCreationFlags.None);

error info (what I pasted before) +:
- SEHException was unhandled

The form is loaded-opened without anything (empty)

I really don't know - what more data should I give you?
Axiverse
Axiverse
@ miroslav_karpis: So it seems that it's failing on the first DirectX 10 call. Just to be sure - are you sure that you have a DirectX 10 video card? Also you're on vista right? Besides that I don't know what could be going wrong.

@ davepermen: Yeah, it's been a while since I've programmed so I'm still learning about the new quirks in the C# 2008. You'll see that I do use those initializes in the third tutorial though.
miroslav_karpis
miroslav_karpis
so most probably here is the problem:

I'm on XP + than I have most probably only activeX 9 (but I'm not sure how to check)...

does it mean that I can not use slimDX?
Phantom Sage
Phantom Sage
Quote:
Original post by miroslav_karpis
so most probably here is the problem:

I'm on XP + than I have most probably only activeX 9 (but I'm not sure how to check)...

does it mean that I can not use slimDX?


You can use SlimDX if you stick to the DirectX 9 interfaces. However you will not be able to use the DirectX 10 interfaces because it's only supported on Vista and will only work with DirectX 10 compliant video cards.
Axiverse
Axiverse
Yeah, sorry about that. I wanted to focus on DirectX 10, so that means that these will not work on SlimDX. As Tape_Worm stated, you can use SlimDX with DirectX 9 on windows XP, but they will require different code.
davepermen
davepermen
Quote:
Original post by Axiverse
@ davepermen: Yeah, it's been a while since I've programmed so I'm still learning about the new quirks in the C# 2008. You'll see that I do use those initializes in the third tutorial though.


yes, i've noted it afterwards. now you need to get into the habbit of 'var' and it'll be perfect hrrhrr :)
If that's not the help you're after then you're going to have to explain the problem better than what you have. - joanusdmentia
My Page davepermen.net | My Music on Bandcamp and on Soundcloud
Fragsta
Fragsta
Hey Axiverse, thanks for making these tutorials. I'm quite eager to get started on them but unfortunately when trying to run Tutorial 1, the SlimDX file cannot be found apparently. "FileNotFoundException" was thrown and it says it cannot load file or assembly 'SlimDX, Version=2.0.5.39, Culture=neutral, PublicKeyToken=b1b0c32fd1ffe4f9' or one of its dependencies.

Originally it was simply not finding the reference or namespace but I fixed that by just doing a quick reboot (Hadn't since installing SlimDX) and adding it manually. This is new, though - it's definitely installed, and it's the latest version. The DX10 runtime and SDK are both installed too. What else could it be?

Oh also, I'm on Vista x64, but I got the 32-bit version of SlimDX as I don't intend to make apps just for 64-bit processors.

Hope you can help, cheers.
szpaq234
szpaq234
websites expired, I love the Internet

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.