Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » set_mouse_sprite()

This thread is locked; no one can reply to it. rss feed Print
set_mouse_sprite()
spellcaster
Member #1,493
September 2001
avatar

OK, I was playing around with molecule again, and wanted to update the way it's handling the mouse cursor. To play around with some ideas I wrote a small demo program.

1 set_mouse_sprite(pointer);
2 show_mouse(screen);
3
4 // ------------ Main ----------------------
5
6 while (!key[KEY_ESC]) {
7 // ------------ Display ----------------------
8 if (mouse_b) {
9 putpixel(doublebuffer, mouse_x, mouse_y, makecol(255,255,255));
10 }
11 vsync();
12 scare_mouse();
13 blit(doublebuffer, screen, 0, 0, 0, 0, doublebuffer->w, doublebuffer->h);
14 unscare_mouse();
15 }

The program runs in 640x480x16, the cursor sprite is 40x40 pixels.

Verything seemed to work nicely until I moved the cursor to the upper end of the screen.
There it disappears.

I guess the blit takes so long, that the ray is at around line 200 or so once the blit is finished. So, at the time the mouse is enabled again, we're past the position of the mosue cursor.

Ok, no problem I thought. I can simply remove the vsync(). The result was a very interresting effect which more or less resulted in around 3 lines of the cursor beeing visible per frame (and of course which lines are visible is changing as well all the time). So I get more or less "dancing line fragments" instead of a cursor image.

On the other hand I'm pretty sure that this should work... so I thought I could post here and get collect some ideas.

Of course, I could simply render my cursor to the doublebuffer by hand and then blit the doublebuffer... but then the set_mouse_sprite() function is pretty pointless ;)

Just for completeness, I'm running winXP on a p4 2.5gHz machine, 512MB Ram, Geforce40 Ti/128 gfx card.
I'm using Allegro 4.0.3 (beta1) (date:20021223) and the current gcc release. exmouse is not affected, since it simply displays the cursor, but doesn't update the screen.

Any ideas what might be causing this?
And if there's any solution but to render the mouse cursor in software onto the doublebuffer?

EDIT:
I just made the obvious change and used the default cursor: Same effect. So I doubt it's related to the size / content of the cursor itself.

--
There are no stupid questions, but there are a lot of inquisitive idiots.

23yrold3yrold
Member #1,134
March 2001
avatar

Can't you just blit the mouse sprite? Really doesn't solve the "bug", but it should be a nice quick fix (it's how I always do it) ...

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

spellcaster
Member #1,493
September 2001
avatar

Yep, as I said, I can blit it to the doublebuffer.
But this would make set_mouse_sprite() a really useless function :)

If I use show_mouse(doublebuffer) I get pretty much no visible cursor. My only chance is to draw_sprite() it manually.

This smells like an allegro bug, but I wanted to get a 2nd opionion here before I start yelling "Bug!" ;)

--
There are no stupid questions, but there are a lot of inquisitive idiots.

nonnus29
Member #2,606
August 2002
avatar

I use show_mouse(backbuffer) and it works fine for me. It should be flicker free since there is no delay in your loop. (EDIT; beside vsync.)

Plucky
Member #1,346
May 2001
avatar

I've successfully used show_mouse(screen), double buffering, scare/unscare_mouse(), scare_mouse_area(), and set_mouse_sprite() all in the same allegro project.

Allegro 4.1.5
Athlon
GeForce 2/GTS
MinGW 2.0

spellcaster
Member #1,493
September 2001
avatar

Good to hear. Can you be sure it'll run on my machine as well? Did you use show_mouse(screen) or did you show it on the backbuffer?

Is there anything wrong with the code above?

--
There are no stupid questions, but there are a lot of inquisitive idiots.

Go to: