[comp.sys.amiga.programmer] I can't get Flood

davids@ucscf.UCSC.EDU (Dave Schreiber) (05/11/91)

I'm having a problem figuring out how the Flood() function works.  I've
been able to get flood mode #0 (flood to the outline color) to work, but
it's incredibly slow (even on my 3000), and not really what I want anyway.
Mode #1 (flood the block of color at the given coordinates), on the other
hand, looks like it will fit the bill, but I haven't been able to get it to
work.  Here's a code sample that illustrates what I'm trying to do
(ignoring the fact that this could be done with RectFill or AreaInfo):

#include <exec/types.h>
#include <intuition/intuition.h>

struct NewWindow NW =
{0,0,300,200,-1,-1,NULL,WINDOWDRAG,NULL,NULL,"Window",NULL,NULL,
0,0,640,400,WBENCHSCREEN};

struct Library *IntuitionBase,*GfxBase;
struct Window *wdw;
#define Rp wdw->RPort

main()
{
	 /*Open libraries*/
   IntuitionBase=(struct Library *)OpenLibrary("intuition.library",0L);
   GfxBase=(struct Library *)OpenLibrary("graphics.library",0L);

   wdw=(struct Window *)OpenWindow(&NW); /*Open window*/
   if(wdw==NULL)  /*Exit if not opened*/
      exit(1000);

   SetDrMd(Rp,JAM1); /*Set drawing mode and pen*/
   SetAPen(Rp,1);

   Move(Rp,15,20);   /*Create a box from (15,20) to (100,100)*/
   Draw(Rp,15,100);
   Draw(Rp,100,100);
   Draw(Rp,100,20);
   Draw(Rp,15,20);
   Flood(wdw->RPort,1,30,30); /*And fill it (but it doesn't work!)*/

   Delay(100);       /*Pause for a bit...*/

   CloseWindow(wdw);    /*Cleanup and exit*/
   exit(0);
}

I'd appreciate it if someone could point out what I'm missing.  Thanks.

-- 
Dave Schreiber                               E-mail:  davids@ucscf.ucsc.edu
"It was fun learning about logic, but I don't see where or when I will ever
use it again."                               Disclaimer:

jpotter@ucs.adelaide.edu.au (Jonathan Potter) (05/11/91)

In article <15629@darkstar.ucsc.edu> davids@ucscf.UCSC.EDU (Dave Schreiber) writes:
>I'm having a problem figuring out how the Flood() function works.  I've
>been able to get flood mode #0 (flood to the outline color) to work, but
>it's incredibly slow (even on my 3000), and not really what I want anyway.
>Mode #1 (flood the block of color at the given coordinates), on the other
>hand, looks like it will fit the bill, but I haven't been able to get it to
>work.  Here's a code sample that illustrates what I'm trying to do

You need to allocate a TmpRas, and set the TmpRas pointer of the rastport to
that. The TmpRas (presumably short for temporary rastport) is the same height
and width as your window's rastport, but only one bit-plane deep. Check the RKM
for more info, as I can't remember exactly how its done of the top of my head.

Jon
-- 
| Jonathan Potter |                              | I'd really like to      |
| P.O. Box 289    | jpotter@itd.adelaide.edu.au  |   change the world...   |
| Goodwood, SA    | FidoNet : 3:680/829          | But they won't give me  |
| Australia  5034 |                              |   the source code.      |

bj@cbmvax.commodore.com (Brian Jackson) (05/11/91)

In article <3238@sirius.ucs.adelaide.edu.au> jpotter@ucs.adelaide.edu.au (Jonathan Potter) writes:
>In article <15629@darkstar.ucsc.edu> davids@ucscf.UCSC.EDU (Dave Schreiber) writes:
>>I'm having a problem figuring out how the Flood() function works.  I've
>>been able to get flood mode #0 (flood to the outline color) to work, but
>>it's incredibly slow (even on my 3000), and not really what I want anyway.
>>Mode #1 (flood the block of color at the given coordinates), on the other
>>hand, looks like it will fit the bill, but I haven't been able to get it to
>>work.  Here's a code sample that illustrates what I'm trying to do
>
>You need to allocate a TmpRas, and set the TmpRas pointer of the rastport to
>that. The TmpRas (presumably short for temporary rastport) is the same height
>and width as your window's rastport, but only one bit-plane deep. Check the RKM
>for more info, as I can't remember exactly how its done of the top of my head.

>Jon

It goes something like:

struct TmpRas myTmpRas ;
PLANEPTR *trptr ;
struct Window *myWindow ;
LONG bits_wide, bits_high ;
 ...
  
 OpenWindow() ...
  
 ...
  
if(trptr = AllocRaster( bits_wide, bits_high))
{
    InitTmpRas( &myTmpRas, trptr, (LONG)(RASSIZE(bits_wide,bits_high))) ;
    myWindow->RPort->TmpRas = &myTmpRas ;
}

Brian

 -----------------------------------------------------------------------
 | Brian Jackson  Software Engineer, Commodore-Amiga Inc.  GEnie: B.J. |
 | bj@cbmvax.cbm.commodore.com    or  ...{uunet|rutgers}!cbmvax!bj     |
 | "My beer comes from farther away than your beer."                   |
 -----------------------------------------------------------------------

davids@ucscf.UCSC.EDU (Dave Schreiber) (05/12/91)

In article <3238@sirius.ucs.adelaide.edu.au> jpotter@ucs.adelaide.edu.au (Jonathan Potter) writes:
>
>You need to allocate a TmpRas, and set the TmpRas pointer of the rastport to
>that. The TmpRas (presumably short for temporary rastport) is the same height
>and width as your window's rastport, but only one bit-plane deep. Check the RKM
>for more info, as I can't remember exactly how its done of the top of my head.

I tried your suggestion, and it Flood() still doesn't work (at least not
mode 1;  mode 0 works perfectly without a TmpRas).  

I can't find anything in the (1.1) RKMs, BTW, about using a TmpRas with
the Flood() command.  Is it in the 1.3 RKMs?

>| Jonathan Potter |                              | I'd really like to      |


-- 
Dave Schreiber                               E-mail:  davids@ucscf.ucsc.edu
"It was fun learning about logic, but I don't see where or when I will ever
use it again."                               Disclaimer:

jpotter@ucs.adelaide.edu.au (Jonathan Potter) (05/12/91)

In article <15681@darkstar.ucsc.edu> davids@ucscf.UCSC.EDU (Dave Schreiber) writes:
>I tried your suggestion, and it Flood() still doesn't work (at least not
>mode 1;  mode 0 works perfectly without a TmpRas).
>
>I can't find anything in the (1.1) RKMs, BTW, about using a TmpRas with
>the Flood() command.  Is it in the 1.3 RKMs?

You're right, I can't find anything in the 1.1 rkms either (tho I'm sure
it was there :-) However, try page 369 of the 1.3 libraries & devices.

Jon
-- 
| Jonathan Potter |                              | I'd really like to      |
| P.O. Box 289    | jpotter@itd.adelaide.edu.au  |   change the world...   |
| Goodwood, SA    | FidoNet : 3:680/829          | But they won't give me  |
| Australia  5034 |                              |   the source code.      |