Hi all,
This might sound a bit stupid, but I've been able to most things when programming the Amiga, but flood fill isn't one of them. I have always been missing something but cannot work out what it is. Now, I really need to do it for a project I am working on and it still doesn't work.
I've knocked up a quick example to see if I could get it working but even the small example doesn't work. It's meant to draw a circle and fill it. Should be easy, right? The circle draws fine, but no fill happens. Can anyone see what I am doing wrong?
Example code below, compiled with SAS/C 6.x and run/tested on AmigaOS 4.1.4:
/* Attempt to test flood fill */
#include <exec/types.h>
#include <graphics/gfx.h>
#include <graphics/gfxmacros.h>
#include <intuition/intuition.h>
#include <proto/exec.h>
#include <proto/dos.h>
#include <proto/graphics.h>
#include <proto/intuition.h>
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
struct Window *win;
win = OpenWindowTags(NULL,
WA_InnerWidth, 200,
WA_InnerHeight, 200,
WA_IDCMP, IDCMP_CLOSEWINDOW,
WA_Title, "test flood",
WA_DragBar, TRUE,
WA_CloseGadget, TRUE,
WA_NoCareRefresh, TRUE,
WA_SmartRefresh, TRUE,
TAG_DONE);
if(win)
{
WORD centreX, centreY;
struct TmpRas tr;
LONG size;
UBYTE *buf;
centreX = (win->Width + win->BorderLeft - win->BorderRight) / 2;
centreY = (win->Height + win->BorderTop - win->BorderBottom) / 2;
SetOutlinePen(win->RPort, 1);
SetAPen(win->RPort, 1);
SetDrPt(win->RPort, 0xFF);
DrawCircle(win->RPort, centreX, centreY, 25);
size = (200 * 200) / 8;
buf = AllocVec(size, MEMF_CHIP);
if(buf)
{
InitTmpRas(&tr, buf, size);
win->RPort->TmpRas = &tr;
Flood(win->RPort, 0, centreX, centreY);
win->RPort->TmpRas = NULL;
FreeVec(buf);
}
Wait(1 << win->UserPort->mp_SigBit);
CloseWindow(win);
}
return 0;
}