Introduce Math.hpp and use typedef to make replacing glm with something else in the future simpler

This commit is contained in:
2020-10-27 23:25:26 +01:00
parent c219fc3778
commit 78d24fbe41
16 changed files with 268 additions and 181 deletions

View File

@@ -25,68 +25,8 @@ namespace openVulkanoCpp
return windowConfig;
}
void GetSize(int* width, int* height) override = 0;
void GetSize(uint32_t* width, uint32_t* height) override
{
int w, h;
GetSize(&w, &h);
*width = w;
*height = h;
}
uint32_t GetWidth() override
{
uint32_t width, height;
GetSize(&width, &height);
return width;
}
uint32_t GetHeight() override
{
uint32_t width, height;
GetSize(&width, &height);
return height;
}
glm::ivec2 GetSize() override
{
glm::ivec2 size;
this->GetSize(&size.x, &size.y);
return size;
}
void SetSize(uint32_t width, uint32_t height) override = 0;
void SetSize(glm::ivec2 size) override
{
SetSize(size.x, size.y);
}
void GetPosition(int* x, int* y) override = 0;
int GetPositionX() override
{
int x, y;
GetPosition(&x, &y);
return x;
}
int GetPositionY() override
{
int x, y;
GetPosition(&x, &y);
return y;
}
glm::ivec2 GetPosition() override
{
glm::ivec2 position;
GetPosition(&position.x, &position.y);
return position;
}
bool HasTitle() override
{
return WindowMode::WINDOWED == GetWindowMode();
@@ -104,8 +44,6 @@ namespace openVulkanoCpp
void SetPosition(int posX, int posY) override = 0;
void SetPosition(glm::ivec2 pos) override { SetPosition(pos.x, pos.y); }
void Show() override = 0;
void Hide() override = 0;

View File

@@ -6,7 +6,7 @@
#pragma once
#include <glm/glm.hpp>
#include "../../Math/Math.hpp"
#include "../PlatformEnums.hpp"
#include "../ICloseable.hpp"
#include <string>
@@ -28,8 +28,8 @@ namespace openVulkanoCpp
struct WindowConfiguration
{
uint32_t width = 1280, height = 720;
int posX = 0, posY = 0;
Math::Vector2ui size{1280, 720};
Math::Vector2i position{0, 0};
std::string title = "Window Title";
WindowMode windowMode = WINDOWED;
};
@@ -47,25 +47,20 @@ namespace openVulkanoCpp
virtual WindowMode GetWindowMode() = 0;
virtual void SetWindowMode(WindowMode) = 0;
virtual void SetFullscreen() { SetWindowMode(FULLSCREEN); }
virtual void SetWindowed() { SetWindowMode(WINDOWED); }
inline void SetFullscreen() { SetWindowMode(FULLSCREEN); }
inline void SetWindowed() { SetWindowMode(WINDOWED); }
virtual const WindowConfiguration& GetWindowConfiguration() = 0;
virtual uint32_t GetWidth() = 0;
virtual uint32_t GetHeight() = 0;
virtual void GetSize(int* width, int* height) = 0;
virtual void GetSize(uint32_t* width, uint32_t* height) = 0;
virtual glm::ivec2 GetSize() = 0;
inline uint32_t GetWidth() { return GetSize().x; }
inline uint32_t GetHeight() { return GetSize().y; }
virtual Math::Vector2ui GetSize() = 0;
virtual void SetSize(uint32_t width, uint32_t height) = 0;
virtual void SetSize(glm::ivec2 size) { SetSize(size.x, size.y); }
inline void SetSize(Math::Vector2ui size) { SetSize(size.x, size.y); }
virtual void SetSizeLimits(int minWidth, int minHeight, int maxWidth, int maxHeight) = 0;
virtual int GetPositionX() = 0;
virtual int GetPositionY() = 0;
virtual void GetPosition(int* x, int* y) = 0;
virtual glm::ivec2 GetPosition() = 0;
virtual Math::Vector2i GetPosition() = 0;
virtual void SetPosition(int posX, int posY) = 0;
virtual void SetPosition(glm::ivec2 pos) = 0;
inline void SetPosition(Math::Vector2i pos) { SetPosition(pos.x, pos.y); };
virtual void Show() = 0;
virtual void Hide() = 0;