oh yes.. :)) i looked that one up.. :))

i tried using it in my callbacks.. then that did not work,
so i tried it in all methods that can be accessed by any
of the callbacks..

it is probably best to see the code.

i have included the Graphics.c file - which should do my 
double buffering and freeing of the offscreen window.

cheers. 
:))

az.
--
#include <Pilot.h>

#include "Graphics.h"

static CustomPatternType erase  = { 0x0000, 0x0000, 0x0000, 0x0000 };
static RectangleType     screen = { 0, TITLE_HEIGHT, 
                                    PALM_WIDTH, (PALM_HEIGHT - TITLE_HEIGHT) };

static WinHandle scrnBuffer = NULL;
static WinHandle backBuffer = NULL;

void    
_Graphics_initialize()
{
  Word error;

#ifdef __GNUC__
  FUNCTION_PROLOGUE
#endif

  scrnBuffer = WinGetDrawWindow();
  backBuffer = WinCreateOffscreenWindow(PALM_WIDTH, PALM_HEIGHT, screenFormat, 
&error); 
  ErrFatalDisplayIf(error, "Cannot create offscreen buffer.");

  if (backBuffer != NULL) 
    WinInitializeWindow(backBuffer);

  backBuffer = NULL;

#ifdef __GNUC__
  FUNCTION_EPILOGUE
#endif
}

void    
_Graphics_terminate()
{
#ifdef __GNUC__
  FUNCTION_PROLOGUE
#endif

  WinSetDrawWindow(scrnBuffer);

  if (backBuffer != NULL) 
    WinDeleteWindow(backBuffer, false);

#ifdef __GNUC__
  FUNCTION_EPILOGUE
#endif
}

void    
_Graphics_clearScr()
{
  CustomPatternType oldPattern;

#ifdef __GNUC__
  FUNCTION_PROLOGUE
#endif

  if (backBuffer != NULL) 
    WinSetDrawWindow(backBuffer);

  WinGetPattern(oldPattern);
  WinSetPattern(erase);
  WinFillRectangle(&screen, 0);
  WinSetPattern(oldPattern);

  if (backBuffer != NULL) 
    WinSetDrawWindow(scrnBuffer);

#ifdef __GNUC__
  FUNCTION_EPILOGUE
#endif
}

void    
_Graphics_drawPoint(int x, int y, int style)
{
#ifdef __GNUC__
  FUNCTION_PROLOGUE
#endif

  _Graphics_drawRectangle(x-2, y-2, x+2, y+2, style, 0);

#ifdef __GNUC__
  FUNCTION_EPILOGUE
#endif
}

void    
_Graphics_drawLine(int x1, int y1, int x2, int y2, int style)
{
#ifdef __GNUC__
  FUNCTION_PROLOGUE
#endif

  if (backBuffer != NULL) 
    WinSetDrawWindow(backBuffer);

  switch (style) 
  {
    case LIGHT:
         WinDrawGrayLine(x1, y1, x2, y2);
         break;

    case ERASE:
         WinEraseLine(x1, y1, x2, y2);
         break;

    case INVERT:
         WinInvertLine(x1, y1, x2, y2);
         break;

    case NORMAL: 
    default:
         WinDrawLine(x1, y1, x2, y2);
         break;
  }

  if (backBuffer != NULL) 
    WinSetDrawWindow(scrnBuffer);

#ifdef __GNUC__
  FUNCTION_EPILOGUE
#endif
}

void    
_Graphics_drawRectangle(int x1, int y1, int x2, int y2, int style, int diam)
{
  RectangleType rect = { x1, y1, (x2-x1), (y2-y1) };

#ifdef __GNUC__
  FUNCTION_PROLOGUE
#endif

  if (backBuffer != NULL) 
    WinSetDrawWindow(backBuffer);

  switch (style) 
  {
    case ERASE:
         WinEraseRectangle(&rect, diam);
         break;
  
    case INVERT:
         WinInvertRectangle(&rect, diam);
         break;
 
    case FILL:
         WinFillRectangle(&rect, diam);
         break;

    case NORMAL:
    default:
         WinDrawRectangle(&rect, diam);
         break;
  }
    
  if (backBuffer != NULL) 
    WinSetDrawWindow(scrnBuffer);

#ifdef __GNUC__
  FUNCTION_EPILOGUE
#endif
}

