uses
Winapi.GDIPOBJ,
Winapi.Windows,
Winapi.Direct3D9,
// Winapi.DirectDraw,
Winapi.D3DX9;
procedure LoadPerDirectX(
const Filename:
string);
var
HR: HRESULT;
Direct3D: IDirect3D9Ex;
Device: IDirect3DDevice9;
Texture: IDirect3DTexture9;
Params: TD3DPresentParameters;
DisplayMode: TD3DDisplayMode;
D3DSurface: IDirect3DSurface9;
// DDSurface: IDirectDrawSurface7;
begin
HR := Direct3DCreate9Ex(D3D_SDK_VERSION, Direct3D);
if Failed(HR)
then
Exit;
HR := Direct3D.GetAdapterDisplayMode(D3DADAPTER_DEFAULT, DisplayMode);
if Failed(HR)
then
Exit;
FillChar(Params, SizeOf(Params), 0);
Params.SwapEffect := D3DSWAPEFFECT_DISCARD;
Params.BackBufferCount := 1;
Params.BackBufferWidth := DisplayMode.Width;
Params.BackBufferHeight := DisplayMode.Height;
Params.BackBufferFormat := DisplayMode.Format;
HR := Direct3D.CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, 0, D3DCREATE_SOFTWARE_VERTEXPROCESSING, @Params, Device);
if Failed(HR)
then
Exit;
HR :=
Winapi.D3DX9.D3DXCreateTextureFromFile(Device, PWideChar(Filename), Texture);
if Failed(HR)
then
Exit;
HR := Texture.GetSurfaceLevel(0, D3DSurface);
if Failed(HR)
then
Exit;
end;