2022-06-04 16:26:58 +00:00
|
|
|
#include "Graphics/Window.h"
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
2022-06-10 20:44:40 +00:00
|
|
|
#include <iostream>
|
2022-06-04 16:26:58 +00:00
|
|
|
#include <GLFW/glfw3.h>
|
|
|
|
#include <spdlog/spdlog.h>
|
2022-06-10 20:44:40 +00:00
|
|
|
#include "../Include/EventSystem/Event.h"
|
2022-06-04 16:26:58 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set vsync off !!
|
|
|
|
glfwSwapInterval(0);
|
|
|
|
|
|
|
|
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);
|
2022-06-10 20:44:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void BarinkWindow::ReceiveEvent(Event& incident)
|
|
|
|
{
|
2022-06-19 18:01:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2022-06-10 20:44:40 +00:00
|
|
|
std::cout << "EVENT RECEIVED: " << incident.name << std::endl;
|
|
|
|
|
2022-04-20 19:40:35 +00:00
|
|
|
}
|