Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Help! How to find out my (3d, sprites, sounds) memory is out?

Author
Message
Alex_Peres
AGK Master
15
Years of Service
User Offline
Joined: 13th May 2009
Location: The Milky Way Galaxy
Posted: 10th Jul 2009 19:58
When I use Alt-Tab (in WindowOff mode) or when I use Ctrl-Alt-Del (in Vista) my game memory become crear...

How to avoid this?

Please don't suggest not use dbSetWindowOff or Vista.
jezza
16
Years of Service
User Offline
Joined: 8th Mar 2008
Location: Bham, UK
Posted: 11th Jul 2009 11:16
'crear'...?

Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 11th Jul 2009 12:59 Edited at: 11th Jul 2009 13:09
Instead of dbSetWindowOff, use dbSetWindowLayout to remove the title bar and window border. (Look up parameters in the help, but 0,0,0 should work.) Used together with dbMaximizeWindow or dbSetWindowPosition, the visual effect is the same, and you can Alt-Tab out of it and back without losing the content. It won't solve losing the graphic context with Ctrl Alt Del, though.

EDIT: You can also experiment with the dbScreenInvalid command to detect when such an event happens. (I don't know if it can detect Ctrl Alt Del or only Alt Tab, never tried.) Quote from another thread on this forum:

"DirectX requires you to reload all resources when switching screens or resolutions. ... If the SCREEN INVALID() returns one you call a function that replaces all loaded resources (textures, models, sounds, music) with valid ones as the previously loaded one are now corrupted."
Alex_Peres
AGK Master
15
Years of Service
User Offline
Joined: 13th May 2009
Location: The Milky Way Galaxy
Posted: 11th Jul 2009 15:14
Thanks for SCREEN INVALID()!

Maybe is there any way to save all resources into the memory and after take it back?

How the other games are working (I think without that problem!)?
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 12th Jul 2009 05:29
The easiest way around it would be to put all of your asset loading inside a function, that can be called to reload everything if the dbScreenInvalid() returns 1.

You would need to think about the problem a little more though to be able to get completely around it... the above, while restoring the objects, images etc that are lost, it wont put them back where you had them or do to them what was already done... SO, you would need to be able to catch the system keys(setting up your own message pump with peekmessage would probably be the best way to catch them before their message is processed) and store a whole heap of data relating to the assets inside your program, before the ctrl-alt-del message is processed.

If you want to dig around a little in directX, im pretty sure that there are functions to deal with specifically lost devices or changing the screen resolution, resolution changes work differently to alt-tabbing i think. You should be able to save the buffer from the directX device when alt tabbing and restore it without having to reload stuff... resolution changing though usually means destroying the existing DX surface and creating a new one at the new resolution, so all media etc will be lost when that happens and need to be reloaded.

If it ain't broke.... DONT FIX IT !!!
Alex_Peres
AGK Master
15
Years of Service
User Offline
Joined: 13th May 2009
Location: The Milky Way Galaxy
Posted: 12th Jul 2009 18:18
dbScreenInvalid() work only when my window out of focus!
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 12th Jul 2009 19:34
thats right, the window will lose focus when you alt tab or press ctrl-alt-delete unless you are telling it not to with windows messages... Im not sure how that would be affected in full screen mode, if the message would be the same or not. If screen invalid only works when the window loses focus, I would assume that its catching windows messages itself to set its value, but I dont know exactly how the screen invalid function works so that may be wrong.

If it ain't broke.... DONT FIX IT !!!
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 12th Jul 2009 20:24 Edited at: 12th Jul 2009 20:24
Why MUST the application be fullscreen exclusive? It will behave identically if you remove the titlebar and border, and then maximize the window, and you won't have to worry about any of this

The only difference is that this way means that it will work correctly on laptop screens, and you won't get any strange effects when changing between the game window and other windows.

Login to post a reply

Server time is: 2024-11-25 06:27:50
Your offset time is: 2024-11-25 06:27:50