Introduce Math.hpp and use typedef to make replacing glm with something else in the future simpler
This commit is contained in:
@@ -30,8 +30,8 @@ namespace openVulkanoCpp::GLFW
|
||||
{
|
||||
int posX, posY, sizeX, sizeY;
|
||||
glfwGetMonitorWorkarea(monitors[i], &posX, &posY, &sizeX, &sizeY);
|
||||
if (windowConfig.posX >= posX && windowConfig.posX < posX + sizeX &&
|
||||
windowConfig.posY >= posY && windowConfig.posY < posY + sizeY)
|
||||
if (windowConfig.position.x >= posX && windowConfig.position.x < posX + sizeX &&
|
||||
windowConfig.position.y >= posY && windowConfig.position.y < posY + sizeY)
|
||||
{
|
||||
return monitors[i];
|
||||
}
|
||||
@@ -53,7 +53,7 @@ namespace openVulkanoCpp::GLFW
|
||||
{
|
||||
glfwWindowHint(GLFW_DECORATED, (~windowConfig.windowMode) & 1);
|
||||
//TODO handle full screen resolutions
|
||||
window = glfwCreateWindow(windowConfig.width, windowConfig.height, windowConfig.title.c_str(), GetTargetMonitor(), nullptr);
|
||||
window = glfwCreateWindow(windowConfig.size.x, windowConfig.size.y, windowConfig.title.c_str(), GetTargetMonitor(), nullptr);
|
||||
if (!window) return;
|
||||
glfwSetWindowUserPointer(window, this);
|
||||
RegisterCallbacks();
|
||||
@@ -142,8 +142,8 @@ namespace openVulkanoCpp::GLFW
|
||||
|
||||
void WindowGLFW::SetSize(uint32_t width, uint32_t height)
|
||||
{
|
||||
windowConfig.width = width;
|
||||
windowConfig.height = height;
|
||||
windowConfig.size.x = width;
|
||||
windowConfig.size.y = height;
|
||||
if (window)
|
||||
{
|
||||
glfwSetWindowSize(window, width, height);
|
||||
@@ -152,14 +152,28 @@ namespace openVulkanoCpp::GLFW
|
||||
|
||||
void WindowGLFW::SetPosition(int posX, int posY)
|
||||
{
|
||||
windowConfig.posX = posX;
|
||||
windowConfig.posY = posY;
|
||||
windowConfig.position.x = posX;
|
||||
windowConfig.position.y = posY;
|
||||
if (window)
|
||||
{
|
||||
glfwSetWindowPos(window, posX, posY);
|
||||
}
|
||||
}
|
||||
|
||||
Math::Vector2ui WindowGLFW::GetSize()
|
||||
{
|
||||
Math::Vector2i size;
|
||||
glfwGetWindowSize(window, &size.x, &size.y);
|
||||
return size;
|
||||
}
|
||||
|
||||
Math::Vector2i WindowGLFW::GetPosition()
|
||||
{
|
||||
Math::Vector2i pos;
|
||||
glfwGetWindowPos(window, &pos.x, &pos.y);
|
||||
return pos;
|
||||
}
|
||||
|
||||
void WindowGLFW::SetSizeLimits(int minWidth, int minHeight, int maxWidth, int maxHeight)
|
||||
{
|
||||
minWidth = (minWidth < 0) ? GLFW_DONT_CARE : minWidth;
|
||||
@@ -185,10 +199,10 @@ namespace openVulkanoCpp::GLFW
|
||||
glfwWindowHint(GLFW_DECORATED, (~windowMode) & 1);
|
||||
if (windowMode == WINDOWED || windowMode == BORDERLESS)
|
||||
{
|
||||
sizeX = windowConfig.width;
|
||||
sizeY = windowConfig.height;
|
||||
posX = windowConfig.posX;
|
||||
posY = windowConfig.posY;
|
||||
sizeX = windowConfig.size.x;
|
||||
sizeY = windowConfig.size.y;
|
||||
posX = windowConfig.position.x;
|
||||
posY = windowConfig.position.y;
|
||||
monitor = nullptr;
|
||||
if (windowMode == WINDOWED)
|
||||
{
|
||||
@@ -201,7 +215,7 @@ namespace openVulkanoCpp::GLFW
|
||||
}
|
||||
else
|
||||
{ // Fullscreen
|
||||
GetPosition(&windowConfig.posX, &windowConfig.posY); // Backup current window position
|
||||
windowConfig.position = GetPosition(); // Backup current window position
|
||||
monitor = GetCurrentMonitor();
|
||||
if (!monitor) monitor = GetPrimaryMonitor();
|
||||
if (!monitor) return; // We don't have a monitor to set the fullscreen window to
|
||||
@@ -229,16 +243,6 @@ namespace openVulkanoCpp::GLFW
|
||||
this->handler = handler;
|
||||
}
|
||||
|
||||
void WindowGLFW::GetSize(int* width, int* height)
|
||||
{
|
||||
glfwGetWindowSize(window, width, height);
|
||||
}
|
||||
|
||||
void WindowGLFW::GetPosition(int* x, int* y)
|
||||
{
|
||||
glfwGetWindowPos(window, x, y);
|
||||
}
|
||||
|
||||
vk::SurfaceKHR WindowGLFW::CreateSurface(const vk::Instance& instance, const vk::AllocationCallbacks* pAllocator)
|
||||
{
|
||||
VkSurfaceKHR rawSurface;
|
||||
@@ -286,8 +290,8 @@ namespace openVulkanoCpp::GLFW
|
||||
Logger::WINDOW->debug("Window (id: {0}) moved (x: {1}, y: {2})", GetWindowId(), posX, posY);
|
||||
if (windowConfig.windowMode == WINDOWED || windowConfig.windowMode == BORDERLESS)
|
||||
{ // Don't save window position for fullscreen
|
||||
windowConfig.posX = posX;
|
||||
windowConfig.posY = posY;
|
||||
windowConfig.position.x = posX;
|
||||
windowConfig.position.y = posY;
|
||||
}
|
||||
handler->OnWindowMove(this, posX, posY);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user