From aa3b7297135af72bb0fe1bf5d8a487c9e8bc406e Mon Sep 17 00:00:00 2001 From: "Dorodnicov, Sergey" Date: Thu, 22 Mar 2018 04:19:37 -0700 Subject: [PATCH] Adding protection against missing OpenGL drivers (will report error instead of crashing) --- common/ux-window.cpp | 3 +++ examples/example.hpp | 2 ++ tools/rosbag-inspector/rs-rosbag-inspector.cpp | 2 ++ 3 files changed, 7 insertions(+) diff --git a/common/ux-window.cpp b/common/ux-window.cpp index 7a56b5abd6..d4dcf5b7c1 100644 --- a/common/ux-window.cpp +++ b/common/ux-window.cpp @@ -45,6 +45,9 @@ namespace rs2 // Create GUI Windows _win = glfwCreateWindow(_width, _height, _title_str.c_str(), (_fullscreen ? primary : nullptr), nullptr); + if (!_win) + throw std::runtime_error("Could not open OpenGL window, please check your graphic drivers or use the textual SDK tools"); + glfwMakeContextCurrent(_win); ImGui_ImplGlfw_Init(_win, true); diff --git a/examples/example.hpp b/examples/example.hpp index acf5f8e1e7..32c78bfb9e 100644 --- a/examples/example.hpp +++ b/examples/example.hpp @@ -142,6 +142,8 @@ class window { glfwInit(); win = glfwCreateWindow(width, height, title, nullptr, nullptr); + if (!win) + throw std::runtime_error("Could not open OpenGL window, please check your graphic drivers or use the textual SDK tools"); glfwMakeContextCurrent(win); glfwSetWindowUserPointer(win, this); diff --git a/tools/rosbag-inspector/rs-rosbag-inspector.cpp b/tools/rosbag-inspector/rs-rosbag-inspector.cpp index 7eba16cf5c..b50fec5f8b 100644 --- a/tools/rosbag-inspector/rs-rosbag-inspector.cpp +++ b/tools/rosbag-inspector/rs-rosbag-inspector.cpp @@ -44,6 +44,8 @@ class gui_window _first_frame(true), _w(0), _h(0) { + if (!_window) + throw std::runtime_error("Could not open OpenGL window, please check your graphic drivers"); init_window(); } operator bool()