What's the best way to do 2D graphics in DirectX?

Started by
10 comments, last by DividedByZero 11 years, 9 months ago
Edit: By "2D graphics", I mean the basics of drawing images/sprites on the screen.
Edit2: DirextX9 has Sprites, but DX11 doesn't. My engine is to support both.

I can see two solutions:

1) Paste images onto mesh quads and draw the quads.
2) Use Direct2D, which seems to be both depreciated? and not very featureful.

Further, tutorials on this issue would be appreciated.

Thanks.
Advertisement
Looks like it's #1. Should be able to manage that, although I still wouldn't refuse a tutorial on how to create a sprite renderer.
Hello.
try this out.http://takinginitiative.net/2011/01/12/directx10-tutorial-9-the-geometry-shader/

Hello.
try this out.http://takinginitiat...eometry-shader/

Thanks; read, bookmarked.
You could look into the DirectXTK, which has a sprite renderer class for D3D11.
This site has a an example of how to render 2D objects to the screen using directx10 and 11. http://rastertek.com/tutindex.html
Here are some things that lead me to believe Direct2D is a good choice for 2D graphics in DirectX:

http://msdn.microsof...7(v=vs.85).aspx

[color=#2A2A2A][font=verdana,geneva,sans-serif]This topic introduces [/font][color=#ff0000][font=verdana, geneva, sans-serif]Direct2D, a new 2-D graphics API for Windows 7[/font][color=#2A2A2A][font=verdana,geneva,sans-serif]. Direct2D provides Win32 developers with the ability to perform 2-D graphics rendering tasks with superior performance and visual quality.[/font]

[font=verdana,geneva,sans-serif]What is Direct2D?[/font]
[color=#ff0000][font=verdana, geneva, sans-serif]Direct2D is a hardware-accelerated, immediate-mode 2-D graphics API that provides high performance and high-quality rendering for 2-D geometry, bitmaps, and text.[/font][color=#2A2A2A][font=verdana,geneva,sans-serif] The Direct2D API is designed to interoperate with existing code that uses GDI, GDI+, or Direct3D.[/font]

[color=#2A2A2A][font=verdana,geneva,sans-serif]Direct2D is designed primarily for use by the following classes of developers:[/font]

  • [font=verdana,geneva,sans-serif]Developers of large, enterprise-scale, native applications.[/font]
  • [font=verdana,geneva,sans-serif]Developers who create control toolkits and libraries for consumption by downstream developers.[/font]
  • [font=verdana,geneva,sans-serif]Developers who require server-side rendering of 2-D graphics.[/font]
  • [color=#ff0000][font=verdana, geneva, sans-serif]Developers who use Direct3D graphics and need simple, high-performance 2-D and text rendering for menus, user interface (UI) elements, and Heads-up Displays (HUDs).[/font]

[font=verdana, geneva, sans-serif][/quote][/font]

http://msdn.microsof...8(v=vs.85).aspx
[font=verdana, geneva, sans-serif]
[/font][font=verdana,geneva,sans-serif]Here are some of the [color=#ff0000]new[color=#ff0000] additions to Direct2D for Windows 8[color=#2A2A2A] Release Preview.[/font]
[color=#2A2A2A][font=verdana,geneva,sans-serif]The list here shows these features and some related interfaces.[/font]
[color=#ff0000][font=verdana, geneva, sans-serif]Starting with Windows 8 Direct2D is built on top of Direct3D 11.1[/font][font=verdana, geneva, sans-serif].[/font]
[font=verdana, geneva, sans-serif][/quote][/font]

[color=#ff0000]Direct2D Quickstart for Windows 8 - http://msdn.microsof...0(v=vs.85).aspx
Direct3D 9 doesn't actually have sprites.

What it has is a wrapper around vertex buffers, index buffers, textures, states and regular geometry. That's exactly all that ID3DXSprite is - a wrapper that draws ordinary textured triangles. It makes calls to the lower-level D3D API using code that you can write yourself, so that option is also there for 10 and 11.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

Thanks; informative.

Direct3D 9 doesn't actually have sprites.

What it has is a wrapper around vertex buffers, index buffers, textures, states and regular geometry. That's exactly all that ID3DXSprite is - a wrapper that draws ordinary textured triangles. It makes calls to the lower-level D3D API using code that you can write yourself, so that option is also there for 10 and 11.


Direct3D9 has ID3DXSprite as you stated. Therefore, Direct3D9 has sprites.

Everything in programming is a 'wrapper' for something else, when you think about it.

This topic is closed to new replies.

Advertisement