# Could I use Direct3D to make 2D games?

My goal is to make a completely 2D game using DirectX, but I'm new to it and I'm confused about all of the different APIs that are available.

From Wikipedia:

Direct3D is used to render three-dimensional graphics, ... Integration with other DirectX technologies enables Direct3D to deliver such features as video mapping, hardware 3D rendering in 2D overlay planes, and even sprites, providing the use of 2D and 3D graphics in interactive media ties.

So I guess that I can use Direct3D to make HUD and GUI (2D) elements of the game using sprites, but can I use it for a completely 2D game or should I use Direct2D instead?

The reasons because I'd prefer to use Direct3D rather than Direct2D (please correct me if I'm wrong on any of this points) are:

• I don't want to use an API that abstracts me too much from what's going
• Direct2D uses Direct3D at the end
• I could find myself wanting to learn 3D programming in the future

And in case that I could use (and maybe choose) Direct3D, since it is such a massive API, which subset of it would someone need to make a 2D game?

I hope the question is not too broad, thanks in advance.

• Yes, you can use it for 2D games, you just ignore the Z axis and Z buffer while doing it. – János Turánszki Jan 25 '15 at 15:20
• For more information about making 2D games with DirectX, this article: msdn.microsoft.com/en-us/library/windows/apps/hh452790 has been also helpful to me. – user3187144 Jan 25 '15 at 16:37
• If Direct2D uses Direct3D at the end, then how can it have worse support? – Daniel Kmak Jan 25 '15 at 22:30
• @Daniel I know it makes no sense, I read something like that but I can't remember what it said exactly, maybe I'm just wrong sorry. – user3187144 Jan 25 '15 at 22:42
• @user3187144 Actually I came across similiar opinion about Direct2D and I've believed it, but now I think its a myth. – Daniel Kmak Jan 25 '15 at 22:45

Remember that Direct3D is actually drawing everything in 2D as it's just pixels on the screen. The pipeline is sophisticated enough to handle 3D projection, but you don't have to use it to that.

Direct2D is best if you are drawing traditional vector-graphics like arcs, circles, styled-lines, etc. If you are just manipulating bitmaps (aka 2D sprites), then use SpriteBatch in the DirectX Tool Kit for Direct3D 11. It's shared source so you can dig into what it's doing.

• Thanks a lot! Your answer cleared up my doubts and I didn't know about the DirectX Tool Kit, thanks. – user3187144 Jan 25 '15 at 22:33

The biggest difference between 2D and 3D is well.. one dimension. So just remove one of the dimensions! Imagine that 3D is just composed of a lot of 2D slices. So to draw just one slice you would draw everything of the third dimension on 1 value.

A 2D rectangle would be composed of the following points:

(0,0,0).....(1,0,0)
.
.
.
(0,1,0).....(1,1,0)

• Thanks! So I basically ignore the z-axys where it must be provided, but do you know if there is any 2D specific functions/methods or should I learn mostly all the 3D API? – user3187144 Jan 25 '15 at 15:40
• Well there are not really 2D specific functions in a 3D API apart from maybe some math functions. Though I'd read up on an orthographic projection. – Eejin Jan 25 '15 at 16:45