locked
Render an Image on Screen in DirectX RRS feed

  • Question

  • I know it's a very simple question, but how do I render an image on screen in DirectX and move it around (in 2D)?  Do I need to use matrices or the sprite class?

    A simple example would be great, I'm using vb.net by the way.  :)

    Wednesday, November 1, 2006 4:48 PM

Answers

  • Take a look at the Sprite class...
    The sprite class enables you to do what you need.

    1) You will need to create a texture
    2) You will then need a sprite object e.g. Sprite sprite = new Sprite(yourDevice);
    3) Then just use the sprite class in your render loop
    e.g.
    Sprite.Draw(theTexture...);

    Moving the sprite, you can do this in a number of ways.
    Either using the position Vector of the Sprite.Draw method or by setting the sprite flags to object space which is basically the following
    Extract from the Microsoft Managed DirectX documentation
    "Specifies no modification of the world, view, and projection transforms. The transforms currently set to the device are used to transform sprites when the batched sprites are drawn"

    I hope this helps.
    Take care.
    Thursday, November 2, 2006 10:17 AM
  •  Pete_O wrote:

    I know it's a very simple question, but how do I render an image on screen in DirectX and move it around (in 2D)?  Do I need to use matrices or the sprite class?

    A simple example would be great, I'm using vb.net by the way.  :)

    Look at the Simple 2D sample in the DirectX SDK if you want to use Managed DirectX (which is in C#, but there are several free C# to VB conversion tools on the web that can help you).  If you want to use XNA (again, in C#), check out the initial tutorials in the built-in help files.

     

    Thursday, November 2, 2006 5:21 PM

All replies

  • Take a look at the Sprite class...
    The sprite class enables you to do what you need.

    1) You will need to create a texture
    2) You will then need a sprite object e.g. Sprite sprite = new Sprite(yourDevice);
    3) Then just use the sprite class in your render loop
    e.g.
    Sprite.Draw(theTexture...);

    Moving the sprite, you can do this in a number of ways.
    Either using the position Vector of the Sprite.Draw method or by setting the sprite flags to object space which is basically the following
    Extract from the Microsoft Managed DirectX documentation
    "Specifies no modification of the world, view, and projection transforms. The transforms currently set to the device are used to transform sprites when the batched sprites are drawn"

    I hope this helps.
    Take care.
    Thursday, November 2, 2006 10:17 AM
  •  Pete_O wrote:

    I know it's a very simple question, but how do I render an image on screen in DirectX and move it around (in 2D)?  Do I need to use matrices or the sprite class?

    A simple example would be great, I'm using vb.net by the way.  :)

    Look at the Simple 2D sample in the DirectX SDK if you want to use Managed DirectX (which is in C#, but there are several free C# to VB conversion tools on the web that can help you).  If you want to use XNA (again, in C#), check out the initial tutorials in the built-in help files.

     

    Thursday, November 2, 2006 5:21 PM
  • OK thank you both.

    Pete

    Thursday, November 2, 2006 10:00 PM