Files
Archimedes/utils/Window/WindowGLFW/WindowGLFW.cpp
2025-03-22 00:56:41 -05:00

43 lines
915 B
C++

#include "pch.hpp"
#include "WindowGLFW.h"
namespace Archimedes {
WindowGLFW::WindowGLFW() {
glfwSetErrorCallback([](int e, const char* m){
std::cout << "GLFW Error: " << m << std::endl;
});
if(!glfwInit()) {
std::cout << "glfwInit failed!\n";
std::abort();
}
w = glfwCreateWindow(640, 480, "Archimedes", NULL, NULL);
if(!w) {
glfwTerminate();
std::abort();
}
glfwMakeContextCurrent(w);
glfwSwapInterval(1);
}
bool WindowGLFW::shouldClose() {
return glfwWindowShouldClose(w);
}
void WindowGLFW::doFrame() {
glfwPollEvents();
glfwSwapBuffers(w);
}
void WindowGLFW::getSize(int& w, int& h) {
glfwGetFramebufferSize(this->w, &w, &h);
}
WindowGLFW::~WindowGLFW() {
glfwTerminate();
}
}