Sign in to follow this  
Raptisoft

Migrating from DX7 to DX10

Recommended Posts

Hi all,

For years now I've had a stable graphics engine that I've been using for development, using DirectX7 (I'm also somewhat familiar with DX8, but have been using DX7 for backwards compatibility reasons).

I've decided to enter the modern era, so I'm re-coding things to work with DX10. Holy cow, have things changed. It looks like they made all the hard stuff simple, and all the simple stuff hard.

I'm looking to render 2D at the moment, eventually mixing 2D and 3D.

So I get DirectX10 up and running in only a few minutes... and there I am stalled. A lot of my framework code depends on acrobatic use of DrawPrimitive from DX7... I typically am drawing sprites by defining four vertices to make a triangle strip, and I want the freedom and flexibility to color those pixels however I want, *and* I want the freedom and flexibility to render more than four, if I want to render complex shapes. My sprites are all clustered on one big texture, so typically I simply draw a section of that texture. But sometimes I do solid color or gradient fills. Pretty simple stuff, nothing hardcore.

But: How the heck do you do simple stuff in DX10??? When I google it, I find 50 pages of shaders and layouts and all kinds of crazy stuff... just to render a white triangle?

For real? Or is there some simpler way that I'm missing in the noise?

I fiddled with Direct2D a bit, but it doesn't appear to give me the flexibility to color each vertex seperately, and also seems (?) like it can't be made to lay over 3D graphics anyway, a capability I want.

So what say you, know of any tutorials or whatnot on how to get the effect of simple DrawPrimitive calls in DX10?

Thanks in advance for any tips or help you can give!

Share this post


Link to post
Share on other sites
First things first; don't use DX10.

DX10 has been superceeded by DX11, which has feature levels to let it work on DX9 to DX11 hardware.

What you've got here is the difference between Fix Function Pipeline and shaders.

You still have all that flexibility, you just need 3 pixel shaders to do it;
- one to sample the texture
- one to render a fix colour
- one to do the gradient fills

The simple stuff is just as simple really;
- a buffer with some vertices in them
- a set of shaders to do the draw
- a draw command

Alot of the views and layouts are mostly fluff you setup once and would just rebind as required.

Really the best source of information is the DX SDK; you aren't going to find much better.

Share this post


Link to post
Share on other sites
D3D11 is my recommendation too - you get more functionality, with the same clean API and it can run on downlevel hardware, all the way down to entry level DX9 cards. There isn't really any motivation for use D3D10 over D3D11.

As far as learning about how it works, you can take a look at our D3D10 book which will serve as a decent reference (even for D3D11) with lots of code samples. Also, my D3D11 engine is available as open source and can be used to demonstrate how to do various tasks.

For finding a low level simple program, it might be a bit difficult to find something that is really basic. You could the DXSDK samples, but they are also built on a framework so they aren't the simplest possible thing. Quite some time ago Jack Hoxley posted some starter code that might be a good starting point to experiment with in his journal. Here is what I found with a quick search. I have also written several short articles here and there in my journal as well - a quick search for D3D11 will give you a few hits.

Share this post


Link to post
Share on other sites
I find with the SDK examples the best thing todo is ignore all the DXUT stuff and focus on what the drawing/update functions are doing; if you can ignore all the fluff they are still decent references.

Having a look at some of my code it looks like you could setup a D3D11 app in around 300ish line of (well spaced) code (and comments). At some point I need to break this code out I think, as its a bit tangled with other code.

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