work on utils

This commit is contained in:
2025-03-21 13:38:31 -05:00
parent 719af8e85a
commit 7900def444
11 changed files with 113 additions and 76 deletions

View File

@@ -0,0 +1,37 @@
#include "Archimedes.h"
#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);
}
bool WindowGLFW::shouldClose() {
return glfwWindowShouldClose(w);
}
void WindowGLFW::doFrame() {
glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers(w);
glfwPollEvents();
}
WindowGLFW::~WindowGLFW() {
glfwTerminate();
}
}

View File

@@ -0,0 +1,23 @@
#include "Archimedes.h"
#include <GLFW/glfw3.h>
namespace Archimedes {
class WindowGLFW {
public:
WindowGLFW();
~WindowGLFW();
bool shouldClose();
void doFrame();
private:
GLFWwindow* w;
};
typedef WindowGLFW WindowImpl;
}

View File

@@ -1,36 +0,0 @@
#include "Archimedes.h"
#include "windowGLFW.h"
Window::Window() {
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);
}
bool Window::shouldClose() {
return glfwWindowShouldClose(w);
}
void Window::doFrame() {
glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers(w);
glfwPollEvents();
}
Window::~Window() {
glfwTerminate();
}

View File

@@ -1,20 +0,0 @@
#include "Window/Window.h"
#define GLEW_STATIC
#include <GL/glew.h>
#include <GLFW/glfw3.h>
class WindowGLFW : public Window {
public:
Window();
~Window();
bool shouldClose();
void doFrame();
private:
GLFWwindow* w;
};