本文整理汇总了C++中BScreen::GetModeList方法的典型用法代码示例。如果您正苦于以下问题:C++ BScreen::GetModeList方法的具体用法?C++ BScreen::GetModeList怎么用?C++ BScreen::GetModeList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BScreen
的用法示例。
在下文中一共展示了BScreen::GetModeList方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sizeof
display_mode*
GlutGameMode::_FindMatchingMode()
{
if (fWidth == -1 && fHeight == -1 && fPixelDepth == -1
&& fRefreshRate == -1)
// nothing to match!
return NULL;
if (!fModesList) {
// Lazy retrieval of supported modes...
BScreen screen;
if (screen.GetModeList(&fModesList, &fModesCount) == B_OK) {
// sort modes in decrease order (resolution, depth, frequency)
qsort(fModesList, fModesCount, sizeof(display_mode), _CompareModes);
} else {
// bad luck, no modes can be retrieved!
fModesList = NULL;
fModesCount = 0;
}
}
if (!fModesList)
return NULL;
float bestRefreshDiff = 999999;
int bestMode = -1;
for (uint32 i =0; i < fModesCount; i++) {
printf("[%" B_PRId32 "]: %d x %d, %d Bpp, %d Hz\n", i,
fModesList[i].virtual_width, fModesList[i].virtual_height,
_GetModePixelDepth(&fModesList[i]),
_GetModeRefreshRate(&fModesList[i]));
if (fWidth > 0 && fModesList[i].virtual_width != fWidth)
continue;
if (fHeight > 0 && fModesList[i].virtual_height != fHeight)
continue;
if (fPixelDepth > 0
&& _GetModePixelDepth(&fModesList[i]) != fPixelDepth)
continue;
float refreshDiff = fabs(_GetModeRefreshRate(&fModesList[i])
- fRefreshRate);
if (fRefreshRate > 0 && (refreshDiff > 0.006 * fRefreshRate)) {
// not exactly the same, but maybe the best similar mode so far?
if (refreshDiff < bestRefreshDiff) {
bestRefreshDiff = refreshDiff;
bestMode = i;
}
continue;
}
// Hey, this one match everything!
return &fModesList[i];
}
if (bestMode == -1)
return NULL;
return &fModesList[bestMode];
}