13 eastl::string errorcallback =
"Error: ";
14 errorcallback.append(description);
16 debug_error(
"Window",
"Error_callback", errorcallback);
22 glfwDestroyWindow(ptr);
29 void Window::OnWindowResized(GLFWwindow* window,
int width,
int height)
31 if (width == 0 || height == 0)
return;
33 Engine::GetEngine().lock()->GetWindow().lock()->SetWidth(width);
34 Engine::GetEngine().lock()->GetWindow().lock()->SetHeight(height);
36 int display_w, display_h;
37 glfwGetFramebufferSize(Engine::GetEngine().lock()->GetWindow().lock()->GetGLFWWindow().lock().
get(), &display_w, &display_h);
38 Engine::GetEngine().lock()->GetWindow().lock()->displayWidth = display_w;
39 Engine::GetEngine().lock()->GetWindow().lock()->displayHeight = display_h;
42 Engine::GetEngine().lock()->GetInputManager().lock()->GetInputManager().SetDisplaySize(width, height);
49 Engine::GetEngine().lock()->GetRenderer<VulkanRenderer>().lock()->Resized();
53 bool Window::ShouldClose() const noexcept
55 if (window !=
nullptr)
56 return glfwWindowShouldClose(window.get());
60 void Window::SetShouldClose(
bool value)
const noexcept
62 if (window !=
nullptr)
63 glfwSetWindowShouldClose(window.get(), int(value));
66 HWND Window::GetWindowHandle() const noexcept
68 return glfwGetWin32Window(window.get());
71 eastl::weak_ptr<GLFWwindow> Window::GetGLFWWindow() const noexcept
76 eastl::string Window::GetTitle()
const 81 int Window::GetWidth() const noexcept
86 int Window::GetDisplayWidth() const noexcept
91 int Window::GetHeight() const noexcept
96 int Window::GetDisplayHeight() const noexcept
101 Window::Window(
int width,
int height,
const char* title) noexcept : width(width), height(height), title(title)
110 glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE);
111 window = eastl::unique_ptr<GLFWwindow, DestroyglfwWin>(glfwCreateWindow(width, height, title,
nullptr,
nullptr));
119 glfwGetFramebufferSize(window.get(), &displayWidth, &displayHeight);
121 glfwSetWindowSizeCallback(window.get(), OnWindowResized);
125 io.DisplaySize =
ImVec2(
float(width),
float(height));
126 io.DisplayFramebufferScale =
ImVec2(width > 0 ? (
float(displayWidth) / width) : 0, height > 0 ? (
float(displayHeight) / height) : 0);
129 Window::~Window() noexcept
131 glfwDestroyWindow(window.get());
135 void Window::Update()
const noexcept
139 void Window::SwapBuffers()
const noexcept
141 glfwSwapBuffers(window.get());
144 void Window::SetWidth(
int newWidth)
149 void Window::SetHeight(
int newHeight)
#define debug_error(debug_class, function, value)
This functions logs a debug error to the log and console. This does not halt the program! ...
IMGUI_API ImGuiIO & GetIO()
void error_callback(int error, const char *description)
ImVec2 DisplayFramebufferScale
void operator()(GLFWwindow *ptr) const