Hi everyone,

I'm working on a graphics-related application.  It will support things like
zooming and panning.  As such, I would like to use double buffering to
reduce the screen flicker while panning.  However, I'm having lots of
problems related to drawing to an offscreen window.  Here's  the general
idea:

1) Set the screen depth to the maximum supported by the device and save the
original depth
        WinScreenMode ( winScreenModeGet,  &width, &height, &depth, &enableColor);
        mSavedDeviceScreenDepth = depth;
        WinScreenMode ( winScreenModeGetSupportedDepths,  &width,&height,  &depth,
&enableColor);
        .
        . // calculate depth
        .
        WinScreenMode (winScreenModeSet,  NULL,NULL,  &depth, &enableColor);

2) Grab the bitmap from our database

3) Draw the bitmap on screen
        WinDrawBitmap( bitmapP, rect->topLeft.x, rect->topLeft.y );

4) Create an offscreen window and draw the bitmap offscreen
        if (!mOffscreenWindow)
                mOffscreenWindow = WinCreateOffscreenWindow (mWindowBounds.extent.x,
mWindowBounds.extent.y, screenFormat, &err);

        winH = WinSetDrawWindow (mOffscreenWindow);
        WinDrawBitmap( bitmapP, 0, 0);
        WinSetDrawWindow (winH);

5) Then while panning, copy the bitmap from offscreen on to the screen
        WinSetClip(&mWindowBounds);
        WinCopyRectangle (mOffscreenWindow, 0, &mWindowBounds, newX, newY,
winPaint);
        WinResetClip();

6) On appStopEvent, restore screen depth to the orignal depth
        if (mSavedDeviceScreenDepth) {
                WinScreenMode ( winScreenModeGet,  NULL,NULL,  NULL, &enableColor);
                WinScreenMode ( winScreenModeSet,  NULL,NULL,  
&mSavedDeviceScreenDepth,
&enableColor);
                mSavedDeviceScreenDepth = mDeviceScreenDepth = 0;
        }

Depending on what ROM I am running on, copying the pixels from offscreen to
screen gets fouled up.  The pixels look as if they're inverted somehow.
Also when restoring the saved screen depth upon exiting, I usually get an
error that I have written to unallocated memory, causing a fatal exception
on a real device.  However, if I do NOT draw offscreen, I don't have any
problems when restoring the saved screen depth.  I tried running on
different ROMS, and here is what I have found:

ROM Version                     Copying offscreen->screen               Restoring 
screen depth
----------------------------------------------------------------------------
-------
35-ezdbg                        displays incorrectly                            error
35-colordbg                     displays incorrectly                            no 
error
40-fulldbg                      "Bad Window" error when drawing to screen       n/a
40-VZcolordbg           displays correctly                              no error

I'm not sure if the problem is related to drawing offscreen, or copying from
offscreen to screen.  But I do know that the images always look correct when
they are drawn to the screen.  Any ideas?

Thanks a lot!

Nick Guarracino
[EMAIL PROTECTED]



-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to