DirectX Error Conditions

In Fastgraph's DirectX libraries, the fg_vbinit() return value indicates how Fastgraph will use DirectX. If we are using DirectDraw but not Direct3D, fg_vbinit() returns zero if DirectDraw was initialized successfully, and -1 if not (which probably means DirectX isn't available on that system). For example, the code shown here will stop the program if an error occurred during the DirectDraw initialization:

C/C++:

Status = fg_vbinit();
if (Status < 0)
{
   MessageBox(hWnd,"DirectX setup error","Error",
              MB_ICONSTOP|MB_OK);
   DestroyWindow(hWnd);
   return 0;
}

C++Builder:

Status = fg_vbinit();
if (Status < 0)
   MessageDlg("DirectX setup error",mtError,
              TMsgDlgButtons()<

}

Delphi:

Status := fg_vbinit;
if Status < 0 then
begin
  MessageDlg('DirectX setup error',mtError,[mbOK],0);
  Close;
  Exit;
end;

Visual Basic:

Status = fg_vbinit()
If Status < 0 Then
   Call MsgBox("DirectX setup error",
               vbOKOnly Or vbCritical, "Error")
   Unload Me
   Exit Sub
End If

Another function, fg_ddstatus(), returns the status of the most recent DirectX operation. If a DirectX error has occurred, fg_ddstatus() returns one of the error codes listed in the documentation supplied with the DirectX SDK, otherwise it returns zero. You can call fg_ddstatus() after any Fastgraph function to check for DirectX errors. This usually isn't necessary when building the release version of a program, but it can be useful when debugging.

<< Prev

Next >>

Contents
Fastgraph Home Page

 

copyright 2001 Ted Gruber Software, Inc.