XNA Creators Club Online
Page 1 of 1 (8 items)
Sort Posts: Previous Next

Problem between graphicsManager and GamerServices

Last post 05-04-2008 12:53 PM by David Hunt. 7 replies.
  • 04-27-2008 8:44 PM

    Problem between graphicsManager and GamerServices

    I'm trying to add simple multiplayer to a 3D game I'm working on but the graphicsManager and the Gamerservices are not getting along.

    I've based my game off multiple samples, mainly spacewars for the 3d elements and NetworkStateManagement for the screens.

    The game starts, but after approx. 5 seconds, I get the following exception:

               
    System.InvalidOperacionException {"An unexpected error has occurred."}


    This corresponds to the following line of code in the GameplayScreen class, Draw() method:
    ScreensManager.GraphicsDevice.Reset();


    The funny thing is, I haven't included any code so far! The only line of code I've added is
    Components.Add(new GamerServicesComponent(this));
    in the constructor for the main class of the solution.


    What is going on? Why does resetting the graphicsmanager throw an exception? If i remove that line of code then the model looks a bit transparent once it's drawn.

    Any ideas?
    Please not that most of the code is based off tutorials and halfbaked understanding of XNA as this is our first project.

    Many thanks.


    PS: If you just happen to be a genius at this and you're just dying to help me out, I can be contacted via Live Messenger at andresfmol - AT - hotmail. ;)
  • 04-27-2008 9:43 PM In reply to

    Re: Problem between graphicsManager and GamerServices

    I don't know why this would be causing an error: you'll have to post some more code (ideally a complete project that we can run) before anyone can diagnose that.

    My first thought, though, is that you probably don't need to be resetting the graphics device at all. Most games can just set what device options they need in their constructor, and then never need to call Reset. So you can probably work around this problem just by taking out the reset call.
    XNA Framework Developer - blog - homepage
  • 04-28-2008 12:05 AM In reply to

    Re: Problem between graphicsManager and GamerServices

    Those are my thoughts exactly, but it gets pretty weird when I comment out the Reset() line of code the model becomes partially transparent. It's pretty weird, to be honest... albeit cool.

    I'm only working on the networking code (which is null thus-far). Most of the code has been written by a friend.



    Thanks.



    EDIT: Removed the code link.
  • 04-28-2008 12:58 PM In reply to

    Re: Problem between graphicsManager and GamerServices

    You should definitely not be calling GraphicsDevice.Reset every frame. The reason your 3D models aren't rendering correctly is probably because of your SpriteBatch usage. SpriteBatch messes with the render states to set up for 2D drawing. You need to explicitly set whatever states your 3D rendering needs each frame. GraphicsDevice.Reset should only ever be called when the device is lost or a change in presentation parameters is required.

     

  • 04-28-2008 3:26 PM In reply to

    Re: Problem between graphicsManager and GamerServices

    Thanks for your help, David.

    As I said my group and I are barely beginning in graphics/game programing, so our code is one big stew of stuff we've picked up through samples and tutorials.

    How do I set the necessary states for 3D rendering that you've mentioned?
    Could you point me in the right direction on where I could learn more to fix this problem? More importantly, how to get 2D and 3D graphics working together?

    Many thanks.
  • 04-28-2008 3:44 PM In reply to

    Re: Problem between graphicsManager and GamerServices

    Have a look at Shawn's article on SpriteBatch and renderstates. That should point you in the right direction.

     

  • 05-04-2008 3:22 AM In reply to

    Re: Problem between graphicsManager and GamerServices

    Sorry for not replying sooner. Uni is taking over my life right now.

    The code you sent me worked wonderfully. I only needed some minor tweaking. Thanks a lot. 
  • 05-04-2008 12:53 PM In reply to

    Re: Problem between graphicsManager and GamerServices

    No problem. Glad you got it working!
Page 1 of 1 (8 items) Previous Next
var gDomain='m.webtrends.com'; var gDcsId='dcschd84w10000w4lw9hcqmsz_8n3x'; var gTrackEvents=1; var gFpc='WT_FPC'; /*<\/scr"+"ipt>");} /*]]>*/
DCSIMG