diff options
author | Yann Herklotz <ymherklotz@gmail.com> | 2017-10-12 14:57:26 +0100 |
---|---|---|
committer | Yann Herklotz <ymherklotz@gmail.com> | 2017-10-12 14:57:26 +0100 |
commit | 1bb0ef8960c71ef505a351702bec54c01ba15e22 (patch) | |
tree | 365811364237f1e55e66f421b93cad8adcf51eda /yage/base/window.cpp | |
parent | ba733040afb85d4c287a2ec464db05cb86a53fca (diff) | |
download | YAGE-1bb0ef8960c71ef505a351702bec54c01ba15e22.tar.gz YAGE-1bb0ef8960c71ef505a351702bec54c01ba15e22.zip |
Fixing spritesheet and fixed #12
Diffstat (limited to 'yage/base/window.cpp')
-rw-r--r-- | yage/base/window.cpp | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/yage/base/window.cpp b/yage/base/window.cpp index 38056b14..5ac2d8dc 100644 --- a/yage/base/window.cpp +++ b/yage/base/window.cpp @@ -18,13 +18,17 @@ Window::Window() = default; Window::~Window() { glfwDestroyWindow(window_); + glfwTerminate(); } -void Window::create(const std::string &window_name, int width, int height, - unsigned) +void Window::create(std::string window_name, int width, int height) { - glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); - glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); + if(glfwInit() == GLFW_FALSE) { + throw std::runtime_error("GLFW Initialisation failed"); + } + + glfwWindowHint(GLFW_VERSION_MAJOR, 4); + glfwWindowHint(GLFW_VERSION_MINOR, 5); window_ = glfwCreateWindow(width, height, window_name.c_str(), nullptr, nullptr); @@ -46,6 +50,8 @@ void Window::create(const std::string &window_name, int width, int height, // set alpha blending glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + // set the clear depth + glClearDepth(1.f); } void Window::swapBuffer() @@ -56,8 +62,6 @@ void Window::swapBuffer() void Window::clearBuffer() { - // set the clear depth - glClearDepth(1.f); // clears buffer with clear color glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } @@ -72,4 +76,14 @@ void Window::show() glfwShowWindow(window_); } +bool Window::shouldClose() +{ + return glfwWindowShouldClose(window_); +} + +void Window::pollEvents() const +{ + glfwPollEvents(); +} + } // namespace yage |