[futurebasic] Re: GWorlds

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : December 1997 : Group Archive : Group : All Groups

From: Rick Brown <rbrown@...>
Date: Mon, 29 Dec 1997 22:17:30 +0000
> I don't understand GWorlds. I looked through the handbook (couldn't even 
> find anything about them) and read the section in Frank Turovich's book, 
> Learning FutureBASIC II: The Toolbox and picked through Matt Beedle's 
> animations, but I still dn't understand GWorlds. Can somebody just give 
> me a basic introduction; I just need enough information to create a 
> simple animation.

A GWorld basically consists of:
1. A hunk of memory, which is used for storing the colors of
   individual pixels in a rectangular array;
2. A bunch of related data which tells things about the above
   hunk, such as: the number of colors you want to allow in
   your pixels, what color-table you want to use, etc.

The most common GWorld is the screen itself, in which the "hunk of
memory" consists of all of the memory that's mapped to video.  If you
want to manipulate pixels but you're not ready to show them yet, then
you create an "off-screen" GWorld (which uses memory that's not video
memory).  FN NEWGWORLD reserves the necessary memory for you, and
SETGWORLD lets you do graphics operations which affect your "invisible"
pixels in memory rather than the visible ones on screen.  When you're
ready to affect the _screen_ pixels again, you do another SETGWORLD.

COPYBITS is almost like a fancy BLOCKMOVE, that copies pixels from one
"pixel map" (i.e., the "hunk of memory") of one GWorld into the pixel
map of another.  It's more complex than a straight BLOCKMOVE, because it
also does things like adjust for different color resolutions, different
palettes, different rectangle dimensions, etc.  One reason it's popular
for animation is that it can copy any selected _part_ of your offscreen
GWorld onto a given rectangle on the screen--and it does it fast.  So
you might create a huge GWorld landscape (bigger than your screen
window) and make it seem to scroll, just by COPYBITS'ing different
sections of it to the window at different times.  By the same token, you
could create a little tiny GWorld (smaller than your screen window), and
COPYBITS its contents into different spots within your window.

GWorlds are not the only way to "draw invisibly."  There is also
"picture recording," which essentially you do with the PICTURE ON and
PICTURE OFF statements.  This does not involve any GWorlds or pixel
maps--essentially, it just records a list of drawing commands (without
actually doing the drawing).  You can then "play back" this list of
commands later--essentially doing all the drawing at high speed.  If the
commands you recorded happened to be animating something, then a simple
DRAWPICTURE statement will play back that whole animation (though you
can't control its speed).  Also, picture recording tends to use a lot
less memory than GWorlds (since it doesn't allocate a pixel map).

- Rick