locked
Which DX Library to Use?

    Question

  • I want to write my 2D game in C#/XAML, but the game pieces will have to be implemented in DirectX to achieve the look I want. I plan to use class SurfaceImageResource for the game pieces. Each game piece will be represented by an image clipped to a non-rectangular shape. I also need to apply a couple of pixel shaders to each game piece. I have no experience with DX, so before I dive in I need to know whether D2D is the right library for this task? I assume D2D is easier to learn than D3D. Or, would it be better to use D3D?

    Also, do you have a recommendation for a good book or other resource for learning D2D/D3D?
    Sunday, August 19, 2012 12:17 AM

Answers

  • Could you elaborate more on what you're planning to draw?  Some details that could help you identify the best approach include:

    • Do the pieces need to animate in some way?  (if they're static or only have a few different visual states, pure XAML and pre-rendered images might even be easiest without requiring DX at all)
    • Would the pieces be composed of just 2D geometries, or do they need to be fully 3D rendered models with dynamic lighting, e.g. the output of programs like these?  If they're just clipped 2D content, Direct2D should provide everything you need and would be an easier approach than D3D.
    • What are the pixel shaders meant to accomplish?  Could the desired result be accomplished more easily with the built-in Direct2D effects?

    As the name would suggest, Direct2D is primarily for drawing two dimensional content (shapes, lines, images, text, etc.) which can then be painted with various brushes, transformed in pseudo-3D space, and have effects applied.  The following should be helpful in describing its capabilities:

    Direct2D API overview topic

    Original Direct2D introduction article

    Note you can also freely mix Direct2D and Direct3D content as discussed in this MSDN topic

    • Marked as answer by Bob Flora Tuesday, August 21, 2012 1:46 AM
    Monday, August 20, 2012 6:14 PM