Skip to main content
gamedev.net
🔒 Locked

Change Resolutions

Started by atcdevil 1 reply 350+ views
Original Post
atcdevil
atcdevil
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
S1CA
S1CA
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
Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site
atcdevil
atcdevil
Hey thanks a lot, that''s just what I needed to know, I already have it so alt tab works properly so it shouldn''t be too bad to get this working, Thanks again.

- Andrew

Topic Locked

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

Sign in to reply to this topic.