本文整理汇总了C++中CVideo::modePossible方法的典型用法代码示例。如果您正苦于以下问题:C++ CVideo::modePossible方法的具体用法?C++ CVideo::modePossible怎么用?C++ CVideo::modePossible使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CVideo
的用法示例。
在下文中一共展示了CVideo::modePossible方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: set_fullscreen
void set_fullscreen(CVideo& video, const bool ison)
{
_set_fullscreen(ison);
const std::pair<int,int>& res = resolution();
if(video.isFullScreen() != ison) {
const int flags = ison ? FULL_SCREEN : 0;
int bpp = video.bppForMode(res.first, res.second, flags);
if(bpp > 0) {
video.setMode(res.first,res.second,bpp,flags);
if(disp) {
disp->redraw_everything();
}
} else {
int tmp_flags = flags;
std::pair<int,int> tmp_res;
if(detect_video_settings(video, tmp_res, bpp, tmp_flags)) {
set_resolution(video, tmp_res.first, tmp_res.second);
// TODO: see if below line is actually needed, possibly for displays that only support 16 bbp
} else if(video.modePossible(1024,768,16,flags)) {
set_resolution(video, 1024, 768);
} else {
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."));
}
// We reinit color cursors, because SDL on Mac seems to forget the SDL_Cursor
set_color_cursors(preferences::get("color_cursors", false));
}
}
}
示例2: detect_video_settings
bool detect_video_settings(CVideo& video, std::pair<int,int>& resolution, int& bpp, int& video_flags)
{
video_flags = fullscreen() ? FULL_SCREEN : 0;
resolution = preferences::resolution();
int DefaultBPP = 24;
const SDL_VideoInfo* const video_info = SDL_GetVideoInfo();
if(video_info != NULL && video_info->vfmt != NULL) {
DefaultBPP = video_info->vfmt->BitsPerPixel;
}
std::cerr << "Checking video mode: " << resolution.first << 'x'
<< resolution.second << 'x' << DefaultBPP << "...\n";
typedef std::pair<int, int> res_t;
std::vector<res_t> res_list;
if(fullscreen()){
res_list.push_back(res_t(2560, 1600));
res_list.push_back(res_t(1920, 1200));
res_list.push_back(res_t(1920, 1080));
res_list.push_back(res_t(1680, 1050));
res_list.push_back(res_t(1440, 900));
res_list.push_back(res_t(1360, 768));
}
res_list.push_back(res_t(1024, 768));
bpp = video.modePossible(resolution.first, resolution.second,
DefaultBPP, video_flags, true);
BOOST_FOREACH(const res_t &res, res_list)
{
if (bpp != 0) break;
std::cerr << "Video mode " << resolution.first << 'x'
<< resolution.second << 'x' << DefaultBPP
<< " is not supported; attempting " << res.first
<< 'x' << res.second << 'x' << DefaultBPP << "...\n";
resolution = res;
bpp = video.modePossible(resolution.first, resolution.second,
DefaultBPP, video_flags);
}
preferences::set_resolution(resolution);
return bpp != 0;
}