comparison OrthancStone/Sources/Platforms/WebAssembly/WebAssemblyOpenGLContext.cpp @ 2045:e5c812a36746 deep-learning

added support of WebGL2 in WebAssemblyOpenGLContext
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sun, 05 Mar 2023 17:06:31 +0100
parents 184b0aeae1af
children fdb012c86a75
comparison
equal deleted inserted replaced
2044:c9dadbe7c7b0 2045:e5c812a36746
43 std::string canvasSelector_; 43 std::string canvasSelector_;
44 EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context_; 44 EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context_;
45 bool isContextLost_; 45 bool isContextLost_;
46 46
47 public: 47 public:
48 explicit PImpl(const std::string& canvasSelector) : 48 explicit PImpl(const std::string& canvasSelector,
49 Version version) :
49 canvasSelector_(canvasSelector), 50 canvasSelector_(canvasSelector),
50 isContextLost_(false) 51 isContextLost_(false)
51 { 52 {
52 // Context configuration 53 // Context configuration
53 EmscriptenWebGLContextAttributes attr; 54 EmscriptenWebGLContextAttributes attr;
54 emscripten_webgl_init_context_attributes(&attr); 55 emscripten_webgl_init_context_attributes(&attr);
55 56
57 switch (version)
58 {
59 case Version_WebGL1:
60 break;
61
62 case Version_WebGL2:
63 attr.majorVersion = 2;
64 attr.minorVersion = 0;
65 break;
66
67 default:
68 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
69 }
70
56 // The next line might be necessary to print using 71 // The next line might be necessary to print using
57 // WebGL. Sometimes, if set to "false" (the default value), 72 // WebGL. Sometimes, if set to "false" (the default value),
58 // the canvas was rendered as a fully white or black 73 // the canvas was rendered as a fully white or black
59 // area. UNCONFIRMED. 74 // area. UNCONFIRMED.
60 attr.preserveDrawingBuffer = true; 75 attr.preserveDrawingBuffer = true;
160 } 175 }
161 }; 176 };
162 177
163 178
164 WebAssemblyOpenGLContext::WebAssemblyOpenGLContext(const std::string& canvasSelector) : 179 WebAssemblyOpenGLContext::WebAssemblyOpenGLContext(const std::string& canvasSelector) :
165 pimpl_(new PImpl(canvasSelector)) 180 pimpl_(new PImpl(canvasSelector, Version_WebGL1))
181 {
182 }
183
184 WebAssemblyOpenGLContext::WebAssemblyOpenGLContext(const std::string& canvasSelector,
185 Version version) :
186 pimpl_(new PImpl(canvasSelector, version))
166 { 187 {
167 } 188 }
168 189
169 bool WebAssemblyOpenGLContext::IsContextLost() 190 bool WebAssemblyOpenGLContext::IsContextLost()
170 { 191 {