Building Direct3D ProgramsWe also use fg_ddsetup() to create Direct3D programs, just as we do for full screen DirectDraw programs. For Direct3D programs, we must specify FG_DX_FLIP to use DirectDraw page flipping. Fastgraph does not support DirectDraw blitting in Direct3D programs. Programs linked with Fastgraph's DirectX libraries can use either Direct3D or Fastgraph's own rendering for their 3D operations. There are four additional fg_ddsetup() flags used with Direct3D programs that control what type of 3D rendering a DirectX application will use, and if we will be using a Direct3D z-buffer. The complete list of fg_ddsetup() flags is shown here:
The FG_DX_RENDER_xx flags define what types of 3D rendering a DirectX program can use. If FG_DX_RENDER_HW is specified but FG_DX_RENDER_SW is not, Fastgraph will try to use Direct3D hardware acceleration for 3D operations but use Fastgraph's 3D rendering if Direct3D hardware support is not available. Similarly, if FG_DX_RENDER_SW is specified but FG_DX_RENDER_HW is not, Fastgraph will try to use Direct3D software rendering but use Fastgraph's 3D rendering if Direct3D is not available. If both FG_DX_RENDER_HW and FG_DX_RENDER_SW are specified, Fastgraph will first try to use Direct3D hardware acceleration, then Direct3D software rendering, and finally Fastgraph's 3D rendering. Note that Fastgraph's 3D rendering will be used whenever all requested Direct3D methods fail, so we do not need to specify FG_DX_RENDER_FG, but this flag is provided for clarity. Here are four example fg_ddsetup() calls that initialize Direct3D:
C/C++ and Delphi:
Visual Basic:
The first call makes Fastgraph use Direct3D hardware acceleration if available, and if not, defaults to Fastgraph's 3D rendering. The second call is similar but checks for Direct3D software rendering instead of hardware acceleration. The third call uses Direct3D hardware acceleration if available, then checks for Direct3D software rendering, and finally defaults to Fastgraph's 3D rendering if Direct3D is not available. The fourth call is like the first, but it also creates a Direct3D z-buffer. To use Direct3D in a Fastgraph application, it must be a full screen DirectDraw program with the following properties:
The above list does not apply to DirectDraw programs created with Fastgraph, or to programs linked with Fastgraph's native libraries. Further, the fg_polyedge() and fg_tmspan() functions have no effect when used in Direct3D programs. In Fastgraph's DirectX libraries, fg_vbinit() returns -1 if DirectX was not initialized successfully (which probably means DirectX isn't available on that system). If the DirectX initialization was successful, the return value indicates what type of 3D rendering Fastgraph will use in that program. In this case, the possible fg_vbinit() return values are 0 if the program is using Fastgraph's own 3D rendering, 1 for Direct3D software rendering, or 2 for Direct3D hardware acceleration. For example, here's how you could require a Fastgraph program to use Direct3D hardware acceleration:
C/C++:
C++Builder:
Delphi:
Visual Basic:
After a DirectX program calls fg_vbinit(), the fg_ddusage() function will return the same value fg_vbinit() did. The fg_ddusage() function has no parameters and has the same possible return values as fg_vbinit().
|
 
copyright 2001 Ted Gruber Software, Inc.