Fixed several errors/crashes when attempting to open a window larger than

the given screen.  This is allowed in windowed mode, since the window
manager normally takes care of it.  In the case of fullscreen mode, however,
it is never allowed, and an error message is shown.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2169 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2010-11-07 16:19:26 +00:00
parent e8b080551f
commit b756f8c14a
2 changed files with 34 additions and 19 deletions

View File

@ -43,6 +43,7 @@
FrameBuffer::FrameBuffer(OSystem* osystem)
: myOSystem(osystem),
myScreen(0),
mySDLFlags(0),
myRedrawEntireFrame(true),
myUsePhosphor(false),
myPhosphorBlend(77),
@ -93,14 +94,8 @@ FBInitStatus FrameBuffer::initialize(const string& title, uInt32 width, uInt32 h
// If the WINDOWED_SUPPORT macro is defined, we treat the system as the
// former type; if not, as the latter type
// Initialize SDL flags and set fullscreen flag
// This must be done before any modes are initialized
mySDLFlags = 0;
uInt32 flags = mySDLFlags;
#ifdef WINDOWED_SUPPORT
if(myOSystem->settings().getString("fullscreen") == "1")
mySDLFlags = SDL_FULLSCREEN;
// We assume that a desktop size of at least 640x480 means that we're
// running on a 'large' system, and the window size requirements can
// be relaxed
@ -108,6 +103,16 @@ FBInitStatus FrameBuffer::initialize(const string& title, uInt32 width, uInt32 h
if(myOSystem->desktopWidth() < 640 && myOSystem->desktopHeight() < 480 &&
(myOSystem->desktopWidth() < width || myOSystem->desktopHeight() < height))
return kFailTooLarge;
if(myOSystem->settings().getString("fullscreen") == "1")
{
if(myOSystem->desktopWidth() < width || myOSystem->desktopHeight() < height)
return kFailTooLarge;
flags |= SDL_FULLSCREEN;
}
else
flags &= ~SDL_FULLSCREEN;
#else
// Make sure this mode is even possible
// We only really need to worry about it in non-windowed environments,
@ -116,6 +121,9 @@ FBInitStatus FrameBuffer::initialize(const string& title, uInt32 width, uInt32 h
return kFailTooLarge;
#endif
// Only update the actual flags if no errors were detected
mySDLFlags = flags;
// Set the available video modes for this framebuffer
setAvailableVidModes(width, height);
@ -1194,21 +1202,27 @@ void FrameBuffer::VideoModeList::print()
for(Common::Array<VideoMode>::const_iterator i = myModeList.begin();
i != myModeList.end(); ++i)
{
cerr << " Mode " << i << endl
<< " screen w = " << i->screen_w << endl
<< " screen h = " << i->screen_h << endl
<< " image x = " << i->image_x << endl
<< " image y = " << i->image_y << endl
<< " image w = " << i->image_w << endl
<< " image h = " << i->image_h << endl
<< " gfx id = " << i->gfxmode.type << endl
<< " gfx name = " << i->gfxmode.name << endl
<< " gfx desc = " << i->gfxmode.description << endl
<< " gfx zoom = " << i->gfxmode.zoom << endl
<< endl;
cerr << " Mode " << i << endl;
print(*i);
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBuffer::VideoModeList::print(const VideoMode& mode)
{
cerr << " screen w = " << mode.screen_w << endl
<< " screen h = " << mode.screen_h << endl
<< " image x = " << mode.image_x << endl
<< " image y = " << mode.image_y << endl
<< " image w = " << mode.image_w << endl
<< " image h = " << mode.image_h << endl
<< " gfx id = " << mode.gfxmode.type << endl
<< " gfx name = " << mode.gfxmode.name << endl
<< " gfx desc = " << mode.gfxmode.description << endl
<< " gfx zoom = " << mode.gfxmode.zoom << endl
<< endl;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FBSurface::box(uInt32 x, uInt32 y, uInt32 w, uInt32 h,
uInt32 colorA, uInt32 colorB)

View File

@ -546,6 +546,7 @@ class FrameBuffer
void setByGfxMode(GfxID id);
void setByGfxMode(const string& name);
void print();
static void print(const VideoMode& mode);
private:
void set(const GraphicsMode& gfxmode);