summaryrefslogtreecommitdiff
path: root/src/window.cpp
diff options
context:
space:
mode:
authorJonathan Bradley <jcb@pikum.xyz>2023-10-16 09:27:33 -0400
committerJonathan Bradley <jcb@pikum.xyz>2023-10-16 09:27:33 -0400
commit76f2069b78fe369a3eba03a16218d352e3e51b53 (patch)
treec3add8dbc25a7ecf62130aa42ef76da990baa354 /src/window.cpp
parent611eba4565b6f25881a6294696ea10492c025ec4 (diff)
checkpoint - get current monitor's refresh rate
Diffstat (limited to 'src/window.cpp')
-rw-r--r--src/window.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/window.cpp b/src/window.cpp
index c7b9dba..2a1b905 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -27,6 +27,8 @@ const bool VULKAN_DEBUG_REPORT = true;
* Initialization
*/
GLFWwindow *window = nullptr;
+GLFWmonitor *monitor = nullptr;
+GLFWvidmode vidMode;
VkInstance vkInstance = nullptr;
VkPhysicalDevice vkPhysicalDevice = nullptr;
VkPhysicalDeviceProperties vkPhysicalDeviceProperties;
@@ -2323,6 +2325,22 @@ void DestroySwapchain() {
vkDestroySwapchainKHR(vkDevice, vkSwapchainKHR, vkAllocator);
}
+void DetermineMonitor() {
+ int monitorCount;
+ GLFWmonitor **monitors = glfwGetMonitors(&monitorCount);
+ assert(monitors != nullptr);
+ // TODO - actually determine monitor
+ monitor = monitors[0];
+
+ const auto *videoMode = glfwGetVideoMode(monitor);
+ vidMode.width = videoMode->width;
+ vidMode.height = videoMode->height;
+ vidMode.redBits = videoMode->redBits;
+ vidMode.greenBits = videoMode->greenBits;
+ vidMode.blueBits = videoMode->blueBits;
+ vidMode.refreshRate = videoMode->refreshRate;
+}
+
void RecreateSwapchain() {
int width, height = 0;
glfwGetFramebufferSize(window, &width, &height);
@@ -2332,6 +2350,7 @@ void RecreateSwapchain() {
}
extent.width = width;
extent.height = height;
+ DetermineMonitor();
vkDeviceWaitIdle(vkDevice);
DestroySwapchain();
CreateSwapchain();
@@ -2368,6 +2387,8 @@ void CreateWindow(PKEWindowProperties *wp) {
CreateGraphicsPipelines();
UpdateDebugGraphicsPipeline();
CreateImGui();
+
+ DetermineMonitor();
}
void DestroyWindow() {