YoggieEngine/MyGraphicsEngine/window.cpp
2022-05-04 14:39:27 +02:00

73 lines
1.1 KiB
C++

#include "MyGraphicsEngine/Window.h"
#include <spdlog/spdlog.h>
bool BarinkWindow::InitGLFW(){
if(!glfwInit())
{
spdlog::error("Failed to initialise GLFW!");
return false;
}
return true;
}
BarinkWindow::BarinkWindow(const int width, const int height) :
Width(width), Height(height), FullScreen(false){
if (InitGLFW()==false) {
exit(-1);
}
window = glfwCreateWindow(Width, Height, "BarinkEngine", NULL, NULL);
if( !window)
{
spdlog::error("GLFW failed to create window!");
glfwTerminate();
return;
}
glfwMakeContextCurrent(window);
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) {
printf("Failed to initialize GLAD!\n");
exit(-1);
}
VulkanSupported = glfwVulkanSupported();
glfwGetFramebufferSize(window, &Width, &Height);
glViewport(0,0, Width, Height);
glClearColor(0.2f, 0.2f, 0.2f, 1.0f);
}
BarinkWindow::~BarinkWindow(){
glfwTerminate();
}
GLFWwindow* BarinkWindow::windowptr()
{
return window;
}
bool BarinkWindow::WindowShouldClose(){
return glfwWindowShouldClose(window);
}
void BarinkWindow::Poll()
{
glfwPollEvents();
}
void BarinkWindow::SwapBuffers()
{
glfwSwapBuffers(window);
}