[comp.sys.amiga.programmer] Double Buffering

chet@netcom.COM (Eric Chet) (05/30/91)

Hello

     I have a problem.  I have a intuition screen, with many gadgets on it.
The screen is 2 bit planes, 640x400 interlaced.  I have a rectangular 
region of the screen (14,12)-(490,385) that I need to do 30 frames per
second animation on.  My problem is double buffering that region.  I 
should be able to create, 2 alternative BitMaps(for that region) and 
2 copper instruction streams, One displaying the first alternative region, 
the other displaying the second alternative region.  Then it's just swaping
the copper instruction lists.

     What copper instructions, really what custom registers do I need to
write to, and what do I need to write to them to accomplish this?

Thank You in advance -- I hope there are some copper junkies out there.

Eric Chet -- Internet: chet@netcom.com
             BIX: chet
-- 
~
/**************************************************************************
 * Eric Chet       | Amiga does it better
 * chet@netcom.com | Ray Tracing and other graphics techniques 
 * BIX: chet       | "Use what is useful, simply to simplify"
 */

int131d@monu4.cc.monash.edu.au (mr s.d. twyford) (05/31/91)

In article <1991May30.072335.9941@netcom.COM> chet@netcom.COM (Eric Chet) writes:
>Hello
>
>     I have a problem.  I have a intuition screen, with many gadgets on it.
>The screen is 2 bit planes, 640x400 interlaced.  I have a rectangular 
>region of the screen (14,12)-(490,385) that I need to do 30 frames per
>second animation on.  My problem is double buffering that region.  I 
>should be able to create, 2 alternative BitMaps(for that region) and 
>2 copper instruction streams, One displaying the first alternative region, 
>the other displaying the second alternative region.  Then it's just swaping
>the copper instruction lists.
>
>     What copper instructions, really what custom registers do I need to
>write to, and what do I need to write to them to accomplish this?

	Before you decide to write to the copper registers, you need to 
consider a few facts. Firstly, Intuition uses the graphics library privitives
to generate copper lists for its sreens. Intuition has a its own View structure
in IntuitionBase, so if you use the graphics privitives to create your own
view structure, and call LoadView(), Intuition's view will disappear and
you will have taken over the display.
	Further more, the graphics library creates its own copper lists and
writes directly to the copper registers, so if you write to the copper
registers, you will take over the copper hardware from any program (such as
Intuition) that was using it through the graphics library. 
	To double buffer under Intuition, you need to open two screens,
one for each buffer, and then swap the screens by calling ScreenToFront(),
(I think, you may get a posting from me after I check that). This will mean
you will have to split your screen in two, the part you want double buffered
and the part you don't want double buffered. To do gadgets on a double buffered
screen you would have to get intuition to render the gadget window into both
screens (?). There is a problem with this method, it is very slow. This
is because whenever the screens are ordered, moved, etc. Intuition has to
create a new copper list for its view, this will occur every time you swap
your screens.
	It is much easier to double buffer using the graphics privitives,
just create two view structures and swap them with LoadView(), however this
will block out Intuition. In your case you could initialise three ViewPort
sturctures, (1) The ViewPort for the first buffer of the double buffered
screen, (2) The second buffer and (3) the ViewPort for the screen with the
gadgets. Then set up two View structures, one with ViewPort (1) and (2),
one with ViewPort (1) and (3). How you would trick Intuition into rendering
into you custom View and ViewPort structures, I don't know. You may have
to write your own gadget routines.
	The copper method is much the same as the Graphics Library method,
except has fewer advantages and more disadvantages.


>
>Thank You in advance -- I hope there are some copper junkies out there.

Your Welcome.

>
>Eric Chet -- Internet: chet@netcom.com
>             BIX: chet
>-- 
>~
>/**************************************************************************
> * Eric Chet       | Amiga does it better
> * chet@netcom.com | Ray Tracing and other graphics techniques 
> * BIX: chet       | "Use what is useful, simply to simplify"
> */

	Stuart Twyford.
	Internet: int131d@monu4.cc.monash.edu.au