YoggieEngine/MyGraphicsEngine/window.cpp

74 lines
1.2 KiB
C++

#include "include/MyGraphicsEngine/Window.h"
#include <stdlib.h>
#include <stdio.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);
}