Welcome, Guest. Please login or register.

Author Topic: Problem with SA_BackFill  (Read 3953 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline ami_stuffTopic starter

  • Full Member
  • ***
  • Join Date: May 2009
  • Posts: 100
    • Show only replies by ami_stuff
Problem with SA_BackFill
« on: April 03, 2011, 03:45:26 AM »
Hi,

Maybe someone can tell me what is wrong with this code. WA_BackFill works correctly, but SA_BackFill not :/

Quote

   #include
   #include
   #include
   #include
   #include
   #include
   #include

struct Library *CyberGfxBase;

struct BackfillMsg
{
ULONG dummy;
struct Rectangle rect;
LONG offsetx, offsety;
};


void sbackfillfunc (struct Hook *hook, struct RastPort *frp, struct BackfillMsg *bfm)
{

    struct RastPort rp;

    CopyMem(frp, &rp, sizeof(struct RastPort));
    rp.Layer = NULL;    

FillPixelArray(&rp,bfm->rect.MinX, bfm->rect.MinY, bfm->rect.MaxX - bfm->rect.MinX + 1, bfm->rect.MaxY - bfm->rect.MinY + 1, 0x00000000);
}

struct Hook bfhook;



int main (void)

   {

        CyberGfxBase = OpenLibrary("cybergraphics.library",0);


         struct Window *win;
         struct Screen *scr;

                        bfhook.h_Entry    = (HOOKFUNC)HookEntry;
              bfhook.h_SubEntry = (HOOKFUNC)sbackfillfunc;


                        scr = OpenScreenTags(NULL,
                         SA_LikeWorkbench,TRUE,
               SA_BackFill,&bfhook,
               TAG_DONE);


         if (win = OpenWindowTags (NULL,
               WA_Left,200,
               WA_Top,200,
               WA_Width,scr->Width / 2,
               WA_Height,scr->Height / 2,
               WA_Flags,WFLG_CLOSEGADGET | WFLG_DRAGBAR | WFLG_DEPTHGADGET | WFLG_SIZEGADGET | WFLG_ACTIVATE | WFLG_NOCAREREFRESH,
               WA_IDCMP,IDCMP_CLOSEWINDOW,
               WA_Title,"Test",
               WA_BackFill,&bfhook,
               WA_PubScreen, scr,
               TAG_END))
            {
            BOOL cont = TRUE;

            do   {
               struct IntuiMessage *imsg;

               if (Wait ((1L << win->UserPort->mp_SigBit) | SIGBREAKF_CTRL_C) & SIGBREAKF_CTRL_C)
                  cont = FALSE;

               while (imsg = (struct IntuiMessage *) GetMsg (win->UserPort))
                  {
                  switch (imsg->Class)
                     {
                  case IDCMP_CLOSEWINDOW:
                     cont = FALSE;
                     break;
                     }
                  ReplyMsg ((struct Message *) imsg);
                  }
               }
            while (cont);

            CloseWindow (win);
            }


   CloseScreen (scr);

   return (RETURN_OK);
   }


Regards
 

Offline Thomas

Re: Problem with SA_BackFill
« Reply #1 on: April 03, 2011, 08:02:38 AM »
It does work. If you move the window away, the revealed areas are filled with black as intended.

The problem is that installing the hook does not invoke it. You either need to call it manually or open and close a window which covers the entire screen.

Edit: this may be used to call the hook manually:

Quote

struct BackfillMsg tempbfm;
tempbfm.rect.MinX = 0;
tempbfm.rect.MinY = scr->BarHeight + 1;
tempbfm.rect.MaxX = scr->Width - 1;
tempbfm.rect.MaxY = scr->Height - 1;
CallHookPkt (&bfhook,&scr->RastPort,&tempbfm);
« Last Edit: April 03, 2011, 08:11:25 AM by Thomas »
 

Offline ami_stuffTopic starter

  • Full Member
  • ***
  • Join Date: May 2009
  • Posts: 100
    • Show only replies by ami_stuff
Re: Problem with SA_BackFill
« Reply #2 on: April 03, 2011, 11:07:03 AM »
Thanks Thomas. To reduce the flickering on the screen (gray->black)  I decided to use SA_Behind + ScreenToFront() combination, but maybe there is a better method?
 

Offline matthey

  • Hero Member
  • *****
  • Join Date: Aug 2007
  • Posts: 1294
    • Show only replies by matthey
Re: Problem with SA_BackFill
« Reply #3 on: April 03, 2011, 02:28:41 PM »
Could use a backdrop (WA_Backdrop) window on the screen? This type of window always stays in the back and looks like it's the screen but has the advantages of a window.
 

Offline ami_stuffTopic starter

  • Full Member
  • ***
  • Join Date: May 2009
  • Posts: 100
    • Show only replies by ami_stuff
Re: Problem with SA_BackFill
« Reply #4 on: April 03, 2011, 04:47:22 PM »
@matthey

This flickers as well, because screen is still gray at the beginning and next "repleaced" by black window.
« Last Edit: April 03, 2011, 05:08:18 PM by ami_stuff »
 

Offline matthey

  • Hero Member
  • *****
  • Join Date: Aug 2007
  • Posts: 1294
    • Show only replies by matthey
Re: Problem with SA_BackFill
« Reply #5 on: April 03, 2011, 05:48:45 PM »
Quote from: ami_stuff;627269
@matthey
This flickers as well, because screen is still gray at the beginning and next "replaced" by black window.


Grey is the default color. The window color could be set with graphics/SetRast() for <=8 bit depth and cybergraphics/FillPixelArray() for >8 bit depth. It's been a long time since I played with Intuition so maybe there is a better idea.