14 #include <GLFW/glfw3.h> 22 WindowGL::WindowGL(
int width,
int height, std::string title,
bool vsync) :
Window() {
28 glfwDefaultWindowHints();
31 glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
34 glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
35 glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
36 glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
37 glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE);
40 handle = glfwCreateWindow(width, height, title.c_str(), NULL, NULL);
42 throw runtime_error(
"Could not create window!");
46 glfwMakeContextCurrent(
handle);
49 glewExperimental = GL_TRUE;
50 if (glewInit() != GLEW_OK) {
51 throw runtime_error(
"Could not init GLEW for the current GL context!");
void setKeyCallback(KeyCallback *callback)
Set the key callback.
This class provides a basic GLFW window.
Generic namespace for the SimpleGL framework.
This class wraps a GLFW key callback.
GLFWwindow * handle
The handle for the GLFW window.
std::string title
The title for the GLFW window.
void swapBuffers() override
Swaps the framebuffers of this window.
void setMouseButtonCallback(MouseButtonCallback *callback)
Set the mouse button callback.
void centerWindow()
Centers the window on the primary screen.
glm::ivec2 size
The size of the drawing area.
void setVSync(bool vsync)
Enables or disables vertical synchronization.