Mercurial > hg > orthanc-stone
annotate OrthancStone/Sources/OpenGL/WebAssemblyOpenGLContext.cpp @ 1534:0443d04416d9
don't discard the windowing altered by mouse
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 07 Aug 2020 21:48:43 +0200 |
parents | 244ad1e4e76a |
children | 85e117739eca |
rev | line source |
---|---|
616
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Stone of Orthanc |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
1270
2d8ab34c8c91
upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1052
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
616
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 * |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Affero General Public License |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 * as published by the Free Software Foundation, either version 3 of |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * the License, or (at your option) any later version. |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, but |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * WITHOUT ANY WARRANTY; without even the implied warranty of |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * Affero General Public License for more details. |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Affero General Public License |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 **/ |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 #include "WebAssemblyOpenGLContext.h" |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
945
diff
changeset
|
24 #include "../StoneException.h" |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
945
diff
changeset
|
25 |
1455
30deba7bc8e2
simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1351
diff
changeset
|
26 #include <OrthancException.h> |
616
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 #include <emscripten/html5.h> |
942
685c9a2d115f
Added missing ORTHANC_OVERRIDE + preparation for lost GL context handling + stubs for GL context event handlers
Benjamin Golinvaux <bgo@osimis.io>
parents:
894
diff
changeset
|
29 #include <emscripten/em_asm.h> |
685c9a2d115f
Added missing ORTHANC_OVERRIDE + preparation for lost GL context handling + stubs for GL context event handlers
Benjamin Golinvaux <bgo@osimis.io>
parents:
894
diff
changeset
|
30 |
616
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 #include <boost/math/special_functions/round.hpp> |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 namespace OrthancStone |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 { |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 namespace OpenGL |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 { |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 class WebAssemblyOpenGLContext::PImpl |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 { |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 private: |
1351
1b8e37770d78
ID vs CSS selector distinction in API and field names.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1338
diff
changeset
|
40 std::string canvasSelector_; |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
945
diff
changeset
|
41 EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context_; |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
945
diff
changeset
|
42 unsigned int canvasWidth_; |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
945
diff
changeset
|
43 unsigned int canvasHeight_; |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
945
diff
changeset
|
44 bool isContextLost_; |
616
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 public: |
1351
1b8e37770d78
ID vs CSS selector distinction in API and field names.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1338
diff
changeset
|
47 PImpl(const std::string& canvasSelector) |
1b8e37770d78
ID vs CSS selector distinction in API and field names.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1338
diff
changeset
|
48 : canvasSelector_(canvasSelector) |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
945
diff
changeset
|
49 , isContextLost_(false) |
616
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 { |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 // Context configuration |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 EmscriptenWebGLContextAttributes attr; |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 emscripten_webgl_init_context_attributes(&attr); |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 |
1351
1b8e37770d78
ID vs CSS selector distinction in API and field names.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1338
diff
changeset
|
55 context_ = emscripten_webgl_create_context(canvasSelector.c_str(), &attr); |
945
2db3ef713664
Fixed error handling for WebGL context creation
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
56 if (context_ == 0) |
616
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 { |
1351
1b8e37770d78
ID vs CSS selector distinction in API and field names.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1338
diff
changeset
|
58 std::string message("Cannot create an OpenGL context for the element with the following CSS selector: \""); |
1b8e37770d78
ID vs CSS selector distinction in API and field names.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1338
diff
changeset
|
59 message += canvasSelector; |
1b8e37770d78
ID vs CSS selector distinction in API and field names.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1338
diff
changeset
|
60 message += "\" Please make sure the -s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1 flag has been passed to Emscripten when building."; |
894
f557b18d287f
wasm: error log if canvas GL context can't be created
Benjamin Golinvaux <bgo@osimis.io>
parents:
891
diff
changeset
|
61 LOG(ERROR) << message; |
f557b18d287f
wasm: error log if canvas GL context can't be created
Benjamin Golinvaux <bgo@osimis.io>
parents:
891
diff
changeset
|
62 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError, message); |
616
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 } |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 UpdateSize(); |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
66 } |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
67 |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
945
diff
changeset
|
68 void* DebugGetInternalContext() const |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
945
diff
changeset
|
69 { |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
945
diff
changeset
|
70 return reinterpret_cast<void*>(context_); |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
945
diff
changeset
|
71 } |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
945
diff
changeset
|
72 |
956
a7351ad54960
Made IsContextLost automatically set the flag by checking with the emscripten
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
73 bool IsContextLost() |
a7351ad54960
Made IsContextLost automatically set the flag by checking with the emscripten
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
74 { |
961
92e32e263ae9
Removed log in IsContextLost (too many calls) + removed glGetError guards on calls (expensive) + added shared_ptr ref count dump in LoaderCache (still needs to figure that one out)
Benjamin Golinvaux <bgo@osimis.io>
parents:
958
diff
changeset
|
75 //LOG(TRACE) << "IsContextLost() for context " << std::hex << context_ << std::dec; |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
945
diff
changeset
|
76 bool apiFlag = (emscripten_is_webgl_context_lost(context_) != 0); |
956
a7351ad54960
Made IsContextLost automatically set the flag by checking with the emscripten
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
77 isContextLost_ = apiFlag; |
a7351ad54960
Made IsContextLost automatically set the flag by checking with the emscripten
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
78 return isContextLost_; |
a7351ad54960
Made IsContextLost automatically set the flag by checking with the emscripten
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
79 } |
a7351ad54960
Made IsContextLost automatically set the flag by checking with the emscripten
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
80 |
a7351ad54960
Made IsContextLost automatically set the flag by checking with the emscripten
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
81 void SetLostContext() |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
945
diff
changeset
|
82 { |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
945
diff
changeset
|
83 isContextLost_ = true; |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
945
diff
changeset
|
84 } |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
945
diff
changeset
|
85 |
616
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
86 ~PImpl() |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
87 { |
956
a7351ad54960
Made IsContextLost automatically set the flag by checking with the emscripten
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
88 try |
a7351ad54960
Made IsContextLost automatically set the flag by checking with the emscripten
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
89 { |
a7351ad54960
Made IsContextLost automatically set the flag by checking with the emscripten
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
90 EMSCRIPTEN_RESULT result = emscripten_webgl_destroy_context(context_); |
a7351ad54960
Made IsContextLost automatically set the flag by checking with the emscripten
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
91 if (result != EMSCRIPTEN_RESULT_SUCCESS) |
a7351ad54960
Made IsContextLost automatically set the flag by checking with the emscripten
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
92 { |
a7351ad54960
Made IsContextLost automatically set the flag by checking with the emscripten
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
93 LOG(ERROR) << "emscripten_webgl_destroy_context returned code " << result; |
a7351ad54960
Made IsContextLost automatically set the flag by checking with the emscripten
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
94 } |
a7351ad54960
Made IsContextLost automatically set the flag by checking with the emscripten
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
95 } |
a7351ad54960
Made IsContextLost automatically set the flag by checking with the emscripten
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
96 catch (const Orthanc::OrthancException& e) |
a7351ad54960
Made IsContextLost automatically set the flag by checking with the emscripten
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
97 { |
a7351ad54960
Made IsContextLost automatically set the flag by checking with the emscripten
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
98 if (e.HasDetails()) |
a7351ad54960
Made IsContextLost automatically set the flag by checking with the emscripten
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
99 { |
a7351ad54960
Made IsContextLost automatically set the flag by checking with the emscripten
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
100 LOG(ERROR) << "OrthancException in WebAssemblyOpenGLContext::~PImpl: " << e.What() << " Details: " << e.GetDetails(); |
a7351ad54960
Made IsContextLost automatically set the flag by checking with the emscripten
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
101 } |
a7351ad54960
Made IsContextLost automatically set the flag by checking with the emscripten
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
102 else |
a7351ad54960
Made IsContextLost automatically set the flag by checking with the emscripten
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
103 { |
a7351ad54960
Made IsContextLost automatically set the flag by checking with the emscripten
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
104 LOG(ERROR) << "OrthancException in WebAssemblyOpenGLContext::~PImpl: " << e.What(); |
a7351ad54960
Made IsContextLost automatically set the flag by checking with the emscripten
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
105 } |
a7351ad54960
Made IsContextLost automatically set the flag by checking with the emscripten
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
106 } |
a7351ad54960
Made IsContextLost automatically set the flag by checking with the emscripten
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
107 catch (const std::exception& e) |
a7351ad54960
Made IsContextLost automatically set the flag by checking with the emscripten
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
108 { |
a7351ad54960
Made IsContextLost automatically set the flag by checking with the emscripten
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
109 LOG(ERROR) << "std::exception in WebAssemblyOpenGLContext::~PImpl: " << e.what(); |
a7351ad54960
Made IsContextLost automatically set the flag by checking with the emscripten
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
110 } |
a7351ad54960
Made IsContextLost automatically set the flag by checking with the emscripten
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
111 catch (...) |
a7351ad54960
Made IsContextLost automatically set the flag by checking with the emscripten
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
112 { |
a7351ad54960
Made IsContextLost automatically set the flag by checking with the emscripten
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
113 LOG(ERROR) << "Unknown exception in WebAssemblyOpenGLContext::~PImpl"; |
a7351ad54960
Made IsContextLost automatically set the flag by checking with the emscripten
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
114 } |
616
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
115 } |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
116 |
1351
1b8e37770d78
ID vs CSS selector distinction in API and field names.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1338
diff
changeset
|
117 const std::string& GetCanvasSelector() const |
617 | 118 { |
1351
1b8e37770d78
ID vs CSS selector distinction in API and field names.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1338
diff
changeset
|
119 return canvasSelector_; |
617 | 120 } |
121 | |
616
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
122 void MakeCurrent() |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
123 { |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
945
diff
changeset
|
124 if (IsContextLost()) |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
945
diff
changeset
|
125 { |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
945
diff
changeset
|
126 LOG(ERROR) << "MakeCurrent() called on lost context " << context_; |
1050 | 127 throw StoneException(ErrorCode_WebGLContextLost); |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
945
diff
changeset
|
128 } |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
945
diff
changeset
|
129 |
942
685c9a2d115f
Added missing ORTHANC_OVERRIDE + preparation for lost GL context handling + stubs for GL context event handlers
Benjamin Golinvaux <bgo@osimis.io>
parents:
894
diff
changeset
|
130 if (emscripten_is_webgl_context_lost(context_)) |
685c9a2d115f
Added missing ORTHANC_OVERRIDE + preparation for lost GL context handling + stubs for GL context event handlers
Benjamin Golinvaux <bgo@osimis.io>
parents:
894
diff
changeset
|
131 { |
1351
1b8e37770d78
ID vs CSS selector distinction in API and field names.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1338
diff
changeset
|
132 LOG(ERROR) << "OpenGL context has been lost for canvas selector: " << canvasSelector_; |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
945
diff
changeset
|
133 SetLostContext(); |
1050 | 134 throw StoneException(ErrorCode_WebGLContextLost); |
942
685c9a2d115f
Added missing ORTHANC_OVERRIDE + preparation for lost GL context handling + stubs for GL context event handlers
Benjamin Golinvaux <bgo@osimis.io>
parents:
894
diff
changeset
|
135 } |
685c9a2d115f
Added missing ORTHANC_OVERRIDE + preparation for lost GL context handling + stubs for GL context event handlers
Benjamin Golinvaux <bgo@osimis.io>
parents:
894
diff
changeset
|
136 |
616
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
137 if (emscripten_webgl_make_context_current(context_) != EMSCRIPTEN_RESULT_SUCCESS) |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
138 { |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
139 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError, |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
140 "Cannot set the OpenGL context"); |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
141 } |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
142 } |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
143 |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
144 void SwapBuffer() |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
145 { |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
146 /** |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
147 * "Rendered WebGL content is implicitly presented (displayed to |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
148 * the user) on the canvas when the event handler that renders with |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
149 * WebGL returns back to the browser event loop." |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
150 * https://emscripten.org/docs/api_reference/html5.h.html#webgl-context |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
151 * |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
152 * Could call "emscripten_webgl_commit_frame()" if |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
153 * "explicitSwapControl" option were set to "true". |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
154 **/ |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
155 } |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
156 |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
157 unsigned int GetCanvasWidth() const |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
158 { |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
159 return canvasWidth_; |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
160 } |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
161 |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
162 unsigned int GetCanvasHeight() const |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
163 { |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
164 return canvasHeight_; |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
165 } |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
166 |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
167 void UpdateSize() |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
168 { |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
169 double w, h; |
1351
1b8e37770d78
ID vs CSS selector distinction in API and field names.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1338
diff
changeset
|
170 emscripten_get_element_css_size(canvasSelector_.c_str(), &w, &h); |
616
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
171 |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
172 /** |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
173 * Emscripten has the function emscripten_get_element_css_size() |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
174 * to query the width and height of a named HTML element. I'm |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
175 * calling this first to get the initial size of the canvas DOM |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
176 * element, and then call emscripten_set_canvas_size() to |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
177 * initialize the framebuffer size of the canvas to the same |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
178 * size as its DOM element. |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
179 * https://floooh.github.io/2017/02/22/emsc-html.html |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
180 **/ |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
181 |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
182 if (w <= 0 || |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
183 h <= 0) |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
184 { |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
185 canvasWidth_ = 0; |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
186 canvasHeight_ = 0; |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
187 } |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
188 else |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
189 { |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
190 canvasWidth_ = static_cast<unsigned int>(boost::math::iround(w)); |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
191 canvasHeight_ = static_cast<unsigned int>(boost::math::iround(h)); |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
192 } |
997
d6b83ee3a950
fix WebAssemblyOpenGLViewport::UpdateSize()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
961
diff
changeset
|
193 |
1351
1b8e37770d78
ID vs CSS selector distinction in API and field names.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1338
diff
changeset
|
194 emscripten_set_canvas_element_size(canvasSelector_.c_str(), canvasWidth_, canvasHeight_); |
616
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
195 } |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
196 }; |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
197 |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
198 |
1351
1b8e37770d78
ID vs CSS selector distinction in API and field names.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1338
diff
changeset
|
199 WebAssemblyOpenGLContext::WebAssemblyOpenGLContext(const std::string& canvasSelector) : |
1b8e37770d78
ID vs CSS selector distinction in API and field names.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1338
diff
changeset
|
200 pimpl_(new PImpl(canvasSelector)) |
616
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
201 { |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
202 } |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
203 |
956
a7351ad54960
Made IsContextLost automatically set the flag by checking with the emscripten
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
204 bool WebAssemblyOpenGLContext::IsContextLost() |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
945
diff
changeset
|
205 { |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
945
diff
changeset
|
206 return pimpl_->IsContextLost(); |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
945
diff
changeset
|
207 } |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
945
diff
changeset
|
208 |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
945
diff
changeset
|
209 void WebAssemblyOpenGLContext::SetLostContext() |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
945
diff
changeset
|
210 { |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
945
diff
changeset
|
211 pimpl_->SetLostContext(); |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
945
diff
changeset
|
212 } |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
945
diff
changeset
|
213 |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
945
diff
changeset
|
214 void* WebAssemblyOpenGLContext::DebugGetInternalContext() const |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
945
diff
changeset
|
215 { |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
945
diff
changeset
|
216 return pimpl_->DebugGetInternalContext(); |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
945
diff
changeset
|
217 } |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
945
diff
changeset
|
218 |
616
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
219 void WebAssemblyOpenGLContext::MakeCurrent() |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
220 { |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
221 assert(pimpl_.get() != NULL); |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
222 pimpl_->MakeCurrent(); |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
223 } |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
224 |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
225 void WebAssemblyOpenGLContext::SwapBuffer() |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
226 { |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
227 assert(pimpl_.get() != NULL); |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
228 pimpl_->SwapBuffer(); |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
229 } |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
230 |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
231 unsigned int WebAssemblyOpenGLContext::GetCanvasWidth() const |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
232 { |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
233 assert(pimpl_.get() != NULL); |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
234 return pimpl_->GetCanvasWidth(); |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
235 } |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
236 |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
237 unsigned int WebAssemblyOpenGLContext::GetCanvasHeight() const |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
238 { |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
239 assert(pimpl_.get() != NULL); |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
240 return pimpl_->GetCanvasHeight(); |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
241 } |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
242 |
1482
5c96bf3f1d32
IOpenGL::RefreshCanvasSize()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
243 void WebAssemblyOpenGLContext::RefreshCanvasSize() |
616
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
244 { |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
245 assert(pimpl_.get() != NULL); |
1483
6abd819aa534
moving edge case from WebGLViewport::UpdateSize() to WebAssemblyOpenGLContext::RefreshCanvasSize()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1482
diff
changeset
|
246 |
6abd819aa534
moving edge case from WebGLViewport::UpdateSize() to WebAssemblyOpenGLContext::RefreshCanvasSize()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1482
diff
changeset
|
247 try |
6abd819aa534
moving edge case from WebGLViewport::UpdateSize() to WebAssemblyOpenGLContext::RefreshCanvasSize()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1482
diff
changeset
|
248 { |
6abd819aa534
moving edge case from WebGLViewport::UpdateSize() to WebAssemblyOpenGLContext::RefreshCanvasSize()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1482
diff
changeset
|
249 pimpl_->UpdateSize(); |
6abd819aa534
moving edge case from WebGLViewport::UpdateSize() to WebAssemblyOpenGLContext::RefreshCanvasSize()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1482
diff
changeset
|
250 } |
6abd819aa534
moving edge case from WebGLViewport::UpdateSize() to WebAssemblyOpenGLContext::RefreshCanvasSize()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1482
diff
changeset
|
251 catch (const StoneException& e) |
6abd819aa534
moving edge case from WebGLViewport::UpdateSize() to WebAssemblyOpenGLContext::RefreshCanvasSize()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1482
diff
changeset
|
252 { |
6abd819aa534
moving edge case from WebGLViewport::UpdateSize() to WebAssemblyOpenGLContext::RefreshCanvasSize()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1482
diff
changeset
|
253 // Ignore problems about the loss of the WebGL context (edge case) |
6abd819aa534
moving edge case from WebGLViewport::UpdateSize() to WebAssemblyOpenGLContext::RefreshCanvasSize()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1482
diff
changeset
|
254 if (e.GetErrorCode() == ErrorCode_WebGLContextLost) |
6abd819aa534
moving edge case from WebGLViewport::UpdateSize() to WebAssemblyOpenGLContext::RefreshCanvasSize()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1482
diff
changeset
|
255 { |
6abd819aa534
moving edge case from WebGLViewport::UpdateSize() to WebAssemblyOpenGLContext::RefreshCanvasSize()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1482
diff
changeset
|
256 return; |
6abd819aa534
moving edge case from WebGLViewport::UpdateSize() to WebAssemblyOpenGLContext::RefreshCanvasSize()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1482
diff
changeset
|
257 } |
6abd819aa534
moving edge case from WebGLViewport::UpdateSize() to WebAssemblyOpenGLContext::RefreshCanvasSize()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1482
diff
changeset
|
258 else |
6abd819aa534
moving edge case from WebGLViewport::UpdateSize() to WebAssemblyOpenGLContext::RefreshCanvasSize()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1482
diff
changeset
|
259 { |
6abd819aa534
moving edge case from WebGLViewport::UpdateSize() to WebAssemblyOpenGLContext::RefreshCanvasSize()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1482
diff
changeset
|
260 throw; |
6abd819aa534
moving edge case from WebGLViewport::UpdateSize() to WebAssemblyOpenGLContext::RefreshCanvasSize()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1482
diff
changeset
|
261 } |
6abd819aa534
moving edge case from WebGLViewport::UpdateSize() to WebAssemblyOpenGLContext::RefreshCanvasSize()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1482
diff
changeset
|
262 } |
616
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
263 } |
617 | 264 |
1351
1b8e37770d78
ID vs CSS selector distinction in API and field names.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1338
diff
changeset
|
265 const std::string& WebAssemblyOpenGLContext::GetCanvasSelector() const |
617 | 266 { |
267 assert(pimpl_.get() != NULL); | |
1351
1b8e37770d78
ID vs CSS selector distinction in API and field names.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1338
diff
changeset
|
268 return pimpl_->GetCanvasSelector(); |
617 | 269 } |
616
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
270 } |
97926984d5d0
WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
271 } |