Skip to content

Commit

Permalink
Relegate some unneeded Bpp-related functions to SDL1
Browse files Browse the repository at this point in the history
  • Loading branch information
Vultraz committed Dec 31, 2015
1 parent 9e96226 commit 9ac728c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/game_launcher.cpp
Expand Up @@ -433,7 +433,9 @@ bool game_launcher::init_video()

std::cerr << "Setting mode to " << resolution.first << "x" << resolution.second << "x" << bpp << "\n";
const int res = video_.setMode(resolution.first,resolution.second,bpp,video_flags);
#if !SDL_VERSION_ATLEAST(2, 0, 0)
video_.setBpp(bpp);
#endif
if(res == 0) {
std::cerr << "Required video mode, " << resolution.first << "x"
<< resolution.second << "x" << bpp << " is not supported\n";
Expand Down
12 changes: 12 additions & 0 deletions src/preferences_display.cpp
Expand Up @@ -85,8 +85,12 @@ bool detect_video_settings(CVideo& video, std::pair<int,int>& resolution, int& b
res_list.push_back(res_t(1920, 1080));
}

#if SDL_VERSION_ATLEAST(2, 0, 0)
bpp = DefaultBPP;
#else
bpp = video.modePossible(resolution.first, resolution.second,
DefaultBPP, video_flags, true);
#endif

BOOST_REVERSE_FOREACH(const res_t &res, res_list)
{
Expand All @@ -96,8 +100,12 @@ bool detect_video_settings(CVideo& video, std::pair<int,int>& resolution, int& b
<< " is not supported; attempting " << res.first
<< 'x' << res.second << 'x' << DefaultBPP << "...\n";
resolution = res;
#if SDL_VERSION_ATLEAST(2, 0, 0)
bpp = DefaultBPP;
#else
bpp = video.modePossible(resolution.first, resolution.second,
DefaultBPP, video_flags);
#endif
}

return bpp != 0;
Expand Down Expand Up @@ -158,7 +166,11 @@ bool set_resolution(CVideo& video
}

const int flags = fullscreen() ? SDL_FULLSCREEN : 0;
#if SDL_VERSION_ATLEAST(2, 0, 0)
int bpp = 32;
#else
int bpp = video.bppForMode(width, height, flags);
#endif

if(bpp != 0) {
//video.setMode(width, height, bpp, flags);
Expand Down
4 changes: 4 additions & 0 deletions src/video.cpp
Expand Up @@ -511,6 +511,7 @@ void CVideo::make_test_fake(const unsigned width,

}

#if !SDL_VERSION_ATLEAST(2, 0, 0)
int CVideo::bppForMode( int x, int y, int flags)
{
int test_values[3] = {getBpp(), 32, 16};
Expand All @@ -522,6 +523,7 @@ int CVideo::bppForMode( int x, int y, int flags)

return 0;
}
#endif

int CVideo::modePossible( int x, int y, int bits_per_pixel, int flags, bool current_screen_optimal )
{
Expand Down Expand Up @@ -847,6 +849,7 @@ surface& CVideo::getSurface()

bool CVideo::isFullScreen() const { return fullScreen; }

#if !SDL_VERSION_ATLEAST(2, 0, 0)
void CVideo::setBpp( int bpp )
{
bpp_ = bpp;
Expand All @@ -856,6 +859,7 @@ int CVideo::getBpp()
{
return bpp_;
}
#endif

int CVideo::set_help_string(const std::string& str)
{
Expand Down
2 changes: 2 additions & 0 deletions src/video.hpp
Expand Up @@ -129,8 +129,10 @@ class CVideo : private boost::noncopyable {
};

//functions to allow changing video modes when 16BPP is emulated
#if !SDL_VERSION_ATLEAST(2, 0, 0)
void setBpp( int bpp );
int getBpp();
#endif

void make_fake();
/**
Expand Down

0 comments on commit 9ac728c

Please sign in to comment.