www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/07/22/05:35:58

Message-ID: <007201bdb553$e16be6e0$624d08c3@arthur>
Reply-To: "Arthur" <arfa AT clara DOT net>
From: "Arthur" <arfa AT clara DOT net>
To: "DJGPP Mailing List" <djgpp AT delorie DOT com>
Subject: Re: Allegro and blitting to screen
Date: Wed, 22 Jul 1998 10:29:58 +0100
MIME-Version: 1.0

>>HELP !!??
>>I'm programming a very nice game with DJGPP and allegro. I use SVGA
>>640*480*256 colors, so graphic looks good. But the problem is the
>>double buffering. It's just too slow. Example :
>>
>>  BITMAP *buffer = create_bitmap(640, 480);
>>
>>  clear(buffer);
>>  while( game_continues) {
>>    // some drawwing on the buffer
>>    blit(buffer, screen, 0, 0, 0, 0, 640, 480);
>>  }
>>
>>That is a the only way I can think of, but itsn't fast enough.
>>So is there any faster way to do that 'blit(buffer, screen, ...)' ???
>>
>>Tuomo Turunen
>
>I tried Allegro demo to find out what's faster: page flipping of double
buffer.
>I was almost sure that the firtst technique is ~1/4 faster. Well, ...:
>640x480x8       DB - 106fps, PF - 59fps
>800x600x8       DB - 66fps, PF - 60fps
>1024x768x8      DB - 39fps, PF - 60fps
>Why PF fps is always the same? I tried removing vsync_in() from
>vesa_scroll(int, int) (djgpp/vesa.c) but with no effect...


AFAIK, most graphics cards require a vsync() before page flipping anyway. I
can't remember if Allegro puts one in, or if the drivers put one in
themselves.

>Double Buffer is better than Page Flipping if:
>  -RAM is twice as fast as video memory & rendering a frame requires
clearing
>   the screen (buffer) each time
>
>time
|--------------------------------------------------------------------->
>DB    |clear_the_buffer|-draw_everything-|-----blit_buffer_to_screen-----|
>PF    |---------clear_the_screen---------|---draw_everything_on_screen---|
>
>   So, IF draw_everything is faster than clear_the_buffer, THEN I suggest
>   you should use double buffer, ELSE (if draw_everything is slower than
>   clear_the_buffer) you should use page flipping.
>
>  -IF rendering a frame doesn't require clearing the screen, you should use
>   page flipping, but if draw_everything_on_screen is slower than
>   draw_everything + blit_buffer_to_screen you should use double buffer
>   of course.


Note that although your frame rate is not necessarily linked to your monitor
frequency, the number of screen updates per second is. The Allegro demo is a
bit jerky when page flipping (esp. when other applications are open). To get
around this, your screen updates need to be centred around the vsync(), and
not around a timer (like in the Allegro demo). Page flipping is, when used
correctly, very smooth.


OK, Atari rant follows:

On my Atari STe, there was a wonderful little chip called the BLITTER. This
would do stuff like clear screens, blit bits of screen memory around, do
transformations, and generally give a speed boost to graphics. What was the
beauty of it? You could tell it to do something, set it off, and it would do
it by itself in parallel to the CPU. This allowed you to double or triple
buffer in system RAM, while not having to wait while the screen redraws. I
say very cool.

Why, eight years on, is there no VESA funtions to do similar? Why can you
not say "wait for a vsync and draw the screen, while I tidy up before
looping"?

Atari rant ends



James Arthur
jaa AT arfa DOT clara DOT net

- Raw text -


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