Re: Mouse routines

Search this archive.

From: Sergio Masci (sergio@titan.demon.co.uk)
Date: Sat 15 Apr 2000 - 19:20:34 IDT


> 
> in my current application I am trying to display a
> mouse pointer.  Now I have tried doing copying the
> setion of the screen where I am about to display mouse
> then I display the mouse.  I have tried to ways to
> draw the mouse, one is to do a gl_putboxmask(), and
> second I have tried literally doing a series of
> gl_hline() and gl_setpixel().  Both of these methods
> cause the mouse to be very jumpy, I don't get a smooth
> flow of the mouse across the screen.  I have tried to
> play with the sample rate to see if this helps but it
> doesn't seem to help.  So does anyone know of some
> faster ways of drawing the mouse or other ways to help
> smooth out the mouse flow.
> 
> Daniel Smith

If the mouse flickers badly then you have problems with drawing and
erasing the mouse pointer. If the mouse is jerky (does not seem to move
smoothly) then you are not servicing the mouse frequently enough. This
could be because you are doing a lot of work (computational or maybe
disc IO) between servicing the mouse or your 'waiting' functions are not
working correctly. A way to get around this would be to have the mouse
serviced by a routine that is repeatedly triggered by a timmer at
regular intervals (maybe 20 times a second), or to have the mouse
generate interrupts which you catch and process yourself. You would then
need to design your own API to the async service routines (which are now
effectivly running in the background) to tell them when to stop
redrawing and erasing the mouse (so that you can safely draw to the
screen yourself) and what the mouse pointer should look like.

Another way to do it might be to have another thread that blocks while
waiting for mouse events but I'm not sure how well that would work if
your program were to start doing a lot of work (the scheduling of the
user space threads may not happen as often or quickly after an event as
you may like).

You could also consider identifying high load routines, breaking them
up into smaller sections and inserting entra calls to your mouse
servicing routines there.

Regards
Sergio


This archive was generated by hypermail 2.1.4 : Wed 21 Jan 2004 - 22:10:23 IST