void    
_Graphics_drawString(char *str, int len, int x, int y, int style)
{
#ifdef __GNUC__
  FUNCTION_PROLOGUE
#endif

  if (backBuffer != NULL) 
    WinSetDrawWindow(backBuffer);

  switch (style) 
  {
    case ERASE:
         WinEraseChars(str, len, x, y);
         break;

    case INVERT:
         WinInvertChars(str, len, x, y);
         break;

    case NORMAL:
    default:
         WinDrawChars(str, len, x, y);
         break;
  }

  if (backBuffer != NULL) 
    WinSetDrawWindow(scrnBuffer);

#ifdef __GNUC__
  FUNCTION_EPILOGUE
#endif
}

void    
_Graphics_repaint()
{
#ifdef __GNUC__
  FUNCTION_PROLOGUE
#endif

  if (backBuffer != NULL) 
    WinCopyRectangle(backBuffer, scrnBuffer, &screen, 0, TITLE_HEIGHT, scrCopy);

#ifdef __GNUC__
  FUNCTION_EPILOGUE
#endif
}
--

az.
--
Aaron Ardiri 
Lecturer                       http://www.hig.se/~ardiri/
University-College i G�vle     mailto:[EMAIL PROTECTED]
SE 801 76 G�vle SWEDEN       
Tel: +46 26 64 87 38           Fax: +46 26 64 87 88
Mob: +46 70 352 8192           A/H: +46 26 10 16 11

On Wed, 7 Apr 1999, Ray Rodrick wrote:

> Aaron,
> Just a thought - Are you using CALLBACK_PROLOG/EPILOG in your callbacks !
> Regards,
> Ray
> 
> Aaron Ardiri wrote:
> 
> > hej!
> >
> >   my recent experience is that the double buffering techniques
> >   do not work in GCC.. i have not got a copy of code warrior
> >   (and i am running win98 - so i cannot download the preview)
> >   so i dont know if it is gcc, or not.
> >
> >   i have scanned the code - but i cannot seem to locate the
> >   error.
> >
> >   even simply creating an offscreen image, then destroying
> >   it (freeing it) causes the palm to crash.
> >
> >   you can see the source here:
> >
> >     http://www.hig.se/~ardiri/development/palmIII/index.html
> >
> >   if anyone can check this code out? (maybe compile it on
> >   code warrior?) it would be greatly appreciated.
> >
> >   i need to know if i need to change development tools.
> >   (although i hate windows and crappy user interfaces).
> >   gcc and make are perfect for what i want, and it also
> >   means i can compile on linux, win95 and solaris (without
> >   any hassles).
> >
> >   cheers.
> >
> > az.
> > --
> > Aaron Ardiri
> > Lecturer                       http://www.hig.se/~ardiri/
> > University-College i G�vle     mailto:[EMAIL PROTECTED]
> > SE 801 76 G�vle SWEDEN
> > Tel: +46 26 64 87 38           Fax: +46 26 64 87 88
> > Mob: +46 70 352 8192           A/H: +46 26 10 16 11
> >
> > On Wed, 7 Apr 1999, Ray Rodrick wrote:
> >
> > > Hi,
> > >
> > > I would like to know as well - I am happy with GCC (W95) but see many
> > > complaints and problems posted about CodeWarrior.
> > >
> > > I have a copy of V4 and have just received my V5 free update, but since
> > > there seems to be many outstanding issues, many of which it seems are
> > > not going to be fixed until V6, I have not bothered to use it.   I feel
> > > reluctant to part with more money to get fixes when I am happy with GCC.
> > >
> > > Anyone like to comment ?
> > >
> > > Regards,
> > > Ray
> > >
> > > george williams wrote:
> > >
> > > > Perhaps a question for hardcore developers:
> > > >
> > > > I've been using gcc with a minimal emacs dev
> > > > environment and it works fine.  Are there
> > > > any great reasons to move to a prettier dev
> > > > solution like MetroWorks?
> > > >
> > > > gw.
> > >
> > >
> > >
> 
> 
> 

Reply via email to