[SOLVED] app.setOverrideCursor() takes too much cpu
Hiho, everybody again :)
I'm programming a strategy game with the Irrlicht 3D Engine, and use QT for the interface.
For showing the player if he would select a unit by left click, the cursor changes as soon as it is over a unit.
It works very well if I just move the cursor over one unit.
But if I have a bunch of units in a row and move the camera eg. from the left to the right and pass all these units, the camera movement slows down a little bit because the cursor has to change very often.
I declared the cursors as follows:
@QCursor * blue = new QCursor((new QPixmap("../media/interface/cursor_blue.gif")));
QCursor * green = new QCursor((new QPixmap("../media/interface/cursor_green.gif")));
QCursor * yellow = new QCursor(*(new QPixmap("../media/interface/cursor_yellow.gif")));@
and change it with:
or yellow or green.
As I can see its only a pointer and the images should already have been loaded so why does the game slows down?
Is there a better way to acchieve what I want?
Thanks in advance and best regards
I'm no specialist, but wouldn't it be simpler to also manage your cursor with Irrlicht ?
the problem is that I can manage the cursor with Irrlicht only in the Irrlichtwidget. As soon as I move the mouse out of the widget (over the interface), the cursor changes to its normal design. But maybe I could try to manage the cursor with Irrlicht as you said and tell QT to set the cursor to the same image as Irrlicht does, maybe this could work :)
I'll post as soon as I have time to try it.
Thanks for your help and have a nice day.
I would suggest not using pointers that way. Use QPixmap(...) instead of *(new QPixmap(...)). I don't know why is it slowing do we. Are you sure it isn't your game code?
Well I dont think its the game code, because if I move the camera without moving the mouse over the units (or remove the setOverrideCursor function) the game doesn't slow down.
And yes I got the *(new QPixmap(…)) part from the net and pasted it without really thinking about it.
But It doesn't matter, I got it :)
I set the cursor with qt to an image once at gamestart. And change it ingame with irrlicht if I move it over a unit. And if I move the cursor over the interface it doesn't change because I tell qt to use the same image as Irrlicht
Thanks for your help and good night ;)