Jason
Jason

Reputation: 85

DirectX 10 Drawing a .PNG

I'm looking for a tutorial on how to draw a .PNG using DirectX 10, although I'm having no luck. Anyone know where I can find more information on this? I want to create a 2D game

Upvotes: 1

Views: 1094

Answers (2)

Vertexwahn
Vertexwahn

Reputation: 8142

you can use D3DX10CreateShaderResourceViewFromFile to create a shader-resource view from a PNG file. This tutorial explains how it works.

In short:

  • Create a shader to draw a rectangle
  • Create vertex layout
  • Create a vertex buffer which stores the vertices of the rectangle
  • Create a sampler to sample the texture
  • Create a texture object
  • Draw the scene

Upvotes: 0

Gnietschow
Gnietschow

Reputation: 3180

You can load a png as a texture and render it the same way you render other images. For the transparency you can use Alphablending which you enable with Renderstates. (Tutorial, only googled not tested)

Upvotes: 1

Related Questions