Mercurial > hg > orthanc-stone
comparison Applications/Sdl/SdlOpenGLWindow.cpp @ 614:4ec32d4d0867
cnot
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 30 Apr 2019 16:59:48 +0200 |
parents | 412a2d01a189 |
children | b4de8272e8fb |
comparison
equal
deleted
inserted
replaced
613:412a2d01a189 | 614:4ec32d4d0867 |
---|---|
33 | 33 |
34 #include <Core/OrthancException.h> | 34 #include <Core/OrthancException.h> |
35 | 35 |
36 namespace OrthancStone | 36 namespace OrthancStone |
37 { | 37 { |
38 static boost::mutex globalMutex_; | |
39 static bool globalIsGlewInitialized_ = false; | |
40 | |
41 SdlOpenGLWindow::SdlOpenGLWindow(const char* title, | 38 SdlOpenGLWindow::SdlOpenGLWindow(const char* title, |
42 unsigned int width, | 39 unsigned int width, |
43 unsigned int height) : | 40 unsigned int height) : |
44 window_(title, width, height, true /* enable OpenGL */) | 41 window_(title, width, height, true /* enable OpenGL */) |
45 { | 42 { |
54 #if ORTHANC_ENABLE_GLEW == 1 | 51 #if ORTHANC_ENABLE_GLEW == 1 |
55 // The initialization function of glew (i.e. "glewInit()") can | 52 // The initialization function of glew (i.e. "glewInit()") can |
56 // only be called once an OpenGL is setup. | 53 // only be called once an OpenGL is setup. |
57 // https://stackoverflow.com/a/45033669/881731 | 54 // https://stackoverflow.com/a/45033669/881731 |
58 { | 55 { |
59 boost::mutex::scoped_lock lock(globalMutex_); | 56 static boost::mutex mutex_; |
57 static bool isGlewInitialized_ = false; | |
58 | |
59 boost::mutex::scoped_lock lock(mutex_); | |
60 | 60 |
61 if (!globalIsGlewInitialized_) | 61 if (!isGlewInitialized_) |
62 { | 62 { |
63 LOG(INFO) << "Initializing glew"; | 63 LOG(INFO) << "Initializing glew"; |
64 | 64 |
65 GLenum err = glewInit(); | 65 GLenum err = glewInit(); |
66 if (GLEW_OK != err) | 66 if (GLEW_OK != err) |
67 { | 67 { |
68 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError, | 68 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError, |
69 "Cannot initialize glew"); | 69 "Cannot initialize glew"); |
70 } | 70 } |
71 | 71 |
72 globalIsGlewInitialized_ = true; | 72 isGlewInitialized_ = true; |
73 } | 73 } |
74 } | 74 } |
75 #endif | 75 #endif |
76 } | 76 } |
77 | 77 |