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.

DarkBASIC Professional Discussion / image and display mode change interaction

Author
Message
krfsim
22
Years of Service
User Offline
Joined: 26th Aug 2003
Location:
Posted: 26th Aug 2003 17:52
I've created an application that runs a UI in 1024x768x16 exclusive mode and launches games in 512x384x16 exclusive mode. The UI requires a great number of sprites and images which I'd like to keep resident in memory while executing the game. This would allow a quick return to the UI after the game without requiring the UI to be reloaded. The problem I'm having is when I switch display modes from the UI to the game and back again, the images created for the UI no longer exist. I'm not deleting these assets or mistakenly using the wrong image number. Do the objects and images automatically get deleted when the display mode is changed? I'd really like to use this strategy. Any suggestions? Thanks.
OSX Using Happy Dude
22
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 26th Aug 2003 18:54 Edited at: 26th Aug 2003 18:55
Its a fault of DirectX (it wasn't really designed... to task-switch and allow mode change). I've got a routine in the code section (somewhere - I put it on a while ago) that lets you load graphics/music/sound etc from a string - all you would need to do is use this routine to load all your data, and, in a stroke you've taken care of all the re-loading (and loading).


krfsim
22
Years of Service
User Offline
Joined: 26th Aug 2003
Location:
Posted: 26th Aug 2003 20:02
Thanks for the information. My problem with reloading the images is not necessarily the file access time and parsing, but loading the sprite and animation images themselves. I use over a combination of 200 sprites with unique images, animation, background bitmaps, and other Windows-like gizmos that require the use of the load bitmap and get image commands which really slows things down.
OSX Using Happy Dude
22
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 26th Aug 2003 20:42
In that case you've got two choices - make sure the user cant task swap/change mode or display a message whilst everything is re-done.


krfsim
22
Years of Service
User Offline
Joined: 26th Aug 2003
Location:
Posted: 4th Sep 2003 23:42
Does this Direct X command have the potential to solve my problem and allow the original surfaces to be restored?

IDirectDrawSurface::Restore
The Restore method restores a surface that has been lost—that is, the surface memory associated with the DirectDrawSurface object has been freed. Surfaces can be lost because the mode of the display card was changed or because an application received exclusive access to the display card and freed all of the surface memory currently allocated on the video card. When a DirectDrawSurface object loses its surface memory, many methods will return DDERR_SURFACELOST and perform no other function. Restore will reallocate surface memory and reattach it to the DirectDrawSurface object.

A single call to Restore will restore a DirectDrawSurface's associated implicit surfaces. An attempt to restore an implicitly created surface will result in an error. Restore will not work across explicit attachments created using the AddAttachedSurface method; each of these surfaces must be restored individually.

Syntax

HRESULT Restore();
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 5th Sep 2003 00:05
It restores the DirectX surfaces, but not the images they held.
OSX Using Happy Dude
22
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 5th Sep 2003 01:16
The easiest way is to stick everything you want to load in a string, and then use my LoadFiles routine to load everything in one go. The code is in the Code Snippet (somewhere), and also in the Code Projects (when you can view them).

Then you can easily load everything at start-up and after mode change. You will have to delete objects etc yourself manually, but thats no real problem.


Avatar & Logo by Indi. Come to the UK DBPro Convention in Chichester
CloseToPerfect
23
Years of Service
User Offline
Joined: 20th Dec 2002
Location: United States
Posted: 5th Sep 2003 08:35
I still don't understand why this does this with images, because they are stored in system ram not viedo ram. I understand why it happens with bitmaps and models, they are stored in video ram. The system ram should be safe?
It's a shame DBP doesn't let you load you images to a pointer, then you probably not have this problem.

CTP
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 5th Sep 2003 10:11
I suppose if it was too much of a problem you could convert your images etc to a memblock then copy to allocated memory somewhere, then just reverse the process for reloading.

I guess that this is mainly the reason that MS say you should use a windowed mode.
OSX Using Happy Dude
22
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 5th Sep 2003 10:35
Unless I read the DX SDK wrongly, apparently it can happen at any time, even in window mode - swapping windows etc can do it, although when I was doing a sprite DLL years ago, there was less chance of losing everything in window mode.


Avatar & Logo by Indi. Come to the UK DBPro Convention in Chichester

Login to post a reply

Server time is: 2026-07-23 10:48:15
Your offset time is: 2026-07-23 10:48:15