diff options
author | Yann Herklotz <ymherklotz@gmail.com> | 2017-12-22 18:34:29 +0000 |
---|---|---|
committer | Yann Herklotz <ymherklotz@gmail.com> | 2017-12-22 18:34:29 +0000 |
commit | 24253190c92c9d7ef669061670a3b7596f9ee190 (patch) | |
tree | f03d785e30a7783b5e0d5e7b669cd2997d5877ed /yage/core/window.cpp | |
parent | b885965a6375f98d6bec63a43233461f9f42006d (diff) | |
download | YAGE-24253190c92c9d7ef669061670a3b7596f9ee190.tar.gz YAGE-24253190c92c9d7ef669061670a3b7596f9ee190.zip |
Changing directories and adding input support
Diffstat (limited to 'yage/core/window.cpp')
-rw-r--r-- | yage/core/window.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/yage/core/window.cpp b/yage/core/window.cpp index 9696f2bb..70e8d8e3 100644 --- a/yage/core/window.cpp +++ b/yage/core/window.cpp @@ -16,10 +16,13 @@ namespace yage void key_callback(GLFWwindow *window, int key, int scanCode, int action, int mods) { - if (key == GLFW_KEY_E && action == GLFW_PRESS) { + if (key == GLFW_KEY_E && (action == GLFW_REPEAT || action == GLFW_PRESS)) { glClearColor(0.5f, 0.f, 0.f, 1.f); + } else if (key == GLFW_KEY_Q && + (action == GLFW_REPEAT || action == GLFW_PRESS)) { + glClearColor(0.f, 0.f, 0.5f, 1.f); } else { - glClearColor(0.f, 0.5f, 0.f, 1.f); + glClearColor(0.f, .5f, 0.f, 1.f); } } @@ -37,8 +40,9 @@ void Window::create(std::string window_name, int width, int height) throw std::runtime_error("GLFW Initialisation failed"); } - glfwWindowHint(GLFW_VERSION_MAJOR, 4); - glfwWindowHint(GLFW_VERSION_MINOR, 5); + glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); + glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 5); + glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); window_ = glfwCreateWindow(width, height, window_name.c_str(), nullptr, nullptr); @@ -97,6 +101,10 @@ bool Window::shouldClose() void Window::pollEvents() const { glfwPollEvents(); + + if (glfwGetKey(window_, GLFW_KEY_W) == GLFW_PRESS) { + glClearColor(0.f, 0.5f, 0.5f, 1.f); + } } } // namespace yage |