Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm running into trouble trying to figure out the best way to draw textures to the screen using Directx 11.1 (for Metro apps).

In XNA, I used SpriteBatch. Is there something partially comperable?

In the Win8 SDK examples, they used WIC and Bitmap, although it suggests that that is not the best way to draw 2D graphics with the best performance.

share|improve this question
    
I really recomend you look at Allen Pestaluky's answer. An author of the XNA library ported sprite batch to D3D11 which would prably help you immensly. –  ClassicThunder Jul 8 '13 at 20:14

2 Answers 2

up vote 2 down vote accepted

In XNA, I used SpriteBatch. Is there something partially comperable?

No. Direct3D is a low-level rendering system. It's job is not to make your life easier (like XNA); it's job is to provide a bare-bones interface to graphics hardware.

You do not "draw textures" in D3D. You draw triangles, which have textures mapped onto them with shaders. Two triangles form a rectangle or "quad" (short for quadrilateral), which is how you draw textures.

To do this in D3D, you need to fill a vertex buffer with the vertex positions and texture coordinates for the triangles you want to render. You will also need a (very simple) pair of shaders, vertex and pixel, which pass your positions and texture coordinates. Your pixel shader needs to use the texture coordinate it gets from the vertex shader to fetch from the texture. And that texture's color becomes the pixel shader output.

You use all of these, the two shaders, the texture, and the vertex buffer, to render.

Low-level isn't easy, and it's not meant to be.

share|improve this answer
    
Thanks Nicol, could you possibly direct me to a resource to learn how to do this? –  kanno41 Jan 26 '12 at 3:42
    
Just stop looking for D3D 11.1 information specifically. D3D 11.1 is not that different from D3D 11, which is not that different from D3D 10 with regard to how to do this. And even D3D 10 is not that different from how you do it in D3D 9 (you might use functions with slightly different names, but the principle is the same). Pretty much any resource on sprite rendering with D3D will help. –  Nicol Bolas Jan 26 '12 at 3:53

In XNA, I used SpriteBatch. Is there something partially comperable?

Now there is, yes. :) It's called the DirectX Tool Kit. Not as full-featured and mature as XNA, but it seems to get the job done and has been created by members of the orignal XNA team. Worth checking out.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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