46 lines
1.3 KiB
C++
46 lines
1.3 KiB
C++
|
#include "gfx.hpp"
|
||
|
|
||
|
#include <GLFW/glfw3.h>
|
||
|
|
||
|
#include "platform.hpp"
|
||
|
|
||
|
int oldWindowX = 0, oldWindowY = 0;
|
||
|
|
||
|
void GFX::MakeContextCurrent()
|
||
|
{
|
||
|
glfwMakeContextCurrent(static_cast<GLFWwindow*>(Platform::GetUserData()));
|
||
|
glfwSwapInterval(1);
|
||
|
}
|
||
|
|
||
|
void GFX::SwapBuffers()
|
||
|
{
|
||
|
glfwSwapBuffers(static_cast<GLFWwindow*>(Platform::GetUserData()));
|
||
|
}
|
||
|
|
||
|
void GFX::GoFullscreen()
|
||
|
{
|
||
|
GLFWwindow* window = static_cast<GLFWwindow*>(Platform::GetUserData());
|
||
|
|
||
|
glfwGetWindowPos(window, &oldWindowX, &oldWindowY); //save window pos for later
|
||
|
const GLFWvidmode* videoMode = glfwGetVideoMode(glfwGetPrimaryMonitor());
|
||
|
|
||
|
glfwSetWindowMonitor(window, glfwGetPrimaryMonitor(), 0, 0, videoMode->width, videoMode->height, videoMode->refreshRate);
|
||
|
}
|
||
|
|
||
|
void GFX::ExitFullscreen()
|
||
|
{
|
||
|
GLFWwindow* window = static_cast<GLFWwindow*>(Platform::GetUserData());
|
||
|
|
||
|
if(oldWindowX == 0 || oldWindowY == 0)
|
||
|
glfwGetWindowPos(window, &oldWindowX, &oldWindowY); //save window pos
|
||
|
|
||
|
glfwSetWindowMonitor(window, nullptr, oldWindowX, oldWindowY, 1600, 900, GLFW_DONT_CARE);
|
||
|
}
|
||
|
|
||
|
VkSurfaceKHR GFX::CreateVulkanSurface(VkInstance instance)
|
||
|
{
|
||
|
VkSurfaceKHR surface;
|
||
|
glfwCreateWindowSurface(instance, static_cast<GLFWwindow*>(Platform::GetUserData()), nullptr, &surface);
|
||
|
|
||
|
return surface;
|
||
|
}
|