1
0
mirror of https://github.com/borgesdan/xn65 synced 2024-12-29 21:54:47 +01:00
xn65/framework/platform-dx/displaymode.cpp

64 lines
1.3 KiB
C++
Raw Normal View History

2024-05-20 11:51:32 -03:00
#include "platform-dx/implementations.hpp"
#include "graphics/displaymode.hpp"
2024-04-22 11:22:18 -03:00
namespace xna {
2024-05-20 11:51:32 -03:00
DisplayMode::DisplayMode() {
impl = uNew<PlatformImplementation>();
}
DisplayMode::~DisplayMode() {
impl = nullptr;
}
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) {
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) {
if (DisplayModes[i]->Format == format) {
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-05-20 11:51:32 -03:00
if (mode->Format == format && mode->Width == width && mode->Height == height) {
return DisplayModes[i];
2024-04-23 16:11:17 -03:00
}
2024-05-20 11:51:32 -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
}