When writing the X11 (linux) implementation there was a problem with X11 defining a "Display" type and we also have a Display class in the engine. So to fix that problem and minimize the risk for running into other name conflicts. We move everything from global namespace.
58 lines
No EOL
1,021 B
C++
58 lines
No EOL
1,021 B
C++
|
|
#include <Spectre/Display/DisplayMode.h>
|
|
#include <Platform/PlatformMisc.h>
|
|
#include <algorithm>
|
|
|
|
namespace sp {
|
|
|
|
struct DisplayModeCmp
|
|
{
|
|
inline bool operator() (const DisplayMode& a, const DisplayMode& b)
|
|
{
|
|
if (a.bpp == b.bpp) {
|
|
if (a.width == b.width) {
|
|
return a.height > b.height;
|
|
}
|
|
return a.width > b.width;
|
|
}
|
|
return a.bpp > b.bpp;
|
|
}
|
|
};
|
|
|
|
DisplayMode::DisplayMode() :
|
|
width (0),
|
|
height (0),
|
|
bpp (32)
|
|
{
|
|
}
|
|
|
|
DisplayMode::DisplayMode(unsigned int width, unsigned int height, unsigned int bpp) :
|
|
width (width),
|
|
height (height),
|
|
bpp (bpp)
|
|
{
|
|
}
|
|
|
|
std::vector<DisplayMode> DisplayMode::getFullscreenModes()
|
|
{
|
|
static std::vector<DisplayMode> modes;
|
|
|
|
if (modes.size() < 1) {
|
|
|
|
PlatformMisc::GetDisplayModes(modes);
|
|
|
|
// Sort.
|
|
std::sort(modes.begin(), modes.end(), DisplayModeCmp());
|
|
|
|
// remove duplicates
|
|
modes.erase(std::unique(modes.begin(), modes.end()), modes.end());
|
|
}
|
|
return modes;
|
|
}
|
|
|
|
DisplayMode DisplayMode::getDesktopMode()
|
|
{
|
|
return PlatformMisc::GetDesktopMode();
|
|
}
|
|
|
|
} // namespace sp
|