#include "xna/xna-dx.hpp" #include "xna/graphics/displaymode.hpp" namespace xna { size_t DisplayModeCollection::SurfaceCount(SurfaceFormat format) const { size_t counter = 0; for (size_t i = 0; i < DisplayModes.size(); ++i) { if (DisplayModes[i]->Format() == format) { ++counter; } } return counter; } std::vector> DisplayModeCollection::Query(SurfaceFormat format) const { const auto count = SurfaceCount(format); size_t index = 0; std::vector> modes(count); for (size_t i = 0; i < DisplayModes.size(); ++i) { if (DisplayModes[i]->Format() == format) { modes[index] = DisplayModes[i]; ++index; } if (index == count) break; } return modes; } sptr DisplayModeCollection::Query(SurfaceFormat format, Uint width, Uint height) const { sptr matched = nullptr; for (size_t i = 0; i < DisplayModes.size(); ++i) { const auto& mode = DisplayModes[i]; if (mode->Format() == format && mode->Width() == width && mode->Height() == height) { return DisplayModes[i]; } else if(mode->Format() == format && mode->Width() == width) { matched = mode; } } return matched; } }