[comp.sys.amiga] Double Buffered Display

pawn@wpi.wpi.edu (Kevin Goroway) (02/21/89)

I hope someone can help me with this, because it is driving me crazy.
I'm trying to set up a double buffered display. It works fine, except for
one major point.  My second (first) BitMap just isn't there...

InitBitMap(&b[0],DEPTH,WIDTH,HEIGHT);   ;this sets up my two bitmaps
InitBitMap(&b[1],DEPTH,WIDTH,HEIGHT);

ri.BitMap=&b[0];		        ;this links the first into
					;my RasInfo...
vp.RasInfo=&ri;				;this links my RasInfo to my VPort

for(temp=0;temp<2;temp++)	        ;this allocates and clears
{					;my two bitmaps
 for(i=0;i<DEPTH;i++)
 {
	b[temp].Planes[i]=(PLANEPTR)AllocRaster(WIDTH,HEIGHT);
	if(b[temp].Planes[i]==NULL) exit(NOT_ENOUGH_MEMORY);
 }

 for(i=0;i<DEPTH;i++)
 {
	displaymem=(UBYTE *)b[temp].Planes[i];
	BltClear(displaymem,RASSIZE(WIDTH,HEIGHT),0);
 }
}

InitRastPort(&rp);			;this sets up my Rastport
rp.BitMap=&b[0];			;and points to my first Bitmap

ri.BitMap=&b[0];			;this was done already
MakeVPort(&v,&vp);			;begin setting up Double Buffer
MrgCop(&v);
LOF[0]=v.LOFCprList;
SHF[0]=v.SHFCprList;

ri.BitMap=&b[1];			;other bitmap
v.LOFCprList=NULL;
v.SHFCprList=NULL;

MakeVPort(&v,&vp);
MrgCop(&v);
LOF[1]=v.LOFCprList;			;ok, all done...but it doesn't work
SHF[1]=v.SHFCprList;

In a loop I say rp.Bitmap=&b[trigger], to alternate my bitmaps, but if
I set it to &b[0], to force drawing into bp[0], it doesn't display
squat, whereas &b[1] works fine...

I have tried many variations, such as setting up 2 RasInfos, setting up
two RastPorts, etc., but they all yield the same thing.  No bitmap.

I am sure that my LoadView(&v) works fine. (after I swap the LOF and SHF)
So I'm stuck. any ideas?
thanks!

-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
| Pawn@wpi.wpi.edu 		Worcester Polytechnic Institute, Mass, U.S.A. |
| Pawn@wpi.Bitnet		main() { printf("Hello World!\n); }           |
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

ewhac@well.UUCP (Leo 'Bols Ewhac' Schwab) (02/22/89)

[ Much convoluted code and consternation by Kevin deleted. ]

	Yuck.  The approach documented in the RKM is icky, and hard to work
with.  I like this approach much better:
--------
	InitBitMap (&bm1, deep, wide, high);
	InitBitMap (&bm2, deep, wide, high);
	InitVPort (&vp1);
	InitVPort (&vp2);
	InitView (&v1);
	InitView (&v2);

	v1.ViewPort = &vp1;
	v2.ViewPort = &vp2;

	rasinfo1.BitMap = &bm1;
	rasinfo2.BitMap = &bm2;
	rasinfo1.Next = rasinfo2.Next = NULL;

	vp1.RasInfo = &rasinfo1;
	vp2.RasInfo = &rasinfo2;

	MakeVPort (&v1, &vp1);
	MakeVPort (&v2, &vp2);
	MrgCop (&v1);
	MrgCop (&v2);
--------

	At this point (.), you can LoadView() either v1 or v2, and it'll pop
onto your screen at the next VBLANK.  Much less pain and misery all around.

_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
Leo L. Schwab -- The Guy in The Cape	INET: well!ewhac@ucbvax.Berkeley.EDU
 \_ -_		Recumbent Bikes:	UUCP: pacbell > !{well,unicom}!ewhac
O----^o	      The Only Way To Fly.	      hplabs / (pronounced "AE-wack")
"Work FOR?  I don't work FOR anybody!  I'm just having fun."  -- The Doctor