Archived

This topic is now archived and is closed to further replies.

atcdevil

Change Resolutions

Recommended Posts

I''m trying to make it so I can change the resolution after direct draw is initialized, and all the surfaces for my game are loaded. I do know how to use the function SetDisplayMode. I tried just calling that to change resolutions but my screen goes black. So what do I need to do, release all the surfaces (including the primary surface and backbuffer) and reload all of my images onto new surfaces? I don''t really know what even happens to all of my surfaces when I call SetDisplayMode. Thanks for the help. - Andrew

Share this post


Link to post
Share on other sites
Yep!

Releasing before the change and recreating and reloading after the change is a good idea.

When you change screen mode, the new mode uses a different amount of memory, this usually causes the video card to evict all surfaces from video memory and start again. This is what happens when a surface becomes lost. And why surfaces become lost when you Alt-Tab, particularly to a more memory intensive desktop.

You could use Restore() or RestoreAllSurfaces() and then reload the graphics, but often it''s more robust and simpler to Release() the surfcaes and recreate. Your code no doubt has functions which it''s using to create and load data into surfaces - with a bit of careful thought when planning the code it''s simple to do.

If you''re retrofitting this into the code, a simple way to do it is to have a "surface structure", something like:

struct
{
LPDIRECTDRAWSURFACEx pSurface;
int width, height;
blah formatinfo;
char szFullPathNameForSourceGraphics[MAX_PATH];
}

Then hold a list of those and tack that onto the loading and release code - that way you should have a list of all surfaces currently loaded and the pathnames of where to reload their graphics from.


--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

Share this post


Link to post
Share on other sites