fix fullscreen resolution

This commit is contained in:
arthur.jamet
2021-06-17 14:37:16 +02:00
parent f0b6b59428
commit 63a77a61b4
4 changed files with 32 additions and 8 deletions
+19 -1
View File
@@ -80,7 +80,8 @@ const RAY::Vector2 &RAY::Window::getDimensions(void)
RAY::Window &RAY::Window::setDimensions(const Vector2 &dims)
{
this->_dimensions = dims;
SetWindowSize(dims.x, dims.y);
if (this->_isOpen)
SetWindowSize(dims.x, dims.y);
return *this;
}
@@ -200,6 +201,11 @@ unsigned RAY::Window::getConfigFlags(void) const
return this->_flags;
}
bool RAY::Window::isFullscreen(void) const
{
return IsWindowFullscreen();
}
RAY::Window &RAY::Window::setConfigFlags(unsigned flags)
{
if (this->_isOpen)
@@ -212,4 +218,16 @@ RAY::Window &RAY::Window::toggleFullscreen()
{
ToggleFullscreen();
return *this;
}
RAY::Window &RAY::Window::maximize()
{
MaximizeWindow();
return *this;
}
RAY::Window &RAY::Window::restore()
{
RestoreWindow();
return *this;
}
+9
View File
@@ -148,6 +148,15 @@ namespace RAY {
//! @brief set window to fullscreen
RAY::Window &toggleFullscreen();
//! @return true if the window is fullscreen
bool isFullscreen(void) const;
//! @brief set window to max size
RAY::Window &maximize();
//! @brief reset window size
RAY::Window &restore();
private:
//! @brief Creates window, and opens it if openNow is set to true
Window(int width, int height, std::string title, unsigned flags = 0, bool openNow = true);
+3 -6
View File
@@ -184,18 +184,15 @@ namespace BBM
{
RAY2D::Text *text = dynamic_cast<RAY2D::Text *>(entity.getComponent<Drawable2DComponent>().drawable.get());
RAY::Window &window = RAY::Window::getInstance();
unsigned oldFlags = window.getConfigFlags();
if (oldFlags == FLAG_WINDOW_RESIZABLE)
window.toggleFullscreen();
else
window.setConfigFlags(FLAG_WINDOW_RESIZABLE);
if (text->getString().find("Off") != std::string::npos) {
text->setText("Fullscreen: On");
window.setDimensions(RAY::Vector2(1920, 1080));
} else {
text->setText("Fullscreen: Off");
window.setDimensions(RAY::Vector2(1280, 720));
}
window.toggleFullscreen();
})
.addComponent<OnIdleComponent>([](WAL::Entity &entity, WAL::Wal &)
{
+1 -1
View File
@@ -94,7 +94,7 @@ namespace BBM
void RenderSystem::resizeWindow(Vector2f &newDims)
{
newDims.y = (newDims.x * 720) / 1280;
if (newDims.y < 720 || newDims.x < 1280) {
if ((newDims.y < 720 || newDims.x < 1280)) {
newDims.y = 720;
newDims.x = 1280;
}