Sprite Problem

I'm trying to do some simple 2D graphics with DirectX 9.0 (April version), so the first step is to display bitmaps. I found a tutorial that applies a texture to a rectangular triangle fan (quad), and that works perfectly. However, when I try to display a bitmap with the ID3DXSprite object, it looks a little blurry, as if the bitmap is offset from the screen coordinates by some fraction.

When using the texture-quad method, apparently you must offset the position of the vertices by -0.5f, but that does not work for the Sprite. In fact I've tried all sorts of offsets, but the result is always that the image is not quite right, even though it's the right size, not scaled or rotated, etc. It looks a little antialiased. I hope someone out there has had this problem and knows what I'm talking about.

I feel like this is some kind of setup problem, maybe with SetRenderState() or something.

Any suggestions

Thanks!



Answer this question

Sprite Problem

  • kevininspace

    My version of DirectX (April) did not come with a 2D sample.. I've been trying to figure out how to download older samples without downloading the entire old packages. ( )

    I'll try the c-unit code above, though.

    By the way, my image is 128x128 and is displayed at the right size.

    Thanks for the replies so far!


  • Bojan Exi

    Have you looked at the source code for Simple 2D in the SDK It does exactly what you're looking for.

  • VistaGuy

    It could probably be stretching the texture. Make sure your texture is of a power 2.
    8x8, 16x16, 32x32 and so on. You could also try and set the filtering of the rendering.
    Something like
    Device.SamplerState[0].MinFilter = TextureFilter.Point;
    Device.SamplerState[0].MagFilter = TextureFilter.Point;

    I hope this helps.
    Take care.




  • Kedmyster

    Here are the images, you will have to do a screen capture then zoom in to see the differences.

    http://www.ampersandwich.com/sprites

    The first picture is the raw image the way it should look. That's the way I made it in the Paint program.

    The second picture is the image displayed with the Sprite object, with the x and y positions at some integer +0.5. (The way it's supposed to be I think).

    The third picture is the image displayed with the Sprite object where the x and y positions are integers.


  • Maneeshg

    Also here's another sample.

    http://www.c-unit.com/tutorials/mdirectx/ t=46

    If these don't help you may need to send a picture and/or a code snippet



  • KWilliams

    By the way, I found the Simple 2D sample, but it's Managed DirectX, which I'm not using. Does the equivalent sample exist for regular C++
  • Sprite Problem