Jump to content
  • Advertisement
Sign in to follow this  
theStormWeaver

Graphics Device that just won't die

This topic is 4155 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm using C# and DirectX 9.0c Here's whats happening: I use a standard windows form as an opening menu where you can choose which level to play and what your background music is. When you win/lose the game window closes and the frmMain regains focus. The second time the game is run and closes it produces an error, a null reference exception to the graphics device at the beginning of the scene rendering. My EndGame method (which is called when the player runs out of lives or wins the game) looks like this:
private void EndGame(string message)
        {
            try
            {
                BreakOut.frmMain.theMenuScreen.setLabel(message);
                bgSound.Stop();
                this.Hide();
                BreakOut.frmMain.theMenuScreen.Show();
                BreakOut.frmMain.theMenuScreen.Focus();
                graphicsDevice.Dispose();
            }//end try

            catch(Exception e)
            {
                messageboxOK(e.Message);
            }//end catch
        }//end EndGame

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • 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!