Jump to content

  • Log In with Google      Sign In   
  • Create Account

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


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
11 replies to this topic

#1 Narf the Mouse   Members   -  Reputation: 318

Like
0Likes
Like

Posted 05 July 2012 - 11:32 AM

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.

Edited by Narf the Mouse, 05 July 2012 - 11:35 AM.


Sponsor:

#2 Narf the Mouse   Members   -  Reputation: 318

Like
0Likes
Like

Posted 05 July 2012 - 01:45 PM

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.

#3 ankhd   Members   -  Reputation: 1275

Like
1Likes
Like

Posted 06 July 2012 - 01:58 AM

Hello.
try this out.http://takinginitiative.net/2011/01/12/directx10-tutorial-9-the-geometry-shader/

#4 Narf the Mouse   Members   -  Reputation: 318

Like
0Likes
Like

Posted 06 July 2012 - 09:17 AM

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

Thanks; read, bookmarked.

#5 MJP   Moderators   -  Reputation: 11307

Like
1Likes
Like

Posted 06 July 2012 - 04:50 PM

You could look into the DirectXTK, which has a sprite renderer class for D3D11.

#6 DevLiquidKnight   Members   -  Reputation: 834

Like
0Likes
Like

Posted 06 July 2012 - 05:23 PM

This site has a an example of how to render 2D objects to the screen using directx10 and 11. http://rastertek.com/tutindex.html

#7 eFoDay   Members   -  Reputation: 300

Like
0Likes
Like

Posted 07 July 2012 - 03:06 PM

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

This topic introduces Direct2D, a new 2-D graphics API for Windows 7. Direct2D provides Win32 developers with the ability to perform 2-D graphics rendering tasks with superior performance and visual quality.

What is Direct2D?
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. The Direct2D API is designed to interoperate with existing code that uses GDI, GDI+, or Direct3D.

Direct2D is designed primarily for use by the following classes of developers:

  • Developers of large, enterprise-scale, native applications.
  • Developers who create control toolkits and libraries for consumption by downstream developers.
  • Developers who require server-side rendering of 2-D graphics.
  • 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).



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

Here are some of the new additions to Direct2D for Windows 8 Release Preview.
The list here shows these features and some related interfaces.
Starting with Windows 8 Direct2D is built on top of Direct3D 11.1.



Direct2D Quickstart for Windows 8 - http://msdn.microsof...0(v=vs.85).aspx

#8 mhagain   Crossbones+   -  Reputation: 7960

Like
-1Likes
Like

Posted 07 July 2012 - 03:38 PM

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.

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#9 Narf the Mouse   Members   -  Reputation: 318

Like
0Likes
Like

Posted 09 July 2012 - 07:01 PM

Thanks; informative.

#10 DarkRonin   Members   -  Reputation: 610

Like
0Likes
Like

Posted 10 July 2012 - 03:15 AM

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.

#11 mhagain   Crossbones+   -  Reputation: 7960

Like
0Likes
Like

Posted 10 July 2012 - 03:48 AM


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.


Try a test.

Fire up PIX.

Select a program using ID3DXSprite.

Do a single frame capture and tell it to also capture D3DX calls.

Run for a bit, press F12 to capture the frame, then quit.

Scroll down through the call list, find a call into ID3DXSprite, then expand it.

See all the SetTextureStageState calls, the SetTexture calls, the SetStreamSource calls, the DrawIndexedPrimitive calls? That's what I mean. It's not hardware support for sprites, it's purely a software wrapper, and it's something you can write yourself for D3D11 using the equivalent calls.

It's also the case that D3DX is not D3D. D3DX is a higher level utility library built on top of D3D (source: http://www.microsoft.com/en-us/download/details.aspx?id=22275, http://msdn.microsoft.com/en-us/library/windows/desktop/bb172965%28v=vs.85%29.aspx), and you can even use some D3DX functions and interfaces in OpenGL (such as the matrix library). The two of them should not be mixed up in this manner.

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#12 DarkRonin   Members   -  Reputation: 610

Like
0Likes
Like

Posted 10 July 2012 - 04:12 AM

I guess you are right when you look at it depending on your point of view (hardware vs software) :)

But, the first link you provided is for DirectX 8.0b.

D3DX9 (utilities) are a standard a part of the DirectX 9 SDK (not a separate download), therefore (as far as I am concerned) sprites are a standard part of Direct X 9.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS