Jump to content
  • Advertisement
Sign in to follow this  
ChenA

d3d9 render animated cursor is slow

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

i use d3d9 to draw a animated cursor.

 

first i load the animated cursor frome a texture, and i create two 32*32 offscreen plain surface suf1_, suf2_.

 

every frame, i update the cursor rect in the texture, then

 

    D3DXLoadSurfaceFromSurface(suf1_, 0, 0,  textureSurface, 0, rect, D3DX_DEFAULT, 0);
    device->SetCursorProperties(0, 0, suf2_);

    std::swap(suf1_, suf2_);

 

but it's too slow.

 

so how to make it fast? any suggestion will be appreciated, thanks.

Share this post


Link to post
Share on other sites
Advertisement

D3DXLoadSurfaceFromSurface was certainly not meant to be used like that.

 

Why don't you just (Lock,Update,Unlock) the surface of the texture for the cursor and use that same surface for cursor properties ?

Share this post


Link to post
Share on other sites

I prefer use HW cursor in Directx instead of draw by yourself.

There is tons of .cur file and .ani file on the web. Using it so smooth. I have no problem with the graphics of cur file!

And I think you can create your own .ani file from your sprite. Maybe with less color I think.

Edited by greenpig83

Share this post


Link to post
Share on other sites

I would hide HW cursor and draw my own while updating only texcoords in shader.

He may have a valid reason for a HW cursor, but normally, in a game, you do draw just a transparent quad with animated UVs.

Share this post


Link to post
Share on other sites

D3DXLoadSurfaceFromSurface() is not something you want to be calling every frame. You should load your cursor frames at startup, and then just call SetCursorProperties() once per frame.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!