diff Framework/StoneInitialization.cpp @ 611:e3f21a265be5

Added version directive to GLSL shader code + glew init function in sample code AND commented-out glew init function in StoneInitialize
author Benjamin Golinvaux <bgo@osimis.io>
date Tue, 30 Apr 2019 16:07:48 +0200
parents 0c4c0693b97c
children ba72bffceb7d
line wrap: on
line diff
--- a/Framework/StoneInitialization.cpp	Tue Apr 30 09:17:45 2019 +0200
+++ b/Framework/StoneInitialization.cpp	Tue Apr 30 16:07:48 2019 +0200
@@ -21,6 +21,7 @@
 
 #include "StoneInitialization.h"
 
+#include <Core/OrthancException.h>
 #include <Core/Logging.h>
 
 #if !defined(ORTHANC_ENABLE_SDL)
@@ -32,6 +33,9 @@
 #  include "../Applications/Sdl/SdlWindow.h"
 #endif
 
+#if ORTHANC_ENABLE_OPENGL == 1
+#  include "GL/glew.h"
+#endif
 
 namespace OrthancStone
 {
@@ -39,6 +43,31 @@
   {
     Orthanc::Logging::Initialize();
 
+#if 0
+#if ORTHANC_ENABLE_OPENGL == 1
+    glEnable(GL_DEBUG_OUTPUT);
+    GLenum err = glewInit();
+    if (GLEW_OK != err)
+    {
+      const char* error =
+        reinterpret_cast<const char*>(glewGetErrorString(err));
+      if (strcmp(error, "Missing GL version") != 0)
+      {
+        std::stringstream msg;
+        msg << "Error while initializing OpenGL through GLEW: " << error;
+        throw Orthanc::OrthancException(
+          Orthanc::ErrorCode_InternalError,msg.str());
+      }
+    }
+    {
+      std::stringstream message;
+      message << "Using GLEW version " << reinterpret_cast<const char*>(
+        glewGetString(GLEW_VERSION));
+      LOG(INFO) << "Using GLEW version " << message.str();
+    }
+#endif
+#endif
+
 #if ORTHANC_ENABLE_SDL == 1
     OrthancStone::SdlWindow::GlobalInitialize();
 #endif