Archived

This topic is now archived and is closed to further replies.

Chikara

Long shot...

Recommended Posts

I have a big problem with using an additional DelphiX TDirectDrawSurface in my game : I have a ''MissileSurface'' in my game thats used as a static painting ground for missile trails, this surface is described to the main DXDraw surface in the DXTimer loop. The problem is that everything works fine until someone alt-tabs out of the game into windows and then returns later. After they return as soon as the MissileSurface is drawn to (using the canvas property, example: Gameform.MissileSurface.Canvas.Pen.Color := Colour[ColourIndex]; Gameform.MissileSurface.Canvas.MoveTo(Trunc(ox), Trunc(oy)); Gameform.MissileSurface.Canvas.LineTo(Trunc(x), Trunc(y)); Gameform.MissileSurface.Canvas.Release; It creates an error in the Graphics.pas in the procedure TCanvas.RequiredState(ReqState: TCanvasState); ..procedure at this line : if FHandle = 0 then raise EInvalidOperation.CreateRes(@SNoCanvasHandle); I find this strange because if I don''t use the missile canvas, alt-tab out and then re-tab in, it will keep playing until the above missile canvas code is called, and then it gives that error. If I comment out the missile canvas code no errors are raised but then no missiles are drawn either I''ve tried all sorts of DXDraw.CanDraw protections etc but to no avail I''m, really annoyed that I can''t alt-tab my game. I''m really confused! My MissileSurface varible is solid and is being created on a DXDraw.Initialize event and destoryed on finalised, but my debug logs report that none of these are being called during the alt-tab switch, so i''m just really confused. I relise it''s really hard for you ti try to help me with out actually having the code, but i''m hoping that maybe i''m running into a problem someone else has had. I can give more details if possible. Cheers! Chuck

Share this post


Link to post
Share on other sites
Your surface is lost. You must restore it. When alt-tabbing. Your video memory get''s scrambled by windows. Therefore you must restore the surface after it gets lost. There is somekind of mothod in DelphiX surface IsLost or something. Check if it''s true then use Restore and load the surface back.

Try reading DirectX SDK help file for more information on lost sufaces.



Pekka Heikura
pekka@heikura.com
http://bnet.webprovider.com

Share this post


Link to post
Share on other sites
Thank you thank you thank you!

By putting MissileSurface.restore; in the OnRestoreSurface of the DXDraw component stops it from crashing when play is resumed!!!

Albeit, the missileSurfaced is now garbaged but a fill(0) sets it back to blank, and missiles start painting again.

I know that I can devise a method to store the canvas somewhere in (system?) memory prior to an alt-tab and then ''LoadFromDib'' it later.

But for now just having the game not crash is great!!!

yay!

Thanks again!

Chuck


P.S

Turbo team, ever thought of having a DelphiX (asp driven) tips section of Turbo, where users can post handy hints and tips (like this) to? That would be great!

Share this post


Link to post
Share on other sites
quote:

Turbo team, ever thought of having a DelphiX (asp driven) tips section of Turbo, where users can post handy hints and tips (like this) to? That would be great!



That''s what this messaage board is for

I had thought about doing a DelphiX FAQ in PHP/ASP/??? but I didn''t have the time to set it up.

If *someone* were to do it, they''d definitly have my support...



[ Michael Wilson | turbo sys-op | turbo.gamedev.net ]

Share this post


Link to post
Share on other sites