Added SetFullScreen and Maximize function to Window

This commit is contained in:
Antoine Pilote
2024-08-07 12:44:20 -04:00
parent b2bc19b8d0
commit 0e8484f36d
4 changed files with 23 additions and 10 deletions

View File

@@ -2366,6 +2366,7 @@ namespace Nuake {
auto window = Window::Get();
window->SetDecorated(true);
window->SetSize({ 1900, 1000 });
window->Maximize();
window->Center();
frameCount = 0;
return;

View File

@@ -2,14 +2,14 @@
#include "src/Physics/PhysicsManager.h"
#include <GLFW/glfw3.h>
#include "src/Core/Input.h"
#include "src/Core/FileSystem.h"
#include "src/Scripting/ScriptingEngine.h"
#include "src/Audio/AudioManager.h"
#include "src/AI/NavManager.h"
#include "src/Threading/JobSystem.h"
#include "src/Audio/AudioManager.h"
#include "src/Core/FileSystem.h"
#include "src/Core/Input.h"
#include "src/Rendering/Renderer.h"
#include "src/Rendering/Renderer2D.h"
#include "src/Scripting/ScriptingEngine.h"
#include "src/Threading/JobSystem.h"
#include <imgui/imgui_impl_glfw.h>
#include <imgui/imgui_impl_opengl3.h>
@@ -52,7 +52,7 @@ namespace Nuake
s_LastFrameTime = s_Time;
// Dont update if no scene is loaded.
if (s_CurrentWindow->GetScene())
if (s_CurrentWindow->GetScene())
{
float scaledTimeStep = s_TimeStep * s_TimeScale;
s_CurrentWindow->Update(scaledTimeStep);
@@ -66,7 +66,7 @@ namespace Nuake
s_FixedUpdateDifference += s_TimeStep;
// Fixed update
while (s_FixedUpdateDifference >= s_FixedUpdateRate)
while (s_FixedUpdateDifference >= s_FixedUpdateRate)
{
s_CurrentWindow->FixedUpdate(s_FixedUpdateRate * s_TimeScale);
@@ -81,7 +81,7 @@ namespace Nuake
void Engine::EnterPlayMode()
{
s_LastFrameTime = (float)glfwGetTime();; // Reset timestep timer.
s_LastFrameTime = (float)glfwGetTime(); // Reset timestep timer.
// Dont trigger init if already in player mode.
if (GetGameState() == GameState::Playing)

View File

@@ -272,6 +272,18 @@ namespace Nuake
glfwSetWindowAttrib(m_Window, GLFW_DECORATED, enabled);
}
void Window::SetFullScreen(bool enabled)
{
const auto monitor = glfwGetPrimaryMonitor();
const GLFWvidmode* mode = glfwGetVideoMode(monitor);
glfwSetWindowMonitor(m_Window, monitor, 0, 0, mode->width, mode->height, GLFW_DONT_CARE);
}
void Window::Maximize()
{
glfwMaximizeWindow(m_Window);
}
void Window::InitImgui()
{
ImGui::CreateContext();

View File

@@ -46,9 +46,9 @@ namespace Nuake
void SetWindowIcon(const std::string& path);
void SetVSync(bool enabled);
void SetDecorated(bool enabled);
void SetFullScreen(bool enabled);
void Maximize();
private:
const std::string DEFAULT_TITLE = "Untitled Window";
const uint32_t DEFAULT_WIDTH = 1280;