XNA Game Development Forums
2012/05/18 07:24:16 *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Search Calendar Login Register  
Pages: [1]
  Print  
Author Topic: Minimize problem - app crash  (Read 2241 times)
nicknz
Newbie
*
Offline Offline

Posts: 6


View Profile
« on: 2007/04/19 18:22:11 »


Hello!

I have done all the tutorials and they are great. I have a problem, when I run the demo app in window mode and minimize the windrow the application crashes.

Is there a way to prevent the bacbuffer from becoming 0x0 in size?

Thanks

Nick
Logged
Tiago
Newbie
*
Offline Offline

Posts: 42


View Profile
« Reply #1 on: 2007/04/20 01:00:28 »

do you know what call is making the demo crash?
Logged
Tiago
Newbie
*
Offline Offline

Posts: 42


View Profile
« Reply #2 on: 2007/04/20 01:33:01 »

never mind, found it.

just for reference this is the function that throws the exception:

Code:
void Window_ClientSizeChanged(object sender, System.EventArgs e)
{
    myGraphics.PreferredBackBufferWidth = Window.ClientBounds.Width;
    myGraphics.PreferredBackBufferHeight = Window.ClientBounds.Height;

    XCameraManager.UpdateViewports(myGraphics.GraphicsDevice.Viewport);
}

when the window is minimized Window.ClientBounds.Width and Window.ClientBounds.Height are 0. you can solve that by adding 1 line (well...3) like this:

Code:
void Window_ClientSizeChanged(object sender, System.EventArgs e)
{
    if (Window.ClientBounds.Width > 0 && Window.ClientBounds.Height > 0)
    {
        myGraphics.PreferredBackBufferWidth = Window.ClientBounds.Width;
        myGraphics.PreferredBackBufferHeight = Window.ClientBounds.Height;

        XCameraManager.UpdateViewports(myGraphics.GraphicsDevice.Viewport);
    }
}

i noticed theres another problem tho. if you resize your window and make it as small as possible you'll get this:

"Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

from a shader object trying to set a parameter, in my case the World matrix. I'm not exactly sure why this happens but i guess it can be avoided by forcing a min height and width when resizing your window.

if someone knows how to do that please tell cause since XNA only exposes ClientSizeChanged and ScreenDeviceName on the window object so you can only react to the change after the resizing is done and not at each frame of resizing.

i get the same error when i try to move the window to another monitor (im working with dual monitors), and this time it freezes all applications, only way to get out of the freeze is by shuting down the app from task manager, any help on this would be great too

Logged
nicknz
Newbie
*
Offline Offline

Posts: 6


View Profile
« Reply #3 on: 2007/04/20 11:47:07 »

Thanks Tiago, it works fine with the minimize now. I also work with dual monitor and had the same problem as you when trying to move the window to another monitor. Maybe the device is lost and it needs to be rebuild. Does it is possible to detect when the device is lost on XNA?
Logged
Suzume
Newbie
*
Offline Offline

Posts: 9


View Profile
« Reply #4 on: 2007/08/02 04:32:10 »

Had the same problems like you. Figured out a solution.
You have to check for a change of the GraphicsDevice and to inform the camera about this change. Furthermore you need to add an overridden UnloadGraphicsContent() function to HMGame.cs.

Here's my code:

Code:
// in HMGame.cs - constructor
public HMGame()
{
    //existing code as in previous post by Tiago

    // new event handler
    this.Window.ScreenDeviceNameChanged += new System.EventHandler(Window_ScreenDeviceNameChanged);
}

// function for the new event handler
private void Window_ScreenDeviceNameChanged(object sender, System.EventArgs e)
{
    // this updates the viewports of all cameras and hands the viewport of the new GraphicsDevice over to them
    // naming of member variables may vary in your projects so keep that in mind
    HMCameraManager.UpdateViewports(this.graphicsMng.GraphicsDevice.Viewport);
}

// dealing with the content
protected override void UnloadGraphicsContent(bool unloadAllContent)
{
    // since the HMEngine only uses one instance of the ContentManager that is passed over to all
    // objects of the game we have to worry only about unloading this one when windows tells the app to do so
    this.contentMng.Unload();
    base.UnloadGraphicsContent(unloadAllContent);
}
« Last Edit: 2007/08/02 04:33:58 by Suzume » Logged
Pages: [1]
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
Using XNA in a windowed app, like the SceneEditor Hazy Mind XNA Engine Extrakun 2 2047 Last post 2006/11/09 05:46:05
by joey
Got a problem with an .x file Hazy Mind XNA Engine bobbie_dache 8 2784 Last post 2007/01/16 12:26:30
by bobbie_dache
Animations! But one problem... Hazy Mind XNA Engine EclipsE 2 1413 Last post 2007/04/12 02:42:27
by EclipsE
tutorial 4 problem Hazy Mind 3D Engine precious roy 3 2495 Last post 2007/08/03 12:24:26
by mikeschuld
Interface problem. Help!! General Discussion XNASorcerer 5 2111 Last post 2007/05/09 09:46:36
by CarlosFreitas
ObjectManagers problem Hazy Mind XNA Engine Jonotron 1 1339 Last post 2007/08/03 12:29:19
by mikeschuld
Camera problem Hazy Mind XNA Engine Montynis 2 1685 Last post 2007/08/02 09:54:14
by Montynis
Problem with the pick Hazy Mind 3D Engine Zandman26 0 1420 Last post 2007/08/06 15:04:06
by Zandman26
Powered by MySQL Powered by PHP Powered by SMF 1.1.12 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 0.113 seconds with 18 queries.