Jump to content

  • Log In with Google      Sign In   
  • Create Account


d3d9 render animated cursor is slow


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
7 replies to this topic

#1 ChenA   Members   -  Reputation: 131

Like
0Likes
Like

Posted 16 May 2013 - 10:09 AM

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.


hehe.

Sponsor:

#2 VladR   Members   -  Reputation: 722

Like
0Likes
Like

Posted 16 May 2013 - 10:38 AM

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 ?


VladR    My 3rd person action RPG on GreenLight:    http://steamcommunity.com/sharedfiles/filedetails/?id=92951596

 


#3 belfegor   Crossbones+   -  Reputation: 2361

Like
0Likes
Like

Posted 16 May 2013 - 11:21 AM

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



#4 greenpig83   Members   -  Reputation: 323

Like
0Likes
Like

Posted 16 May 2013 - 11:30 AM

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, 16 May 2013 - 11:31 AM.


#5 VladR   Members   -  Reputation: 722

Like
0Likes
Like

Posted 16 May 2013 - 11:31 AM

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.


VladR    My 3rd person action RPG on GreenLight:    http://steamcommunity.com/sharedfiles/filedetails/?id=92951596

 


#6 ankhd   Members   -  Reputation: 1095

Like
0Likes
Like

Posted 16 May 2013 - 05:28 PM

Hi. You don't use a quad for your mouse it's to slow.

#7 Norman Barrows   Crossbones+   -  Reputation: 1845

Like
0Likes
Like

Posted 17 May 2013 - 12:22 AM

another approach (isn't here always another one with games?) is d3dxsprite and 2 (or more) textures for the animated part.


Norm Barrows

Rockland Software Productions

"Building PC games since 1988"

 

rocklandsoftware.net

 


#8 Evil Steve   Members   -  Reputation: 1955

Like
0Likes
Like

Posted 17 May 2013 - 05:11 AM

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.


Steve Macpherson
Senior programmer, Firebrand Games





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS