Software Archive
Read-only legacy content
17060 Discussions

Double buffering for Animation

Intel_C_Intel
Employee
693 Views
I can't seem to locate routines for double buffering. Is this possible with Quickwin? Or, is ther another means to create animation?

Rudy
0 Kudos
3 Replies
Jugoslav_Dujic
Valued Contributor II
693 Views
You can't do double buffering with QuickWin; more precisely,
you can, but you'll have to attach a Win32-handled window or dialog;
with QuickWin child windows it's not possible since they're already
double-buffered internally by QuickWin framework. Perhaps you could subclass a QW child window, intercepting WM_PAINT and WM_ERASEBKGND messages, doing your own painting (double-buffered);
I did try subclassing, but without intercepting these two messages, so I can't tell you whether there are some gotchas.

Well, the answers above are rather general -- I'm willing to explain
in more detail, but please provide more details on required window size, animation speed and GUI requirements.

Regards

Jugoslav
0 Kudos
Intel_C_Intel
Employee
693 Views
multiple window dialog: 1 frame,1 dialog, 1 graphics. The current speed is fast, but there is a flicker. I don't think speed is an issue.
0 Kudos
Jugoslav_Dujic
Valued Contributor II
693 Views
Sorry, I still don't get what you mean by "multiple window dialog". Should the animation be placed in QW child window(s) or a dialog box?

Re-thinking about that, you might construct an (almost) pure QW solution
using GetImage/PutImage in child windows. This wouldn't be probably as
fast as Win32 solution, but if speed is not an issue, it may work OK.
First, create a dummy QW child window (OPEN(55,FILE='User')). Do a SetWindowConfig of appropriate size. Then, move it somewhere where it won't be visible:

 
USE DFWIN 
hDummyWnd=GetHWNDQQ(55) 
iSt=MoveWindow(hDummyWnd,-1,-1,0,0) 


Then, do the drawing on that window (SetActiveQQ(55), then draw whatever necessary). When you finish drawing, use GetImage to
copy its contents into a previously allocated memory buffer, SetActiveQQ(iDestinationUnit) and PutImage onto it.

Timing of that procedure can be an issue. The purest way woud be
to place drawing+copying procedure as a callback for a timer:
 
USE DFWIN 
INTERFACE 
      SUBROUTINE MyAnimationProc(hWnd, Msg, ID, iTime) 
      !DEC$ATTRIBUTES STDCALL:: MyAnimationProc 
      INTEGER:: hWnd, Msg, ID, iTime 
END INTERFACE 
 
!A timer set to 100 ms 
iSt=SetTimer(NULL, 0, 100, LOC(MyAnimationProc)) 
!======================================== 
SUBROUTINE MyAnimationProc(hWnd, Msg, ID, iTime) 
!DEC$ATTRIBUTES STDCALL:: MyAnimationProc 
INTEGER:: hWnd, Msg, ID, iTime 
INTEGER(1), ALLOCATABLE::     iBuffer(:) 
 
iSt=SetActiveQQ(55) 
iSt=Rectangle(...) 
... 
iSize=GetImageSize(1,1,100,100) 
ALLOCATE(iBuffer(iSize)) 
 
CALL GetImage(1,1,100,100,iBuffer) 
iSt=SetActiveQQ(11) 
CALL PutImage(1,1,iBuffer,$GPSET) 
DEALLOCATE(iBuffer) 


Well, if you need it in a dialog, that's another issue.

Jugoslav
0 Kudos
Reply