3
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ Yes, you can use it for 2D games, you just ignore the Z axis and Z buffer while doing it. \$\endgroup\$ – János Turánszki Jan 25 '15 at 15:20
  • \$\begingroup\$ 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. \$\endgroup\$ – user3187144 Jan 25 '15 at 16:37
  • \$\begingroup\$ If Direct2D uses Direct3D at the end, then how can it have worse support? \$\endgroup\$ – Daniel Kmak Jan 25 '15 at 22:30
  • \$\begingroup\$ @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. \$\endgroup\$ – user3187144 Jan 25 '15 at 22:42
  • \$\begingroup\$ @user3187144 Actually I came across similiar opinion about Direct2D and I've believed it, but now I think its a myth. \$\endgroup\$ – Daniel Kmak Jan 25 '15 at 22:45
3
\$\begingroup\$

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.

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

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)

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ 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? \$\endgroup\$ – user3187144 Jan 25 '15 at 15:40
  • \$\begingroup\$ 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. \$\endgroup\$ – Eejin Jan 25 '15 at 16:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.