How do you dissable anti-aliasing when using ID3DXSprite?

Started by
2 comments, last by load_bitmap_file 18 years, 10 months ago
I dont want my sprites blurred like this, how do I turn this off? Also, the bitmap gets stretched, how do i turn this stretching off? I would be very thankfull for an answer to this, 'cause I cant figure it out. Mikael Sweden
Advertisement
When you load the texture with D3DXCreateTextureFromFileEx(), you can specify the filtering to be used. If you specify D3DX_FILTER_NONE, then no dithering/stretching will occur.

Also, you should ensure that your texture files have dimensions that are powers of 2. If you don't, then DirectX will stretch them to the next power of 2 upon loading.
I am assuming that you are using DirectX9.
Ok to fix the Antialias problem with DirectX9 one of the first thing you
must do is when you Load you Bitmaps or any other format for that matter using
the D3DXCreateTextureFromFileEx make sure that the parameters that determined the image filter be set to D3DX_FILTER_NONE or D3DTEXF_POINT, then after you call the begin state of the sprite make sure you change the Sampler State of the Texture Index to D3DTEXF_POINT as well. Because after you call the Begin Method of the Sprite D3D does some Internal Changes to the renderstates and Sampler States so that is why you must change the state after you call the Begin Method. i hope that helps you.

By the way D3DX_FILTER_NONE will make sure that if the Image you specify is not power of two it will make it power of it without streching the image. What it does is make it power of two and add black to the part that is not part of the texture.
In addition to what Drexl said, make sure you also set the sampler state as BornToCode said. If I remember correctly, the code would look like this:

m_d3dDevice->SetSamplerState(0, D3DSAMP_MINFILTER,D3DTEXF_POINT); m_d3dDevice->SetSamplerState(0, D3DSAMP_MAGFILTER,D3DTEXF_POINT);m_d3dDevice->SetSamplerState(0, D3DSAMP_MIPFILTER,D3DTEXF_POINT);


EDIT: As the others said, if your bitmap isn't a power of 2 then it'll get stretched, blurred, and distorted. Thus if you make your bitmap dimensions a power of 2, then it should look fine, and you don't have to disable the AA. If you're planning to rotate your sprites then I highly recommend leaving AA on, without it the sprites look really bad.

This topic is closed to new replies.

Advertisement