Jump to content
  • Advertisement
Sign in to follow this  
Camionsauro

Strange issue with DX and sprite

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

Hi to all and sorry for my english... In these I'm trying to learn Directx after some time of sdl programming. I start with a simple project, just a sprite moving on screen. Here's the code: http://rapidshare.com/files/298835624/2D_Platform_game.rar.html The main question is: if I move the sprite with a step of 1.0f or better on its x position the movement is smooth, but if I step down at 0.1f (in the example the step is deltat, where deltat is the time of a single frame, 0.001 secs. This is for example, a way to see the problem) the animation flicker. In the above project it's easy to see that every step the sprite change its look, I cannot explain better (damn, my horrible english): sometime seems that a color channel (bmp, 32 bit+alpha) is shifted. A good way to see this problem is kept pressed the 'A' key. Any suggestion? Thanks in advance!

Share this post


Link to post
Share on other sites
Advertisement
I can't download your example because I'm using linux at work, but could it be the effect of anti-aliasing? If you are moving sprites by very small amounts then the position of a sprite pixel relative to a screen pixel will vary by a fraction of a pixel. Direct3D/your graphics card will compensate for this by calculating a weighted average of the nearest pixels.

Share this post


Link to post
Share on other sites
Thanks for the answer! After reading tons of documentation I discovered that I haven't enabled the Alphablend. Infact with this it work fine. But there is another problem: with a low D3DRS_ALPHAREF (10 in example) in the left border of the sprite appear some alpha information of the previous frame (is a 4x4 frame texture). So I increase the alpha ref but the flickering is too high. And here it comes your solution: the antialiasing!!!! I've disable it with
gd3dDev->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
gd3dDev->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
gd3dDev->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_POINT);

(found it on an example posted in this forum).

I don't know if this is the final solution but it works! :)

Thanks! :)

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!