2024-07-13 22:55:36 -03:00
|
|
|
#include "xna/xna-dx.hpp"
|
2024-06-03 21:55:09 -03:00
|
|
|
#include "xna/graphics/displaymode.hpp"
|
2024-04-22 11:22:18 -03:00
|
|
|
|
|
|
|
namespace xna {
|
2024-04-23 16:11:17 -03:00
|
|
|
size_t DisplayModeCollection::SurfaceCount(SurfaceFormat format) const
|
2024-04-22 11:22:18 -03:00
|
|
|
{
|
|
|
|
size_t counter = 0;
|
|
|
|
|
2024-05-20 11:51:32 -03:00
|
|
|
for (size_t i = 0; i < DisplayModes.size(); ++i) {
|
2024-07-19 23:21:25 -03:00
|
|
|
if (DisplayModes[i]->Format() == format) {
|
2024-04-22 11:22:18 -03:00
|
|
|
++counter;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-04-23 16:11:17 -03:00
|
|
|
return counter;
|
2024-04-22 11:22:18 -03:00
|
|
|
}
|
|
|
|
|
2024-04-26 11:35:59 -03:00
|
|
|
std::vector<sptr<DisplayMode>> DisplayModeCollection::Query(SurfaceFormat format) const
|
2024-04-22 11:22:18 -03:00
|
|
|
{
|
2024-04-23 16:11:17 -03:00
|
|
|
const auto count = SurfaceCount(format);
|
|
|
|
|
|
|
|
size_t index = 0;
|
2024-04-26 11:35:59 -03:00
|
|
|
std::vector<sptr<DisplayMode>> modes(count);
|
2024-04-22 11:22:18 -03:00
|
|
|
|
2024-05-20 11:51:32 -03:00
|
|
|
for (size_t i = 0; i < DisplayModes.size(); ++i) {
|
2024-07-19 23:21:25 -03:00
|
|
|
if (DisplayModes[i]->Format() == format) {
|
2024-05-20 11:51:32 -03:00
|
|
|
modes[index] = DisplayModes[i];
|
2024-04-23 16:11:17 -03:00
|
|
|
++index;
|
2024-04-22 11:22:18 -03:00
|
|
|
}
|
2024-04-23 16:11:17 -03:00
|
|
|
|
|
|
|
if (index == count)
|
|
|
|
break;
|
2024-04-22 11:22:18 -03:00
|
|
|
}
|
|
|
|
|
2024-04-23 16:11:17 -03:00
|
|
|
return modes;
|
|
|
|
}
|
|
|
|
|
2024-04-26 11:35:59 -03:00
|
|
|
sptr<DisplayMode> DisplayModeCollection::Query(SurfaceFormat format, Uint width, Uint height) const
|
2024-04-23 16:11:17 -03:00
|
|
|
{
|
2024-04-26 11:35:59 -03:00
|
|
|
sptr<DisplayMode> matched = nullptr;
|
2024-04-23 16:11:17 -03:00
|
|
|
|
2024-05-20 11:51:32 -03:00
|
|
|
for (size_t i = 0; i < DisplayModes.size(); ++i) {
|
|
|
|
const auto& mode = DisplayModes[i];
|
2024-04-23 16:11:17 -03:00
|
|
|
|
2024-07-19 23:21:25 -03:00
|
|
|
if (mode->Format() == format && mode->Width() == width && mode->Height() == height) {
|
2024-05-20 11:51:32 -03:00
|
|
|
return DisplayModes[i];
|
2024-04-23 16:11:17 -03:00
|
|
|
}
|
2024-07-19 23:21:25 -03:00
|
|
|
else if(mode->Format() == format && mode->Width() == width) {
|
2024-04-23 16:11:17 -03:00
|
|
|
matched = mode;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return matched;
|
2024-04-22 11:22:18 -03:00
|
|
|
}
|
2024-04-23 16:11:17 -03:00
|
|
|
|
2024-04-22 11:22:18 -03:00
|
|
|
}
|