d3d9 render animated cursor is slow

Started by
6 comments, last by Evil Steve 10 years, 11 months ago

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.
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 ?

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

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

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.

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

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

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 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

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.

This topic is closed to new replies.

Advertisement