Article View: comp.sys.amiga.tech
Article #13298Re: Double-Buffering in a window
From: J I L Gold
Date: Wed, 03 Jan 1990 10:57
Date: Wed, 03 Jan 1990 10:57
97 lines
3388 bytes
3388 bytes
OK, after the rather vague reply yesterday, here's some source to help
you on your way: this works in a non-Intuition environment. This will
illustrate the principle. (BTW, blitting the regions as suggested by
the others works but can lead to flicker).
#include <exec/types.h>
<graphics/gfx.h>
<graphics/rastport.h>
<graphics/copper.h>
<graphics/regions.h>
<graphics/clip.h>
<graphics/gfxbase.h>
struct View View;
struct ViewPort ViewPort;
struct RasInfo RasInfos[2];
struct BitMap BitMaps[2];
struct RastPort RastPorts[2];
struct View *OldView;
struct cprlist *LOF[2],*SHF[2] /* to store copper list
addresses */
struct GfxBase *GfxBase;
.
.
main() {
/* initialisation (opening relevant libraries) */
.
.
OldView = GfxBase->ActiView; /* Save the current screen */
ViewPort.D(x y)Offset = top left corner of viewport;
ViewPort.D(Width Height) = size of viewport;
ViewPort.RasInfo = &RasInfos[0];
ViewPort.Modes = whatever;
ViewPort.Next = NULL; /* Only one viewport! */
RasInfos[0].Next = &RasInfos[1];
/*Allocate the bitmap memory here for both bitmaps */
.
.
/* Now the tricky bit..compute the copper lists for the
viewport... */
MakeVPort(&View,&ViewPort);
/* ...merge with the system copper list... */
MrgCop(&View);
/* ...and save. */
LOF[0] = View.LOFCprList;
SHF[0] = View.SHFCprList;
/* Now set the viewport up to use the second bitmap/rastport
etc... */
ViewPort.RasInfo = &RasInfos[1];
/* ...and do the same for this bitmap... */
/* EXCEPT set the copper list pointers in the View
structure to NULL otherwise Ami assumes that the
copper list has already been defined and will not make
a second one...*/
View.LOFCprList = View.SHFCprList = NULL;
MakeVPort(&View,&ViewPort);
MrgCop(&View);
LOF[1] = View.LOFCprList;
SHF[1] = View.SHFCprList;
/* OK, all set up. To do the buffering, the code will look
like this... */
dbuff = 0;
while (some condition) {
/* Clear the hidden screen ... */
SetRast(&RastPorts[dbuff],0);
/* Now draw into it... */
Move(&RastPorts[dbuff],x1,y1);
Draw(&RastPorts[dbuff],x2,y2);
/* Now flip the screens by swapping copper lists... */
View.LOFCprList = LOF[dbuff];
View.SHFCprList = SHF[dbuff];
LoadView(&View);
WaitTOF(); /* Optional but preferable! */
dbuff ^= 1; /* Next screen */
}
LoadView(OldView);
/* Free up copper list memory... */
FreeVPortCopLists(&ViewPort);
for(i=0 ; i < 2 ; i++){
FreeCprList(LOF[i]);
FreeCprList(SHF[i]);
}
/* Free bitmap memory and tidy up here */
.
.
CloseLibrary(GfxBase);
}
You should be able to do this with Intuition by accesing the relevant
structures through the window structure. Hope this is of help (bloody
better be after all this typing!)
Happy New Year :-)
J.Gold
mapjilg@uk.ac.bath.gdr
Technical Details
Message-ID:
<1990Jan3.105701.11465@gdt.bath.ac.uk>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!mcsun!ukc!dcl-cs!gdt!gdr!mapjilgReferences:
<39491@ames.arc.nasa.gov> <5861@sdcc6.ucsd.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!mcsun!ukc!dcl-cs!gdt!gdr!mapjilg From: mapjilg@gdr.bath.ac.uk (J I L Gold) Newsgroups: comp.sys.amiga.tech Subject: Re: Double-Buffering in a window Message-ID: <1990Jan3.105701.11465@gdt.bath.ac.uk> Date: 3 Jan 90 10:57:01 GMT References: <39491@ames.arc.nasa.gov> <5861@sdcc6.ucsd.edu> Reply-To: mapjilg@gdr.bath.ac.uk (J I L Gold) Organization: University of Bath, England Lines: 97