Fixed a bug with --bpp setting being ignored upon resolution change.

Forcing --bpp still breaks the video mode selection dialog.
This commit is contained in:
Karol Nowak 2011-06-15 20:54:03 +00:00
parent 2cf4902eb5
commit 437ee1b853
3 changed files with 21 additions and 11 deletions

View file

@ -104,11 +104,8 @@ void set_fullscreen(CVideo& video, const bool ison)
const std::pair<int,int>& res = resolution();
if(video.isFullScreen() != ison) {
const int flags = ison ? FULL_SCREEN : 0;
int bpp = video.modePossible(res.first,res.second,32,flags);
if (bpp <= 0) {
bpp = video.modePossible(res.first,res.second,16,flags);
}
int bpp = video.bppForMode(res.first, res.second, flags);
if(bpp > 0) {
video.setMode(res.first,res.second,bpp,flags);
if(disp) {
@ -168,10 +165,8 @@ bool set_resolution(CVideo& video
}
const int flags = fullscreen() ? FULL_SCREEN : 0;
int bpp = video.modePossible(width, height, 32, flags);
if(bpp == 0) {
bpp = video.modePossible(width, height, 16, flags);
}
int bpp = video.bppForMode(width, height, flags);
if(bpp != 0) {
video.setMode(width, height, bpp, flags);
@ -180,6 +175,7 @@ bool set_resolution(CVideo& video
}
} else {
// grzywacz: is this even true?
gui2::show_transient_message(video,"",_("The video mode could not be changed. Your window manager must be set to 16 bits per pixel to run the game in windowed mode. Your display must support 1024x768x16 to run the game full screen."));
return false;
}
@ -455,7 +451,7 @@ bool show_video_mode_dialog(display& disp)
std::cerr << "Can support any video mode\n";
// SDL says that all modes are possible, so it's OK to use a
// hardcoded list here. Include tiny and small gui since they
// will be filter out later if not needed.
// will be filtered out later if not needed.
static const SDL_Rect scr_modes[] = {
{ 0, 0, 320, 240 },
{ 0, 0, 640, 480 },

View file

@ -351,6 +351,18 @@ void CVideo::make_test_fake(const unsigned width,
}
int CVideo::bppForMode( int x, int y, int flags)
{
int test_values[3] = {getBpp(), 32, 16};
foreach(int &bpp, test_values) {
if(modePossible(x, y, bpp, flags) > 0) {
return bpp;
}
}
return 0;
}
int CVideo::modePossible( int x, int y, int bits_per_pixel, int flags, bool current_screen_optimal )
{

View file

@ -46,11 +46,13 @@ class CVideo : private boost::noncopyable {
FAKE,
FAKE_TEST
};
CVideo(FAKE_TYPES type = NO_FAKE);
~CVideo();
int modePossible( int x, int y, int bits_per_pixel, int flags ,bool current_screen_optimal=false);
int bppForMode( int x, int y, int flags);
int modePossible( int x, int y, int bits_per_pixel, int flags, bool current_screen_optimal=false);
int setMode( int x, int y, int bits_per_pixel, int flags );
//did the mode change, since the last call to the modeChanged() method?