YoggieEngine/BarinkEngine/graphics/window.cpp

73 lines
1.2 KiB
C++
Raw Normal View History

#include "Graphics/Window.h"
#include <stdlib.h>
#include <stdio.h>
#include <GLFW/glfw3.h>
#include <spdlog/spdlog.h>
bool BarinkWindow::InitGLFW(){
if(!glfwInit())
{
spdlog::error("Failed to initialise GLFW!");
return false;
}
2022-04-30 18:20:07 +00:00
return true;
}
BarinkWindow::BarinkWindow(const int width, const int height) :
Width(width), Height(height), FullScreen(false){
2022-04-30 18:20:07 +00:00
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);
2022-04-30 18:20:07 +00:00
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) {
printf("Failed to initialize GLAD!\n");
exit(-1);
}
VulkanSupported = glfwVulkanSupported();
glfwGetFramebufferSize(window, &Width, &Height);
glViewport(0,0, Width, Height);
2022-04-30 18:20:07 +00:00
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();
2022-05-04 12:39:27 +00:00
}
void BarinkWindow::SwapBuffers()
{
glfwSwapBuffers(window);
}