cvs.gedasymbols.org/archives/browse.cgi   search  
Mail Archives: djgpp/1997/03/19/01:39:52

From: Shawn Hargreaves <Shawn AT talula DOT demon DOT co DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: allegro - sprites and smudge on screen
Date: Tue, 18 Mar 1997 20:34:46 +0000
Organization: None
Distribution: world
Message-ID: <qR$ZTcAmxvLzEw5v@talula.demon.co.uk>
References: <199703181247 DOT NAA10767 AT gilberto DOT physik DOT rwth-aachen DOT de>
NNTP-Posting-Host: talula.demon.co.uk
MIME-Version: 1.0
Lines: 46
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Christoph Kukulies writes:
>While I'm moving a round the sprite smudge gets spattered over
>the screen (pieces of the sprite, pixels are set where they not
>should be etc etc.).
>
>When I'm doing a show_mouse(NULL) before I'm doing the drawing the
>smudge disappears but this is leading to intolerable flickering
>of the sprite.

Drawing to the screen while the mouse pointer is being displayed is a
bad thing for two reasons:

- In order to restore what was under the mouse when it next moves, 
  Allegro stores a copy of what lies underneath it on the screen. If you 
  draw something else over the top of the cursor, this buffer will 
  become invalid. If you then move the mouse, the old, incorrect image 
  will get restored where it used to be, so it will leave some 'mouse 
  droppings' behind...

- The mouse pointer is drawn inside a timer interrupt, which means that 
  it may get drawn while the main program is in the middle of some other 
  drawing operation. This wreaks havoc with the SVGA bank switching 
  mechanism, as the mouse drawing code will change bank, and then return 
  from the interrupt to the other drawing function which fails to 
  realise that it now needs to switch back to whatever bank it was 
  previously using. This can result in pixels being written to 
  completely the wrong part of the screen, but is only a problem in 
  banked SVGA modes.

The best way to make this work is to integrate the pointer display with
however the rest of your drawing code works: if you are using double-
buffering or some such algorithm, draw the cursor onto the double buffer
so that it gets updated in sync with all the rest of your graphics.

If you need to draw everything straight to the screen, you can do a
check before you draw whatever you are drawing to see if it overlaps
with the current mouse position, and only bother to hide the mouse if
they do overlap. To prevent the mouse from moving while you do this test
and in the middle of your drawing code, set the "freeze_mouse_flag" (new
in Allegro 2.2), to prevent any movement taking place during the
critical bits of code...


--
Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/
Beauty is a French phonetic corruption of a short cloth neck ornament.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019