Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » vsynv() and mouse?

Credits go to Kitty Cat for helping out!
This thread is locked; no one can reply to it. rss feed Print
vsynv() and mouse?
Christopher Bludau
Member #5,401
January 2005

I have a problem with my mouse cursor again.

I have this peace of code:

  if (do_vsync == 1) vsync();
  scare_mouse();
  blit(temp, screen, 0,0,0,0,800,600);
  unscare_mouse();

If do_vsync is != 1 and no vsync() is done then it works fine.

But if do_vsync = 1 then the mouse cursor will flicker at the TOP of the screen (don't know. Maybe 20 pixels of the top screen).

This happens only at the top of the screen and when vsync is enabled.

I searched for this problem and found out that spellcaster mentioned this problem in 2003 in this thread http://www.allegro.cc/forums/thread/240147#post_240147.

The quistion was not solved in this thread.

Is there no way to use allegros mouse functions when using vsync since allegro version 4.0.3 (beta1)??

So the mouse functions are useless if used together with vsync?
Or is there a solution to this problem I didn't found?

ReyBrujo
Moderator
January 2001
avatar

Actually, you should blit your mouse into the temp bitmap, like:

if (do_vsync == 1)
    vsync();
show_mouse(temp);
blit(temp, screen, 0,0,0,0,800,600);

I have only used the scare functions inside dialogs.

--
RB
光子「あたしただ…奪う側に回ろうと思っただけよ」
Mitsuko's last words, Battle Royale

Christopher Bludau
Member #5,401
January 2005

Hmm.. In a discussion in another thread we came to the point, that blitting the mouse somewere else then the screen is not a good idea.

read it here:
http://www.allegro.cc/forums/thread/555441#target

So I don't want to do that. If I HAVE TO blit the mousepointer to my buffer, then indeed the mouse functions of allegro where kind of pointless.

No other solution?

Kitty Cat
Member #2,815
October 2002
avatar

Use a hardware/OS cursor. After setting it, you can check if it was actually enabled and just double buffer the pointer if not.

--
"Do not meddle in the affairs of cats, for they are subtle and will pee on your computer." -- Bruce Graham

Christopher Bludau
Member #5,401
January 2005

How do I use a hardware/os cursor?
Will this not be affected by the vsync problem?

Thanks!

Kitty Cat
Member #2,815
October 2002
avatar

It should "fix" the mouse problem, if the problem isn't that the mouse_x/y values get foobar'd.

// At startup:
enable_hardware_cursor();
show_mouse(screen);
// Make sure a hardware cursor is set. if not, double
// buffer the mouse
if(!(gfx_capabilities&GFX_HW_MOUSE))
   show_mouse(NULL);

// In display loop, before blitting to screen:
if(!(gfx_capabilities&GFX_HW_MOUSE))
  draw_sprite(buffer, mouse_sprite, mouse_x, mouse_y);

--
"Do not meddle in the affairs of cats, for they are subtle and will pee on your computer." -- Bruce Graham

Christopher Bludau
Member #5,401
January 2005

Thank you very much! It did work.

But I had to change GFX_HW_MOUSE to GFX_HW_CURSOR.
Is this right? GFX_HW_MOUSE was unknown to the compiler.

Kitty Cat
Member #2,815
October 2002
avatar

Yeah, sorry. I mistyped it even after looking at the docs. ::)

--
"Do not meddle in the affairs of cats, for they are subtle and will pee on your computer." -- Bruce Graham

Christopher Bludau
Member #5,401
January 2005

No problem.
There should be at least a little work for me even if someone else is doing the real job ;)

Go to: