I know this has to be an easy one, but I simply can't find anything helpful in the forum or elsewhere. I'm overlooking something.
I just want to change the mouse cursor to a custom image -- say a 32x32 PNG or whatever. I see that tutorial 24 does this, but it's very confusing to me. I don't need an animated cursor and I don't need a "bank" of cursors. I think the "bank" is what is causing me the most grief... and the difference between a "sprite" and an "icon" and a "cursor" and a "cursor sprite" is a little confusing.
I only want to change the primary arrow cursor. Is there a simple way to do this?
Change Mouse Cursor
Re: Change Mouse Cursor
If you don't want to change the hw cursor, you can always go sw.
ie: hide the OS cursor, draw your own using draw2DImage.
ie: hide the OS cursor, draw your own using draw2DImage.
-
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
Re: Change Mouse Cursor
Example 6 has an example of how to render sw cursors, just as hendu suggests.
Re: Change Mouse Cursor
Ok, but suppose I do want to change the HW cursor? I'm just looking to write simple function, e.g.:
I will also look into the SW cursor example, though, thanks.
Code: Select all
void change_mouse_cursor(const string &image_filename, irr::core::vector2di hotspot)
{
// ... load the image into a sprite (or something?)
// ... set the hotspot and whatever else
// ... replace the main arrow cursor
}
Re: Change Mouse Cursor
Any idea why my SW approach doesn't work? I took this from tutorial 6.
I have verified that "tex" is not null, which I guess means that the texture loaded properly. There is no error message, but nothing is drawn. I also verified that nothing is overlapping (in front of) the cursor, etc...
I also tried draw2DRectangle() and it doesn't draw anything, either.
Code: Select all
irr::video::ITexture* tex = driver->getTexture("E:\\Projects\\shmup-1\\test_cursor.png");
driver->draw2DImage(tex, device->getCursorControl()->getPosition());
I also tried draw2DRectangle() and it doesn't draw anything, either.
Re: Change Mouse Cursor
When are you rendering? Maybe paste a short test program
Re: Change Mouse Cursor
Yep, that was exactly the problem. I was doing it outside the begin/end scene calls.Seven wrote:When are you rendering?
Thanks for the help.
Re: Change Mouse Cursor
You don't get around creating a spritebank. But you can use the AddIconToSpriteBank function from the example if you want a non-animated cursor. It takes the name of your texture and the rectangle inside that texture where your cursor is. And ICursorControl::changeIcon can then be used to set the cursor you want to change to that new icon.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm