diff --git a/00skeleton.cpp b/00skeleton.cpp index 5113fed..8f1b39c 100644 --- a/00skeleton.cpp +++ b/00skeleton.cpp @@ -34,6 +34,13 @@ int main() { glfwMakeContextCurrent(window); + // Bind ESC key press to close the application + glfwSetKeyCallback(window, [](GLFWwindow* window, int key, int scancode, int action, int mods) { + if (action == GLFW_PRESS and key == GLFW_KEY_ESCAPE) { + glfwSetWindowShouldClose(window, true); + }; + }); + if(glxwInit()) { std::cerr << "failed to init GL3W" << std::endl; glfwDestroyWindow(window); diff --git a/01shader_vbo1.cpp b/01shader_vbo1.cpp index d75fbfb..49818bc 100644 --- a/01shader_vbo1.cpp +++ b/01shader_vbo1.cpp @@ -66,6 +66,13 @@ int main() { glfwMakeContextCurrent(window); + // Bind ESC key press to close the application + glfwSetKeyCallback(window, [](GLFWwindow* window, int key, int scancode, int action, int mods) { + if (action == GLFW_PRESS and key == GLFW_KEY_ESCAPE) { + glfwSetWindowShouldClose(window, true); + }; + }); + if(glxwInit()) { std::cerr << "failed to init GL3W" << std::endl; glfwDestroyWindow(window); diff --git a/01shader_vbo2.cpp b/01shader_vbo2.cpp index a10ae88..4a4e6e4 100644 --- a/01shader_vbo2.cpp +++ b/01shader_vbo2.cpp @@ -68,6 +68,13 @@ int main() { glfwMakeContextCurrent(window); + // Bind ESC key press to close the application + glfwSetKeyCallback(window, [](GLFWwindow* window, int key, int scancode, int action, int mods) { + if (action == GLFW_PRESS and key == GLFW_KEY_ESCAPE) { + glfwSetWindowShouldClose(window, true); + }; + }); + if(glxwInit()) { std::cerr << "failed to init GL3W" << std::endl; glfwDestroyWindow(window); diff --git a/02indexed_vbo.cpp b/02indexed_vbo.cpp index 44a594a..16beef5 100644 --- a/02indexed_vbo.cpp +++ b/02indexed_vbo.cpp @@ -66,6 +66,13 @@ int main() { glfwMakeContextCurrent(window); + // Bind ESC key press to close the application + glfwSetKeyCallback(window, [](GLFWwindow* window, int key, int scancode, int action, int mods) { + if (action == GLFW_PRESS and key == GLFW_KEY_ESCAPE) { + glfwSetWindowShouldClose(window, true); + }; + }); + if(glxwInit()) { std::cerr << "failed to init GL3W" << std::endl; glfwDestroyWindow(window); diff --git a/03texture.cpp b/03texture.cpp index 8297af1..44b2b5a 100644 --- a/03texture.cpp +++ b/03texture.cpp @@ -66,6 +66,13 @@ int main() { glfwMakeContextCurrent(window); + // Bind ESC key press to close the application + glfwSetKeyCallback(window, [](GLFWwindow* window, int key, int scancode, int action, int mods) { + if (action == GLFW_PRESS and key == GLFW_KEY_ESCAPE) { + glfwSetWindowShouldClose(window, true); + }; + }); + if(glxwInit()) { std::cerr << "failed to init GL3W" << std::endl; glfwDestroyWindow(window); diff --git a/04perspective.cpp b/04perspective.cpp index e9d212d..13edb74 100644 --- a/04perspective.cpp +++ b/04perspective.cpp @@ -72,6 +72,13 @@ int main() { glfwMakeContextCurrent(window); + // Bind ESC key press to close the application + glfwSetKeyCallback(window, [](GLFWwindow* window, int key, int scancode, int action, int mods) { + if (action == GLFW_PRESS and key == GLFW_KEY_ESCAPE) { + glfwSetWindowShouldClose(window, true); + }; + }); + if(glxwInit()) { std::cerr << "failed to init GL3W" << std::endl; glfwDestroyWindow(window); diff --git a/05fbo_fxaa.cpp b/05fbo_fxaa.cpp index f90b478..3884269 100644 --- a/05fbo_fxaa.cpp +++ b/05fbo_fxaa.cpp @@ -72,6 +72,13 @@ int main() { glfwMakeContextCurrent(window); + // Bind ESC key press to close the application + glfwSetKeyCallback(window, [](GLFWwindow* window, int key, int scancode, int action, int mods) { + if (action == GLFW_PRESS and key == GLFW_KEY_ESCAPE) { + glfwSetWindowShouldClose(window, true); + }; + }); + if(glxwInit()) { std::cerr << "failed to init GL3W" << std::endl; glfwDestroyWindow(window); diff --git a/06instancing1.cpp b/06instancing1.cpp index dfdc357..3a1bac6 100644 --- a/06instancing1.cpp +++ b/06instancing1.cpp @@ -72,6 +72,13 @@ int main() { glfwMakeContextCurrent(window); + // Bind ESC key press to close the application + glfwSetKeyCallback(window, [](GLFWwindow* window, int key, int scancode, int action, int mods) { + if (action == GLFW_PRESS and key == GLFW_KEY_ESCAPE) { + glfwSetWindowShouldClose(window, true); + }; + }); + if(glxwInit()) { std::cerr << "failed to init GL3W" << std::endl; glfwDestroyWindow(window); diff --git a/06instancing2_buffer_texture.cpp b/06instancing2_buffer_texture.cpp index 7b8f0c4..f3be81e 100644 --- a/06instancing2_buffer_texture.cpp +++ b/06instancing2_buffer_texture.cpp @@ -75,6 +75,13 @@ int main() { glfwMakeContextCurrent(window); + // Bind ESC key press to close the application + glfwSetKeyCallback(window, [](GLFWwindow* window, int key, int scancode, int action, int mods) { + if (action == GLFW_PRESS and key == GLFW_KEY_ESCAPE) { + glfwSetWindowShouldClose(window, true); + }; + }); + if(glxwInit()) { std::cerr << "failed to init GL3W" << std::endl; glfwDestroyWindow(window); diff --git a/06instancing3_uniform_buffer.cpp b/06instancing3_uniform_buffer.cpp index 99a9ab9..f0d887f 100644 --- a/06instancing3_uniform_buffer.cpp +++ b/06instancing3_uniform_buffer.cpp @@ -73,6 +73,13 @@ int main() { glfwMakeContextCurrent(window); + // Bind ESC key press to close the application + glfwSetKeyCallback(window, [](GLFWwindow* window, int key, int scancode, int action, int mods) { + if (action == GLFW_PRESS and key == GLFW_KEY_ESCAPE) { + glfwSetWindowShouldClose(window, true); + }; + }); + if(glxwInit()) { std::cerr << "failed to init GL3W" << std::endl; glfwDestroyWindow(window); diff --git a/07geometry_shader_blending.cpp b/07geometry_shader_blending.cpp index acb3962..202d01d 100644 --- a/07geometry_shader_blending.cpp +++ b/07geometry_shader_blending.cpp @@ -75,6 +75,13 @@ int main() { glfwMakeContextCurrent(window); + // Bind ESC key press to close the application + glfwSetKeyCallback(window, [](GLFWwindow* window, int key, int scancode, int action, int mods) { + if (action == GLFW_PRESS and key == GLFW_KEY_ESCAPE) { + glfwSetWindowShouldClose(window, true); + }; + }); + if(glxwInit()) { std::cerr << "failed to init GL3W" << std::endl; glfwDestroyWindow(window); diff --git a/08map_buffer.cpp b/08map_buffer.cpp index 56e0036..6ddfb9a 100644 --- a/08map_buffer.cpp +++ b/08map_buffer.cpp @@ -77,6 +77,13 @@ int main() { glfwMakeContextCurrent(window); + // Bind ESC key press to close the application + glfwSetKeyCallback(window, [](GLFWwindow* window, int key, int scancode, int action, int mods) { + if (action == GLFW_PRESS and key == GLFW_KEY_ESCAPE) { + glfwSetWindowShouldClose(window, true); + }; + }); + if(glxwInit()) { std::cerr << "failed to init GL3W" << std::endl; glfwDestroyWindow(window); diff --git a/09transform_feedback.cpp b/09transform_feedback.cpp index fa191be..e99f863 100644 --- a/09transform_feedback.cpp +++ b/09transform_feedback.cpp @@ -76,6 +76,13 @@ int main() { glfwMakeContextCurrent(window); + // Bind ESC key press to close the application + glfwSetKeyCallback(window, [](GLFWwindow* window, int key, int scancode, int action, int mods) { + if (action == GLFW_PRESS and key == GLFW_KEY_ESCAPE) { + glfwSetWindowShouldClose(window, true); + }; + }); + if(glxwInit()) { std::cerr << "failed to init GL3W" << std::endl; glfwDestroyWindow(window); diff --git a/10queries_conditional_render.cpp b/10queries_conditional_render.cpp index ecd660e..f5cf6a9 100644 --- a/10queries_conditional_render.cpp +++ b/10queries_conditional_render.cpp @@ -106,6 +106,13 @@ int main() { glfwMakeContextCurrent(window); + // Bind ESC key press to close the application + glfwSetKeyCallback(window, [](GLFWwindow* window, int key, int scancode, int action, int mods) { + if (action == GLFW_PRESS and key == GLFW_KEY_ESCAPE) { + glfwSetWindowShouldClose(window, true); + }; + }); + if(glxwInit()) { std::cerr << "failed to init GL3W" << std::endl; glfwDestroyWindow(window); diff --git a/11tesselation.cpp b/11tesselation.cpp index b5e2c82..6b4b18b 100644 --- a/11tesselation.cpp +++ b/11tesselation.cpp @@ -80,6 +80,13 @@ int main() { glfwMakeContextCurrent(window); + // Bind ESC key press to close the application + glfwSetKeyCallback(window, [](GLFWwindow* window, int key, int scancode, int action, int mods) { + if (action == GLFW_PRESS and key == GLFW_KEY_ESCAPE) { + glfwSetWindowShouldClose(window, true); + }; + }); + if(glxwInit()) { std::cerr << "failed to init GL3W" << std::endl; glfwDestroyWindow(window); diff --git a/12shader_image_load_store.cpp b/12shader_image_load_store.cpp index e7a3c6e..ef6ba02 100644 --- a/12shader_image_load_store.cpp +++ b/12shader_image_load_store.cpp @@ -72,6 +72,13 @@ int main() { glfwMakeContextCurrent(window); + // Bind ESC key press to close the application + glfwSetKeyCallback(window, [](GLFWwindow* window, int key, int scancode, int action, int mods) { + if (action == GLFW_PRESS and key == GLFW_KEY_ESCAPE) { + glfwSetWindowShouldClose(window, true); + }; + }); + if(glxwInit()) { std::cerr << "failed to init GL3W" << std::endl; glfwDestroyWindow(window); diff --git a/13compute_shader_nbody.cpp b/13compute_shader_nbody.cpp index eaea0ec..790f468 100644 --- a/13compute_shader_nbody.cpp +++ b/13compute_shader_nbody.cpp @@ -76,6 +76,13 @@ int main() { glfwMakeContextCurrent(window); + // Bind ESC key press to close the application + glfwSetKeyCallback(window, [](GLFWwindow* window, int key, int scancode, int action, int mods) { + if (action == GLFW_PRESS and key == GLFW_KEY_ESCAPE) { + glfwSetWindowShouldClose(window, true); + }; + }); + if(glxwInit()) { std::cerr << "failed to init GL3W" << std::endl; glfwDestroyWindow(window); diff --git a/CMakeLists.txt b/CMakeLists.txt index a1e3f0b..40278e0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,9 @@ cmake_minimum_required(VERSION 2.6) project(OPENGLEXAMPLES) +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED True) + option(BUILD_OGL43 "Bild OpenGL 4.3 examples" OFF) mark_as_advanced(BUILD_OGL43)