Newer
Older
ForwardPlusRenderer / src / VulkanWindow.cpp
#include <stdafx.h>
#include "VulkanWindow.h"

 namespace fpr
{
GLFWwindow* VulkanWindow::GetWindowHandle()
{
  return m_window;
}

VulkanWindow::VulkanWindow(const char* title, uint32_t width, uint32_t height)
{
  glfwInit();
  glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
  m_window = glfwCreateWindow(width, height, title, nullptr, nullptr);
  glfwSetWindowUserPointer(m_window, this);
  glfwSetFramebufferSizeCallback(m_window, VulkanWindow::ResizeCallback);
}


vk::Extent2D VulkanWindow::GetCurrentExtent()
{
  return { m_width, m_height };
}

void VulkanWindow::ResizeCallback(GLFWwindow* window, int width, int height)
{
  VulkanWindow* window_handle = reinterpret_cast<VulkanWindow*>(glfwGetWindowUserPointer(window));
  window_handle->m_width      = width;
  window_handle->m_height     = height;
  window_handle->resized      = true;
  glfwSetWindowTitle(window, std::to_string(width).c_str());
}
void VulkanWindow::ResizeComplete()
{
  resized = false;
};

bool VulkanWindow::NeedsResizing()
{
  return resized;
}

VulkanWindow::~VulkanWindow()
{
  glfwDestroyWindow(m_window);
  glfwTerminate();
}
} // namespace fpr