2022-04-22 20:37:38 +00:00
|
|
|
#include "MyGraphicsEngine/Window.h"
|
|
|
|
#include <spdlog/spdlog.h>
|
2022-04-20 19:40:35 +00:00
|
|
|
|
2022-04-28 19:02:54 +00:00
|
|
|
|
2022-04-20 19:40:35 +00:00
|
|
|
bool BarinkWindow::InitGLFW(){
|
2022-04-22 20:37:38 +00:00
|
|
|
if(!glfwInit())
|
|
|
|
{
|
|
|
|
spdlog::error("Failed to initialise GLFW!");
|
2022-04-20 19:40:35 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
BarinkWindow::BarinkWindow(const int width, const int height) :
|
|
|
|
Width(width), Height(height), FullScreen(false){
|
|
|
|
InitGLFW();
|
|
|
|
|
|
|
|
window = glfwCreateWindow(Width, Height, "BarinkEngine", NULL, NULL);
|
|
|
|
|
2022-04-22 20:37:38 +00:00
|
|
|
if( !window)
|
|
|
|
{
|
|
|
|
spdlog::error("GLFW failed to create window!");
|
2022-04-20 19:40:35 +00:00
|
|
|
glfwTerminate();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
glfwMakeContextCurrent(window);
|
|
|
|
|
|
|
|
VulkanSupported = glfwVulkanSupported();
|
|
|
|
|
|
|
|
glfwGetFramebufferSize(window, &Width, &Height);
|
|
|
|
glViewport(0,0, Width, Height);
|
|
|
|
|
|
|
|
|
2022-04-28 19:02:54 +00:00
|
|
|
|
|
|
|
|
2022-04-20 19:40:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BarinkWindow::~BarinkWindow(){
|
|
|
|
|
|
|
|
glfwTerminate();
|
|
|
|
}
|
|
|
|
|
2022-04-28 19:02:54 +00:00
|
|
|
bool BarinkWindow::WindowShouldClose(){
|
|
|
|
return glfwWindowShouldClose(window);
|
|
|
|
}
|
2022-04-20 19:40:35 +00:00
|
|
|
|
2022-04-28 19:02:54 +00:00
|
|
|
void BarinkWindow::Poll()
|
|
|
|
{
|
|
|
|
glfwSwapBuffers(window);
|
|
|
|
glfwPollEvents();
|
2022-04-20 19:40:35 +00:00
|
|
|
}
|