the gui problem^TM
This commit is contained in:
37
utils/Window/WindowGLFW/WindowGLFW.cpp
Normal file
37
utils/Window/WindowGLFW/WindowGLFW.cpp
Normal 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);
|
||||
glfwSwapInterval(1);
|
||||
}
|
||||
|
||||
bool WindowGLFW::shouldClose() {
|
||||
return glfwWindowShouldClose(w);
|
||||
}
|
||||
|
||||
void WindowGLFW::doFrame() {
|
||||
glfwPollEvents();
|
||||
glfwSwapBuffers(w);
|
||||
}
|
||||
|
||||
WindowGLFW::~WindowGLFW() {
|
||||
glfwTerminate();
|
||||
}
|
||||
}
|
||||
27
utils/Window/WindowGLFW/WindowGLFW.h
Normal file
27
utils/Window/WindowGLFW/WindowGLFW.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#include "Archimedes.h"
|
||||
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
namespace Archimedes {
|
||||
|
||||
class WindowGLFW {
|
||||
|
||||
public:
|
||||
|
||||
WindowGLFW();
|
||||
~WindowGLFW();
|
||||
|
||||
bool shouldClose();
|
||||
|
||||
void doFrame();
|
||||
|
||||
void getSize(int&, int&);
|
||||
|
||||
auto getWindow() { return w; }
|
||||
|
||||
private:
|
||||
GLFWwindow* w;
|
||||
};
|
||||
|
||||
typedef WindowGLFW WindowImpl;
|
||||
}
|
||||
Reference in New Issue
Block a user