comparison Framework/OpenGL/OpenGLIncludes.h @ 947:1091b2adeb5a toa2019081001

Fixed animation frame stopping when returning false + big work on the OpenGL objects to make them lost context-safe + debug code to forcefully tag a context as lost + debug macros
author Benjamin Golinvaux <bgo@osimis.io>
date Sat, 10 Aug 2019 13:07:31 +0200
parents f4b37a991dac
children 92e32e263ae9
comparison
equal deleted inserted replaced
946:dbe3e1e47019 947:1091b2adeb5a
37 # include <GL/glew.h> 37 # include <GL/glew.h>
38 #else 38 #else
39 # include <GL/gl.h> 39 # include <GL/gl.h>
40 # include <GL/glext.h> 40 # include <GL/glext.h>
41 #endif 41 #endif
42
43 #if ORTHANC_ENABLE_SDL == 1
44 #include <SDL_video.h>
45
46 #define ORTHANC_OPENGL_CHECK(name) \
47 if(true) \
48 { \
49 GLenum error = glGetError(); \
50 if (error != GL_NO_ERROR) { \
51 SDL_GLContext ctx = SDL_GL_GetCurrentContext(); \
52 LOG(ERROR) << "Error when calling " << name << " | current context is: 0x" << std::hex << ctx << " | error code is " << error; \
53 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError,"OpenGL error in " name " | See log."); \
54 } \
55 } else (void)0
56
57 #define ORTHANC_OPENGL_TRACE_CURRENT_CONTEXT(msg) \
58 if(true) \
59 { \
60 SDL_GLContext ctx = SDL_GL_GetCurrentContext(); \
61 LOG(TRACE) << msg << " | Current OpenGL context is " << std::hex << ctx; \
62 } else (void)0
63
64 #define ORTHANC_CHECK_CURRENT_CONTEXT(context) \
65 if(true) \
66 { \
67 SDL_GLContext actualCtx = SDL_GL_GetCurrentContext(); \
68 void* expectedCtx = context.DebugGetInternalContext(); \
69 if(expectedCtx != actualCtx) \
70 { \
71 LOG(ERROR) << "Expected context was " << std::hex << expectedCtx << " while actual context is " << std::hex << actualCtx; \
72 } \
73 } else (void)0
74
75 #endif
76
77 #if ORTHANC_ENABLE_WASM == 1
78 #include <emscripten/html5.h>
79
80 #define ORTHANC_OPENGL_CHECK(name) \
81 if(true) \
82 { \
83 GLenum error = glGetError(); \
84 if (error != GL_NO_ERROR) { \
85 EMSCRIPTEN_WEBGL_CONTEXT_HANDLE ctx = emscripten_webgl_get_current_context(); \
86 EM_BOOL lost = emscripten_is_webgl_context_lost(ctx); \
87 LOG(ERROR) << "Error when calling " << name << " | current context is: 0x" << std::hex << ctx << " | error code is " << error << " | emscripten_is_webgl_context_lost = " << lost; \
88 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError,"OpenGL error in " name " | See log."); \
89 } \
90 } else (void)0
91
92 #define ORTHANC_OPENGL_TRACE_CURRENT_CONTEXT(msg) \
93 if(true) \
94 { \
95 EMSCRIPTEN_WEBGL_CONTEXT_HANDLE ctx = emscripten_webgl_get_current_context(); \
96 LOG(TRACE) << msg << " | Current OpenGL context is " << std::hex << ctx; \
97 } else (void)0
98
99 #define ORTHANC_CHECK_CURRENT_CONTEXT(context) \
100 if(true) \
101 { \
102 EMSCRIPTEN_WEBGL_CONTEXT_HANDLE ctx = emscripten_webgl_get_current_context(); \
103 void* actualCtx = reinterpret_cast<void*>(ctx); \
104 void* expectedCtx = context.DebugGetInternalContext(); \
105 if(expectedCtx != actualCtx) \
106 { \
107 LOG(ERROR) << "Expected context was " << std::hex << expectedCtx << " while actual context is " << std::hex << actualCtx; \
108 } \
109 } else (void)0
110
111 #endif
112