@Minniat, post #3
The following fragment shows proper double buffering synchronization:
int SafeToChange=TRUE, SafeToWrite=TRUE, CurBuffer=1;
struct MsgPort *ports[2]; /* reply ports for DispMessage and SafeMessage
*/
struct BitMap *BmPtrs[2];
struct DBufInfo *myDBI;
... allocate bitmap pointers, DBufInfo, set up viewports, etc.
myDBI->dbi_SafeMessage.mn_ReplyPort=ports[0];
myDBI->dbi_DispMessage.mn_ReplyPort=ports[1];
while (! done)
{
if (! SafeToWrite)
while(! GetMsg(ports[0])) Wait(1l<<(ports[0]->mp_SigBit));
SafeToWrite=TRUE;
... render to bitmap # CurBuffer.
if (! SafeToChange)
while(! GetMsg(ports[1])) Wait(1l<<(ports[1]->mp_SigBit));
SafeToChange=TRUE;
WaitBlit(); /* be sure rendering has finished */
ChangeVPBitMap(vp,BmPtrs[CurBuffer],myDBI);
SafeToChange=FALSE;
SafeToWrite=FALSE;
CurBuffer ^=1; /* toggle current buffer */
}
if (! SafeToChange) /* cleanup pending messages */
while(! GetMsg(ports[1])) Wait(1l<<(ports[1]->mp_SigBit));
if (! SafeToWrite) /* cleanup */
while(! GetMsg(ports[0])) Wait(1l<<(ports[0]->mp_SigBit));@Minniat, post #4
@AmiChris, post #6