[comp.sys.atari.st] shadow buffering

jg@hpldola.HP.COM (Joe Gilray) (01/17/89)

I tried out the shadow buffer this weekend, after negotiating with my
5 month-old for an hour off.

I proceeded as follows:

/* Step 1. set up two logical screens */
    logscr1 = Logbase();
    logscr2 = (char *)[32000 byte block aligned on 256 byte boundary]
	
/* Step 2. whenever drawing to the screen draw to both logical screens */
    Setscreen(logscr2, -1L, -1);
    draw (v_bar, v_gtext, etc)
    Setscreen(logscr1, -1L, -1);
    draw (v_bar, v_gtext, etc)

/* Step 3. when a REDRAW event is received blit from logscr2 to */
/* physical screen using vro_cpyfm().                           */

Steps 1 & 3 seem to be ok.
Step 3 will eventually consist of changing the physical screen pointer 
to logscr2 then blitting to logscr1 which will take the place of 
logscr2 (become the shadow buffer) for subsequent operations.

Step 2 is causing two problems right now:
    Problem 2a.  When things are drawn with the AES routine objc_draw()
    as in the following, the system crashes with two or three bombs.
        Setscreen(logscr2, -1L, -1);
        objc_draw(...);
        Setscreen(logscr1, -1L, -1);
        objc_draw(...);

    Problem 2b.  certain items are not being drawn at all (to either
    logical screen).  Do I need to call Vsync() after each Setscreen?
    This doesn't seem to make sense to me as the Setscreen calls are
    not affecting the physical screen at all.

Thanks for any help.

Joe Gilray
	

jg@hpldola.HP.COM (Joe Gilray) (01/19/89)

I wrote:

> /* Step 1. set up two logical screens */
>     logscr1 = Logbase();
>     logscr2 = (char *)[32000 byte block aligned on 256 byte boundary]
> 	
> /* Step 2. whenever drawing to the screen draw to both logical screens */
>     Setscreen(logscr2, -1L, -1);
>     draw (v_bar, v_gtext, etc)
>     Setscreen(logscr1, -1L, -1);
>     draw (v_bar, v_gtext, etc)
> 
> /* Step 3. when a REDRAW event is received blit from logscr2 to */
> /* physical screen using vro_cpyfm().                           */
> 
> Steps 1 & 3 seem to be ok.
> Step 3 will eventually consist of changing the physical screen pointer 
> to logscr2 then blitting to logscr1 which will take the place of 
> logscr2 (become the shadow buffer) for subsequent operations.
> 
> Step 2 is causing two problems right now:
>     Problem 2a.  When things are drawn with the AES routine objc_draw()
>     as in the following, the system crashes with two or three bombs.
>         Setscreen(logscr2, -1L, -1);
>         objc_draw(...);
>         Setscreen(logscr1, -1L, -1);
>         objc_draw(...);
> 
>     Problem 2b.  certain items are not being drawn at all (to either
>     logical screen).  Do I need to call Vsync() after each Setscreen?
>     This doesn't seem to make sense to me as the Setscreen calls are
>     not affecting the physical screen at all.
> 

Problem 2b was my fault (doing things in the wrong order).  I got around
problem 2a by drawing only to logscr1 then blitting the whole screen to
logscr2 (the shadow buffer).

Now I'm having a different problem, when I go to redraw the screen in
Step 3, I would like to blit only the part of the screen that needs to
be redrawn, but the redraw list contains only one rectangle, the size 
of the desktop.

In more detail:

Step A.  Create a window the size of the desktop

Step B.  Draw on top of this window with objc_draw, and VDI 
routines (v_bar, v_gtext, etc.)

Step C.  Draw a small dialog box with objc_draw (reserving only enough
space for the box, not the whole desktop.

Step D.  Get WM_REDRAW message when dialog box is closed.  Use 
wind_get(windhandle, WF_FIRSTXYWH, ...) and 
wind_get(windhandle, WF_NEXTXYWH, ...) to get rectangles to be
redrawn, but, although only the area of the dialog box needs to
be redrawn, I get only one rectangle the size of the entire desktop.
Also when I get the WM_REDRAW message the msg buffer [4] through
[7] contains a box the size of the entire desktop too (but I think
this is as it should be because the window that needs to be redrawn
is the size of the desktop).

Please respond, I need help!

Joe Gilray