function TOmegaScreen.ReInit: HRESULT;
var
hr: HRESULT;
fsok: boolean;
d3ddm: TD3DDisplayMode;
behave: cardinal;
pool: TD3DPOOL;
begin
if not assigned(FDevice) then
begin
result := S_FALSE;
exit
end;
CaptureRenderStates;
SubUnInit;
if vb <> nil then
vb := nil;
if assigned(FOnUnInit) then
FOnUnInit(self);
FDevice.SetTexture(0, nil);
{ if not FFullScreen then
begin
GetWindowRect(FhWnd, rcWindowBounds);
SetWindowPos(FhWnd, HWND_NOTOPMOST,
rcWindowBounds.left, rcWindowBounds.top,
(rcWindowBounds.right - rcWindowBounds.left),
(rcWindowBounds.bottom - rcWindowBounds.top),
SWP_SHOWWINDOW);
end;
}
fsok := false;
if ((FWidth = 800) and (FHeight = 600)) or
((FWidth = 640) and (FHeight = 400)) or
((FWidth = 640) and (FHeight = 480)) or
((FWidth = 1024) and (FHeight = 76
) or
((FWidth = 320) and (FHeight = 200)) or
((FWidth = 320) and (FHeight = 240)) or
((FWidth = 1280) and (FHeight = 1024)) then
fsok := true;
with FD3DDEVPPAR do
begin
Windowed := not FFullScreen;
if FBBAccess then
Flags := D3DPRESENTFLAG_LOCKABLE_BACKBUFFER
else
Flags := 0;
if (not Windowed) then
begin // FullScreen
if not fsok then
begin
beep;
BackBufferWidth := 800;
BackBufferHeight := 600;
end
else
begin
BackBufferWidth := FWidth;
BackBufferHeight := FHeight;
end;
if Fbpp = 16 then
BackBufferFormat := D3DFMT_R5G6B5
else
BackBufferFormat := D3DFMT_A8R8G8B8;
if FBBCount < 1 then
FBBCount := 1;
BackBufferCount := FBBCount;
FullScreen_RefreshRateInHz := D3DPRESENT_RATE_DEFAULT;
if FVSync then
PresentationInterval := D3DPRESENT_INTERVAL_ONE
else
PresentationInterval := D3DPRESENT_INTERVAL_IMMEDIATE;
end
else
begin // Windowed mode
BackBufferWidth := FWidth;
BackBufferHeight := FHeight;
FD3D.GetAdapterDisplayMode(D3DADAPTER_DEFAULT, d3ddm);
BackBufferFormat := d3ddm.Format;
if FVSync then
PresentationInterval := D3DPRESENT_INTERVAL_ONE
else
PresentationInterval := D3DPRESENT_INTERVAL_IMMEDIATE;
FullScreen_RefreshRateInHz := 0;
end;
end;
// Reset the device
hr := FDevice.Reset(FD3DDEVPPAR);
if (FAILED(hr)) then
begin
result := hr;
exit;
end;
ShowCursor(FShowMouseCursor);
if FPool = plDefault then
begin
behave := D3DUSAGE_WRITEONLY or D3DUSAGE_DYNAMIC;
pool := D3DPOOL_DEFAULT;
end
else
begin
behave := D3DUSAGE_WRITEONLY;
pool := D3DPOOL_MANAGED;
end;
FDevice.CreateVertexBuffer(sizeof(TOmegaVertex) * maxVertices,
behave, OmegaVertexDef, pool, VB, nil);
RestoreRenderStates;
SubInit;
if assigned(FOnInit) then
FOnInit(self);
result := S_OK;
end;
Bookmarks