2D in Direct3D

Started by
5 comments, last by Manaxter 17 years, 8 months ago
Hi Guys. First off I would like to apologise for this thread, as this question has probably been asked several times. I have been stuffing around with C++ for a few years now on and off and I have an alright handle of it. I've always wanted to use directX for games, but tried to learn it a couple of times and it just went over my head. I tried again recently and I got a lot more of it but it was still just out of my reach. I want to make a 2D game, simply because it is easier on my questionable graphics skills and (supposedly) on my questionable programming skills. What I'm looking for are some tutorials specifically designed for 2D in direct3D 9. What I really like the sound of is hardware accelerated alpha, rotation and scaling (which libraries like SDL don’t provide, without OpenGL). I've been doing some reading (Forum FAQ, This GameDev article) and what I seem to believe is that using things like ID3DXSprite and the like don't allow for hardware alpha etc. (Reading this implies to me that I have to use "Regular 3D geometry via an orthographic projection" in order to achieve this.) So if anybody here can either dispel the myth that pre-transformed vertexes are exempt from hardware acceleration or can point me to some good tutorials that use "Regular 3D geometry via an orthographic projection" that would be most helpful. Cheers Jacob
"You're worth all the discount milk in the world!" - Mum
Advertisement
Quote:Original post by Manaxter
and what I seem to believe is that using things like ID3DXSprite and the like don't allow for hardware alpha etc.

Yep, this is not true - ID3DXSprite can do hardware alpha blending just fine (all you have to do is specify an additional flag so it knows which render states to set).

It is important to know that sprite is just a utility interface - it goes through all of the same D3D APIs that you do. All it really does is cache a lot of textures that you feed to it, then batch render them all (aside from some options for alpha blending, color modulation, and billboarding). It's actually pretty fast - the average graphics programmer would have to spend quite a bit of time writing a system that could beat it.
Dustin Franklin ( circlesoft :: KBase :: Mystic GD :: ApolloNL )
Ok, so sending pre-transformed vertexes (that's what the ID3DXSprite does yeah?) still allows for hardware accelleration? Or have I got those two parts confused. Thanks for the help circlesoft!
"You're worth all the discount milk in the world!" - Mum
Quote:Original post by Manaxter
Ok, so sending pre-transformed vertexes (that's what the ID3DXSprite does yeah?) still allows for hardware accelleration?

This is correct. Pre-transforming them just skips the vertex shader having to multiply the positions by the view & projection matrices. Remember, the view transform goes from world -> camera space, while the projection transform goes from camera -> screen space. If you already start in screen space, you can just skip those steps.
Dustin Franklin ( circlesoft :: KBase :: Mystic GD :: ApolloNL )
Thanks!

Do you know of any good resources (internet or otherwise) that could help me? I should be alright but a good tutorial could save me many hours of heartache.

Thanks again.
Jacob
"You're worth all the discount milk in the world!" - Mum
Sure:

- Here is an entire FAQ section about 2D rendering in D3D.

- Here is a cool C-Unit tutorial about animating your sprites

- Here is a CodeSampler tutorial about sprites

In addition, check out the 'Additional Resources' section of the DX forum FAQ for lots of tutorial sites.
Dustin Franklin ( circlesoft :: KBase :: Mystic GD :: ApolloNL )
Cheers, your Googling skills obviously surparse mine!
"You're worth all the discount milk in the world!" - Mum

This topic is closed to new replies.

Advertisement