Skip to main content
gamedev.net
🔒 Locked

Transparent Device Release

Started by Raloth 2 replies 900+ views
Original Post
Raloth
Raloth
I am looking for a way to "transparently" release my device. It's a little hard to explain what I mean, but I'll try anyway. I have the game menu all nicely rendered. When I start up the game itself, I dynamically load another dll that contains information about how the map will be run - this lets me do all the scripting I could ever dream of. However, this is C#, and I don't have the ability to directly unload an assembly once I load it. I need to create a separate application domain and unload that. Switching between domains is not the most efficient operation, and normally the rendering core would be outside of it. I want to move it inside. That's all fine and good. The problem comes when the game ends and I go back to the menu screen. I want to unload the map assembly so they don't start piling up as the person plays different games. This requires me to unload all of the assemblies in the application domain, including the rendering core. The rendering core has my device object, which means I need to release that. If the user is in fullscreen there will be an awkward flicker as the display mode is returned to the original when the device is released, and then set back when it's recreated to display the menu. I need a way to 1) keep fullscreen active between the device release and recreation, or 2) move the graphics object into the appdomain and then out again. Currently I can't think of a good way to do either. I don't think #2 is possible. Even if new app domain had a reference to the graphics object, it would still jump outside any time a function was called. When the graphics core goes to render, it jumps inside the app domain...not good at all. I'll keep the idea open just in case, but I think #1 would be the simplest. So, does anyone know a way to preserve the fullscreen while destroying the device?
____________________________________________________________AAAAA: American Association Against Adobe AcrobatYou know you hate PDFs...
Raloth
Raloth
*kapow*
____________________________________________________________AAAAA: American Association Against Adobe AcrobatYou know you hate PDFs...
Drew_Benton
Drew_Benton
Quote:
Original post by Raloth
*kapow*


[lol][smile] Ok I really have not ever worked with DX, but here's a theory idea. What if you made some temporary device context that was the same the map ran in, but you did not 'activate' it. When you need to release the current one, you could activate the temporary, and switch to it. I do not know if this is possible under DX, but if it was, you would not have thet 'flicker' as the screen changes resolutions because you are now in a similar device. Just an idea, don't know if it'll help any.
Evil Steve
Evil Steve
I know next to nothing about C#, but this should hopefully be of some help anyway...

Internally, D3D calls ChangeDisplaySettings to change the screen resolution. You could probably do this before creating your device, which would remove the flicker (notice how you don't get a flicker if you create a device with a backbuffer the same size as the current screen resolution?).
In C++ the function is ChangeDisplaySettings, as I said, It'll probably have the same name in C# (it's part of the GDI, so look around there).
You could call ChangeDisplaySettings() and create your device, and then release the device and re-create it without any flickering.

However, this seems like a bad idea. You really shouldn't need to destroy and recreate your device, there's probably another way. But I don't know what that is [smile] So I suppose this'll be alright for now...

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.