unit Unit3;
interface
uses
Winapi.Windows,
Vcl.Forms,
Winapi.Direct3D9;
type
TForm3 =
class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form3: TForm3;
implementation
{$R *.dfm}
procedure DebugOutput(
const AText:
string);
begin
OutputDebugString(PChar(AText));
end;
procedure TestDirect3D9(
const AForm: TForm);
var
m_pD3DDirect3d: IDirect3D9;
hr: HRESULT;
d3dpp: TD3DPresentParameters;
m_pD3DDevice: IDirect3DDevice9;
begin
m_pD3DDirect3d := Direct3DCreate9(D3D_SDK_VERSION);
ZeroMemory(@d3dpp, SizeOf(d3dpp));
d3dpp.BackBufferWidth := AForm.ClientWidth;
d3dpp.BackBufferHeight := AForm.ClientHeight;
d3dpp.BackBufferCount := 1;
d3dpp.BackBufferFormat := D3DFMT_UNKNOWN;
d3dpp.SwapEffect := D3DSWAPEFFECT_DISCARD;
d3dpp.hDeviceWindow := AForm.Handle;
d3dpp.Windowed := True;
hr := m_pD3DDirect3d.CreateDevice(
D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL,
0,
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
@d3dpp,
m_pD3DDevice);
case hr
of
D3D_OK:
DebugOutput('
Alles chic!');
D3DERR_DEVICELOST:
DebugOutput('
Gerät wech!');
D3DERR_INVALIDCALL:
DebugOutput('
Falscher Aufruf');
D3DERR_NOTAVAILABLE:
DebugOutput('
Is nich!');
D3DERR_OUTOFVIDEOMEMORY:
DebugOutput('
Kein Platz');
else
DebugOutput('
Alles kaputt');
end;
end;
procedure TForm3.FormCreate(Sender: TObject);
begin
TestDirect3D9(Self);
end;
end.