Jump to content
  • Advertisement
Sign in to follow this  

Preserving a mesh when resetting the device:

This topic is 4158 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 creating my mesh using the MeshFlags.Managed and I'm resetting as many of the states as I can when the device is reset. I've put a message box in the OnResetDevice function so I've confirmed my device does get reset when I resize the window. My mesh and my textures stay pretty much intact other than a bit of distortion and the image not resizing to fit in the new window. I'm recalculating the aspect ratio and camera positions every frame, and the distortion sometimes corrects itself when I resize a second time. However other times the image stays the same size and gets clipped to fit the new window size. I'd like to try to keep my application running as fast as possible my avoiding reloading my meshes, but I can't really see any other options. The best I can come up with is saving the mesh to a GraphiscStream immediately after I load it, so there's always a copy in memory in case the device is lost. Would this be the best way to keep my program's speed up or are there other ways I could try? I'd prefer not to have to reload the file itself because it might have changed, been deleted or in use by another program etc.

Share this post

Link to post
Share on other sites
From your description, it sounds like the mesh is preserved, and you don't need to do anything. There's some issue with your transforms or viewport definitions, but it's hard to understand exactly from your description (what do you mean by "distortion"?)

Share this post

Link to post
Share on other sites
Here's some screenshots:


I moved the horizontal splitter down, then back up again and that's the effect I got, even though the matrices are recalculated every frame using this function:

        public void Update()
Control xRenderWindow = m_xDevice.CreationParameters.FocusWindow;
m_xDevice.Transform.Projection = Matrix.PerspectiveFovLH(
(float)xRenderWindow.Width / (float)xRenderWindow.Height,
m_xDevice.Transform.View = Matrix.LookAtLH(

The only variables used here that change when resizing the render window are the width and height and those are supposed to change anyway.

EDIT: The problem also corrects itself when I minimise and maximise again. I may have been getting mixed up with an earlier problem with the aspect ration when I said there was distortion. Also, I'm using the multi threaded flag so the window will render properly when I have a dialog or messagebox open. I don't know if that would have anything to do with my problem.

EDIT 2: The problem in those screenshots seems to only happen when I move the horizontal splitter up or the vertical splitter to the right. I've noticed that if I show a message box in the Resize event, the problem fixes when I close the message box.
Could this be due to the render panel losing focus? I've tried calling refresh when the panel gets resized. This partially fixes the problem, but then the resolution for my image is reverly reduced until I move the splitter again. I only need to move it the slightest distance for the image to correct itself though.
I've also tried a a couple of flags in the Invalidate function. I'm having to call Invalidate on the TopLevelControl otherwise my menu bar and other controls don't get rendered right away. If I try using the invalidate children flag in that, the resizing problem is cured, but the problem with the other controls comes back.
So, I'm fairly sure the problem is to do with invalidating or updating the window somehow, but I don't know what the proper way to fix this is. Does any of what I've desccribed sound familiar to anyone?

[Edited by - CodeReaver on July 27, 2007 5:05:22 PM]

Share this post

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

  • Advertisement

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!