Skip to content

Commit 89ee90d

Browse files
committed
Merge pull request #341 from larshg/master
Exit on opengl errors
2 parents a6770bd + 3990a23 commit 89ee90d

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

examples/protonect/src/opengl_depth_packet_processor.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,11 @@ struct OpenGLDepthPacketProcessorImpl : public WithOpenGLBindings
469469
ChangeCurrentOpenGLContext ctx(opengl_context_ptr);
470470

471471
OpenGLBindings *b = new OpenGLBindings();
472-
flextInit(opengl_context_ptr, b);
472+
if (flextInit(opengl_context_ptr, b) == 0)
473+
{
474+
std::cerr << "[OpenGLDepthPacketProcessor] Failed to initialize flextGL.";
475+
exit(-1);
476+
}
473477
gl(b);
474478

475479
input_data.allocate(352, 424 * 10);
@@ -768,7 +772,11 @@ OpenGLDepthPacketProcessor::OpenGLDepthPacketProcessor(void *parent_opengl_conte
768772
GLFWwindow* parent_window = (GLFWwindow *)parent_opengl_context_ptr;
769773

770774
// init glfw - if already initialized nothing happens
771-
glfwInit();
775+
if (glfwInit() == GL_FALSE)
776+
{
777+
std::cerr << "[OpenGLDepthPacketProcessor] Failed to initialize GLFW.";
778+
exit(-1);
779+
}
772780

773781
// setup context
774782
glfwDefaultWindowHints();
@@ -782,6 +790,12 @@ OpenGLDepthPacketProcessor::OpenGLDepthPacketProcessor(void *parent_opengl_conte
782790

783791
GLFWwindow* window = glfwCreateWindow(1024, 848, "OpenGLDepthPacketProcessor", 0, parent_window);
784792

793+
if (window == NULL)
794+
{
795+
std::cerr << "[OpenGLDepthPacketProcessor] Failed to create opengl window.";
796+
exit(-1);
797+
}
798+
785799
impl_ = new OpenGLDepthPacketProcessorImpl(window, debug);
786800
impl_->initialize();
787801
}

0 commit comments

Comments
 (0)