• Advertisement
Sign in to follow this  

Sprites edges blend

This topic is 2413 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

SOLVED:
I solved this by changing samplerstate like this.
d3ddev->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_NONE);
d3ddev->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_NONE);
Also I had to make my image size a power of 2. Now it looks like a sprite is supposed to look!


Ok my problem is with drawing sprites. It works just fine with my code below... However the sprites are a little bit fuzzy and when you take a printscreen and zoom in on the image you can see that the edges of the sprite blend with the background image, which causes the fuzzy look. I dont want this and do not know what is causing it.



void initD3D(HWND hWnd)
{
...
// setup texture
if (! D3DXCreateTextureFromFile(d3ddev,"man.png", &gTexture) == D3D_OK)
MessageBox (hWnd,"error loading texture.",NULL, MB_OK);

// setup sprite
if (! D3DXCreateSprite(d3ddev, &sprite) == S_OK)
MessageBox (hWnd,"error creating sprite.",NULL, MB_OK);

}


And here is my code to draw the image to the top left of the screen. I call this function in between BeginScene() and EndScene().


void DrawSprite ()
{

sprite->Begin(D3DXSPRITE_ALPHABLEND);
sprite->Draw(gTexture,NULL,NULL,NULL,0xFFFFFFFF);
sprite->End();
}

Share this post


Link to post
Share on other sites
Advertisement

I don't use DirectX, but what you are describing is sometimes called 'anti-aliasing'.
Maybe this solves your problem?


link does not work, but yes it seems like anti-aliasing.

Share this post


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

  • Advertisement