Jump to content
  • Advertisement

bramsquad

Member
  • Content Count

    6
  • Joined

  • Last visited

Community Reputation

122 Neutral

About bramsquad

  • Rank
    Newbie
  1. bramsquad

    DeviceLostException

    oh, i forgot to say, i did incorperate your resizing event handler. so i dont think the problem with the toggle lies there.
  2. bramsquad

    DeviceLostException

    Thanks for the help...but I actually do need some more direction...i havent got it quite working but i think i understand it a lot better. I think some of these ramblings maybe quite simplistic, but please bear with me, im fairly new to DX. when i posted earlier code, i showed my state delagate system. my program works on delagates and each pointer points to its own respective update function. these functions more or less process mouse movement, key strokes, and eventually they render to the screen. question being, is that all my textures, sprites, etc... are created in the constructor. so if i were to dispose of them would the device.Reset() call reinstantiate them, or would i have to create another instance of my class? next about the toggling between full screen and windowed mode. here is some code i made (this is the part i think is a simple solution) public static void ScreenFull() { presentParams.SwapEffect = SwapEffect.Discard; presentParams.PresentationInterval = PresentInterval.One; Format current = Microsoft.DirectX.Direct3D.Manager.Adapters[0].CurrentDisplayMode.Format; if (Microsoft.DirectX.Direct3D.Manager.CheckDeviceType(0, Microsoft.DirectX.Direct3D.DeviceType.Hardware, current, current, false)) { presentParams.Windowed = false; presentParams.BackBufferFormat = current; presentParams.BackBufferCount = 1; presentParams.BackBufferWidth = ScreenWidth = 800; presentParams.BackBufferHeight = ScreenHeight = 600; } else { //error handling (cant support full screen mode) } DG_Device.Dispose(); DG_Device = new DGDevice(0, Microsoft.DirectX.Direct3D.DeviceType.Hardware, m_GameWindow, CreateFlags.SoftwareVertexProcessing, presentParams); DG_Device.RenderState.ReferenceAlpha = 0; DG_Device.RenderState.AlphaFunction = Compare.NotEqual; } public static void ScreenWindowed() { presentParams.SwapEffect = SwapEffect.Discard; presentParams.PresentationInterval = PresentInterval.One; ScreenWidth = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width; ScreenHeight = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height; presentParams.Windowed = true; DG_Device.Dispose(); DG_Device = new DGDevice(0, Microsoft.DirectX.Direct3D.DeviceType.Hardware, m_GameWindow, CreateFlags.SoftwareVertexProcessing, presentParams); DG_Device.RenderState.ReferenceAlpha = 0; DG_Device.RenderState.AlphaFunction = Compare.NotEqual; } now if i toggle it just locks up. i guess i dont quite know what else to do... i set different presentparams, dipose of the current graphic device, and create a new one...so what step am i missing? thanks a lot for your help, josh
  3. currently im writing this hobby game in C# using DX9 i have it working in full screen mode and all is well except for this one problem. I cant imagine this error happening often, but i dont really understand why it does.... if i click in any one of the corners, like (0,0), (0, 799), etc. i get an unhandled exception. DeviceLostException to be precise. the info on this says 'The device has been lost but cannot be reset at this time.' which says to me that even if i handle the exception, the program will have to terminate. is the only way to avoid this problem to programmatically make it so the user cannot move the mouse the these coordinates? here is my code... public static void Render() { DG_Device.Clear(ClearFlags.Target, System.Drawing.Color.Black, 1.0f, 0); DG_Device.BeginScene(); m_States[m_States.Count - 1](); DG_Device.EndScene(); DG_Device.Present(); } and the exception occurs on the line with 'DG_Device.Present();' btw, the code excecuted here 'm_States[m_States.Count - 1]();' just calls an update function (which will have a specific render function) to the state the game is at. (like titlescreen, save screen, etc.) thanks for you help, Josh
  4. bramsquad

    DirectX 9 mouse position

    First of all thank you for your replies. I actually messed around with GetCursorPos() after I made the post. It makes complete sense what you're saying, but the problem I have with that is the app Im creating is a windowed app. I guess I could get the position of the window relative to the desktop, and the position of the cursor and make my calculations that way, is that an acceptable solution? just seems like it should be easier than that. thanks again, Josh
  5. Ive been working on understanding DirectInput concerning the mouse on DX9... right now i know how to get the coordinates of the current mouse position, something like (in C# btw) MouseState state = DGdevice.CurrentMouseState; where my X and Y are state.X and state.Y this gives a relative position to the last poll taken, so i set the AxisModeAbsolute property to true. This however gives me a crazy number, sometimes positive, sometimes negative, and always very large and always different everytime i run the app. What Im looking to to is have 'buttons' on my window...so i need the absolute position of them so the app will know which button is clicked (if any) and what is really crazy (if someone could please explain this to me) is that if the mouse is at the top of the screen, and i keep moving the mouse up, the Y value keeps increasing...why isnt there a max and min y and x value? thanks in advance
  6. bramsquad

    alpha channel

    im hoping someone can shed some light on this becuase its makes no sense to me. im creating a game in C# and have just successfully made a fade in / fade out effect using directX sprite calls and changing the alpha value. it works perfectly, but becuase I have an animation (which the frames are stored in a tileset bitmap) I have to make two calls, one to Sprite.Draw and one to Sprite.Draw2D. I use the sprite.Draw function b/c it lets me specify the rectangle to draw within the tileset. Now heres the problem..... The rates of the fading are not the same. The calls are back to back, so the m_Alpha value doesnt change, but the animated rectangle fades in slower than the non animated section. for example, I do a call to BGSprite.Draw2D(m_Texture, new Point(0, 0), 0f, new Point(0, 0), Color.FromArgb(m_Alpha, Color.White)); BGSprite.Draw(m_Texture, m_Options[OptionIndex].GetCurrentCoordinates(), Vector3.Empty, m_OptionCoords, Color.FromArgb(m_Alpha, Color.White)); i hope you understand my problem. i have no idea why its doing what it does. Thanks!
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!