Jump to content
  • Advertisement
Sign in to follow this  
djnevs

Blurred Sprite?

This topic is 4007 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello people of GameDev.net I am trying to understand the basics of directx, and starting a gameengine or something.. now i got one little problem My sprites are blurred.. like this messagebox: Original sprite: in directx: Does anyone know a solution for this problem? btw, im using c#.net 2005 with DirectX SDK June 2007 If you need to know more information, just ask. :-) Kind regards, djnevs

Share this post


Link to post
Share on other sites
Advertisement
thought so..
that what i found on the net, doesnt realy work for me..
maybe there is some other solution?

i got this code:
device.SamplerState[0].MipFilter = TextureFilter.None;
device.SamplerState[0].MinFilter = TextureFilter.None;
device.SamplerState[0].MagFilter = TextureFilter.None;
device.SamplerState[0].MaxAnisotropy = int.MaxValue;
device.SamplerState[0].MipMapLevelOfDetailBias = 0;
device.SamplerState[0].SrgbTexture = true;


I placed this in the InitializeDevice section..
if i change the TextureFilter to Anisotropic or something, doesnt work eighter

Share this post


Link to post
Share on other sites
what technique are you using to draw the textures to the screen? ID3DXSprite? something else?

Share this post


Link to post
Share on other sites
It's hard to tell with that paricular sprite. Things to try:
  • Make sure your window client area is the size you think it is. I'm not sure about C#, but with C++ you specify a window size, not client area size. So if you create a window that's 800x600, your client area might be 782x594, which means if your backbuffer is 800x600, it'll be blurred when it's shrunk to the window size.
  • If your texture is close to a power of 2 in size (E.g. 250x120), it's possible that the texture is being loaded as a power of two (256x128), and getting blurred as a result.
  • As Dancin_Fool suggested, what texture filtering mode are you using?
  • If you're using transformed vertices, are you offsetting your vertices by half a pixel? (See Here for an explanation, skip to "Summary" at the bottom if you're in a hurry).

    Overall, we'll need to see some code to help you some more. It might also be worthwhile trying a more "simple" texture and see if you get a more distinctive pattern. Try a texture that alternates black and white texels in a checkerboard pattern. Stretching should be obvious then.

    Share this post


    Link to post
    Share on other sites
    this is my addsprite class:

    using System;
    using System.Collections.Generic;
    using System.Text;
    using Microsoft.DirectX;
    using Microsoft.DirectX.Direct3D;

    public class cSprite
    {
    private Sprite spr;
    private Texture sprTexture;

    public void Create(Device device, string file)
    {
    sprTexture = TextureLoader.FromFile(device, file);
    spr = new Sprite(device);

    }


    public void OnPaint(int x, int y, int width, int height)
    {
    spr.Begin(SpriteFlags.AlphaBlend);
    spr.Draw2D( sprTexture,
    System.Drawing.Rectangle.Empty,
    new System.Drawing.SizeF(width,height),
    new System.Drawing.PointF(x,y),
    System.Drawing.Color.White.ToArgb()
    );
    spr.End();
    }

    public void OnReset() { }

    public void Dispose()
    {
    spr.Flush();
    }
    }



    edit: changing backbuffer results same...

    Share this post


    Link to post
    Share on other sites
    Quote:
    Original post by djnevs
    look

    or isnt this what you mean?
    I meant having each alternate pixel of the texture a different colour, rather than a block of pixels the same colour. Where the first scanline of your texture might be:
    ########################........................
    I meant:
    #.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.

    But your texture helps a bit too, it shows that there seems to be either a filtering or wrapping issue. As for exactly what it is, I'm not sure I'm afraid.

    Share this post


    Link to post
    Share on other sites
    You're on the right lines with your sampler state settings, but you need to set them after your spr.Begin(...) call.

    Share this post


    Link to post
    Share on other sites
    Sign in to follow this  

    • Advertisement
    ×

    Important Information

    By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

    We are the game development community.

    Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

    Sign me up!