;+ ; Double-buffer routines to update window all at once, for animation. ; ; PRO db,CLOSE=close ; PRO flash ; ; Sunview writes the graphics instructions to backing store first; then ; "flash-updates" the visible window. All we need to do to get smooth ; animation in Sunview is to make the graphics buffer large enough so that ; it updates all the screen at once, rather than in 2 or more steps. ; ; Unfortunately X-windows writes the graphics instructions directly to the ; screen (because it doesnt provide backing store?), so we see the image ; being drawn. If there is another image in the queue, it erases the previous ; image as soon as it is drawn, which isnt much use. Here we emulate ; Sunview, by directing graphics instructions to an invisible pixmap, ; then copying the finished image to the visible window. Like Sunview, ; the image then stays on the screen till the next image is ready. ; ; Usage: ; WINDOW,0 ; get into the window to be used for output ; db ; initiate double-buffering ; FOR i=0,99 DO BEGIN ; sequence of movie frames ; PLOT,x(*,i),y(*,i) ; generate the image ; flash ; put it up on the screen (window 0) ; END ; db,/CLOSE ; end double-buffering, get back to window 0 ; ; COMMON: dbcom, to store window number ; AUTHOR: ANM 9101xx, revised 911030 ; ANM 911229 make flash return silently if not double buffering ; ANM 930505 Add "p" to dbcom to try to delete right thing on /CLOSE ; ANM 950910 Add /NOCOMPLAIN ;- PRO flash COMMON dbcom,w,p IF !D.NAME EQ 'X' AND N_ELEMENTS(w) GT 0 THEN IF w GE 0 THEN BEGIN WSET,w & DEVICE,COPY=[0,0,!D.X_SIZE,!D.Y_SIZE,0,0,p] & WSET,p END ELSE EMPTY ; just empty if 'sun' or 'tek' END ; of flash PRO db,CLOSE=close ,NOCOMPLAIN=nocomplain COMMON dbcom,w,p & ON_ERROR,2 IF N_ELEMENTS(w) EQ 0 THEN w = -1 IF NOT KEYWORD_SET(close) THEN BEGIN ; start double-buffering IF !D.WINDOW EQ -1 THEN MESSAGE,'no window to double buffer' IF w NE -1 THEN IF KEYWORD_SET(nocomplain) THEN RETURN $ ELSE MESSAGE,'double buffering already' w = !D.WINDOW ; save name of visible window CASE !D.NAME OF 'SUN': DEVICE,RETAIN=1,BATCH_OPS=50000 ; save up o/p for "flash" update 'X': BEGIN WINDOW,/FREE,/PIXMAP,XS=!D.X_SIZE,YS=!D.Y_SIZE p = !D.WINDOW & END ELSE: MESSAGE,'not a windowing device' ENDCASE END ELSE BEGIN ; end double-buffering IF !D.WINDOW EQ -1 THEN MESSAGE,'/CLOSE: no window to not double buffer' IF w EQ -1 THEN MESSAGE,'/CLOSE: not double-buffering' CASE !D.NAME OF 'SUN': DEVICE,BATCH_OPS=1200 'X': BEGIN pp = !D.WINDOW & WDELETE,p & IF pp EQ p THEN WSET,w & END ELSE: MESSAGE,'not a windowing device' ENDCASE w = -1 END END ; of db