DirectX Animation

The Fastgraph example programs that perform frame-based animation all use a different form of the message loop that calls our own "do the next frame" function when no Windows messages are waiting. If you're creating a DirectX program with Fastgraph, you must modify the message loop so it calls this function only when the program is active. We can determine if a program is active by adding a WM_ACTIVATEAPP event handler (a WM_ACTIVATEAPP event occurs when control switches to or from an application). The way you implement a WM_ACTIVATEAPP handler differs for each supported language.

The WM_ACTIVATEAPP handler also calls fg_ddrestore() to restore all DirectDraw surfaces when control switches back to our program from some other application. This is necessary because Fastgraph creates the primary surface (and its back buffer if present) in video memory. Other surfaces created with fg_vballoc() can also reside in video memory if directed by fg_ddmemory(). When you switch control from a DirectX program to some other task, the DirectX program is minimized and some or all of its video memory surfaces may be lost. Calling fg_ddrestore() restores the primary surface and all other DirectDraw surfaces that reside in video memory. It has no parameters and no return value. Note that fg_ddrestore() restores the actual surfaces, but not their contents.

<< Prev

Next >>

Contents
Fastgraph Home Page

 

copyright 2001 Ted Gruber Software, Inc.