Jump to content
Xtreme .Net Talk

Xebec

Members
  • Posts

    4
  • Joined

  • Last visited

Everything posted by Xebec

  1. ooook.... well to be honest ive never looked at recovering from a lost device before...its something my current project needs but Ive kept putting it off lol...anyways I had a go at it and lo and behold...got it working... I did the same as you and searched through all posts on the topic (not early enough hehe) and found what was needed in one of drunkenhyena's tuts My guess as to the problem in your code is that while your catching the DeviceLost exception...your not catching the DeviceNotReset exception (ie the device was lost...has come back and is ready to be reset) Have a look at this code (my rendering routine as modded after reading DrunkenHyena's tut) - its c# but you should get the gist and be able to adapt to vb. int CheckResult; if (d3ddevice == null) // if no device...why are we here? return; if (d3ddevice.CheckCooperativeLevel(out CheckResult)) // is the device feeling cooperative?... { try { d3ddevice.Clear(ClearFlags.Target, System.Drawing.Color.Black, 1.0f, 0);// black base screen d3ddevice.RenderState.SourceBlend = Blend.SourceAlpha; d3ddevice.RenderState.DestinationBlend = Blend.InvSourceAlpha; d3ddevice.RenderState.AlphaBlendEnable= true; d3ddevice.BeginScene(); d3dsprite.Begin(SpriteFlags.DoNotModifyRenderState); if (d3ddevice.CheckCooperativeLevel()) // no changes to gamestate if device is messing around { Game.Render(); } d3dsprite.End(); d3ddevice.EndScene(); d3ddevice.Present(); } catch (Microsoft.DirectX.Direct3D.DeviceLostException) // catch the DeviceLost exception - decide what to do later { d3ddevice.CheckCooperativeLevel(out CheckResult); } catch (Microsoft.DirectX.Direct3D.DeviceNotResetException)// catch the DeviceNotReset exception - decide what to do later { d3ddevice.CheckCooperativeLevel(out CheckResult); } } if (CheckResult == (int)Microsoft.DirectX.Direct3D.ResultCode.DeviceLost) { //wait a bit :) - device was lost...still is.... } if (CheckResult == (int)Microsoft.DirectX.Direct3D.ResultCode.DeviceNotReset) { d3ddevice.Reset(presentParams); // haha! our device has returned to the fold!...reset it and back to business } Hope that helps a bit :)
  2. From what i can see in the sdk, you dont seem to be passing anykind of sprite in, null or otherwise if this is the call your after public int DrawText(Sprite, string, ref Rectangle, DrawTextFormat, Color); and sDevInfo is your string to be displayed you would still need a sprite of some sort soo... Dim MySprite as Microsoft.DirectX.Direct3d.Sprite .. MySprite = new Microsoft.DirectX.Direct3d.Sprite(d3ddevice) ... fntOut.DrawText(MySprite, _ sDevInfo, _ New Drawing.Rectangle(5, 5, 0, 0), _ DrawTextFormat.Left Or DrawTextFormat.Top, _ Drawing.Color.FromArgb(255, 200, 128, 64)) where d3ddevice is a valid device, might be the sort of thing your after - might not even have to initilise MySprite either (ie replacing second line with MySprite = nothing, or removing it all together maybe what the sdk is referingto by null) - havnt dabbled with the DrawText routines myself yet...
  3. hehe no worries - glad you got it working :)
  4. hmmm my vb.net is a bit rusty (not that it was that hot to begin with) since i started working in c# - so i may have the complete wrong end of the stick..but one thing pops into my head... Inside your function Engine.InitDevice()...where are you setting the return value of the function to true? seems its just falling through your while/render() loop and not rendering since FRunning is always false... ED - curiosity got the of me so i kicked up vb and tried it - yes it will hapilly let you run if/while loops on a function with no return at all... so youll need to tag a Boolean return onto InitDevice() - look for exceptions from device creation...return false if you get one...true if not.. at least so it seems hehe not exactly brimming with confidence on my programming skills :P
×
×
  • Create New...