PDA

View Full Version : Full screen issue



lliihhaaoo
07-07-2004, 01:28 PM
If I use the Windowed mode, everything OK. But when I switch to full screen mode, several seconds later, the computer crashed! Not every time, but the frequency is very high. It's very strange. Could someone tell me the reason? Lifepower?;-)

The Powerdraw initializing code here:

// initialize powerdraw
PowerDraw := TPowerDraw.Create(FVclForm);
PowerDraw.Width := 640;
PowerDraw.Height := 480;
PowerDraw.BitDepth := bd32;
PowerDraw.OnInitDevice := PowerDrawInitDevice;
PowerDraw.OnDoneDevice := PowerDrawDoneDevice;
PowerDraw.Initialize;
...

And the full screen switch code here:

procedure TDXApplication.FullScreen;
begin
// finalize video mode
PowerDraw.DoneDevice;
// switch windowed mode
PowerDraw.Windowed := not PowerDraw.Windowed;
// change border style
if PowerDraw.Windowed then FVclForm.BorderStyle:= bsSingle
else FVclForm.BorderStyle:= bsNone;
// TForm tends to change its size
FVclForm.ClientWidth := PowerDraw.Width;
FVclForm.ClientHeight := PowerDraw.Height;
// re-initialize video mode
PowerDraw.InitDevice;
end;

LP
07-07-2004, 04:17 PM
Before the call to "DoneDevice" you should finalize all customly created fonts, textures, etc., and reinitialize them after the following call of InitDevice. Avoiding this might cause errors (failing to switch to full-screen, for instance, etc).

lliihhaaoo
14-07-2004, 11:12 PM
But I've done this;(

procedure TDXApplication.PowerDrawInitDevice(Sender: TObject; var ExitCode: Integer);
begin
if Imgs<>nil then Imgs.LoadFromVTDb(FVTDB);
if fntDef<>nil then fntDef.LoadFromVTDb(FVTDB, FNT_DEF, PowerDraw.DefTextureFormat);
if fntHnt<>nil then fntHnt.LoadFromVTDb(FVTDB, FNT_HNT, PowerDraw.DefTextureFormat);
end;

procedure TDXApplication.PowerDrawDoneDevice(Sender: TObject);
begin
if Imgs<>nil then Imgs.Finalize;
if fntDef<>nil then fntDef.Finalize;
if fntHnt<>nil then fntHnt.Finalize;
end;