Mercurial > hg > orthanc-stone
comparison Framework/Scene2D/OpenGLCompositor.cpp @ 942:685c9a2d115f
Added missing ORTHANC_OVERRIDE + preparation for lost GL context handling + stubs for GL context event handlers
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Mon, 05 Aug 2019 12:27:27 +0200 |
parents | 9c2f6d6b9f4a |
children | 1091b2adeb5a |
comparison
equal
deleted
inserted
replaced
939:ab90628e70d9 | 942:685c9a2d115f |
---|---|
15 * Affero General Public License for more details. | 15 * Affero General Public License for more details. |
16 * | 16 * |
17 * You should have received a copy of the GNU Affero General Public License | 17 * You should have received a copy of the GNU Affero General Public License |
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 **/ | 19 **/ |
20 | |
21 | 20 |
22 #include "OpenGLCompositor.h" | 21 #include "OpenGLCompositor.h" |
23 | 22 |
24 #include "Internals/OpenGLAdvancedPolylineRenderer.h" | 23 #include "Internals/OpenGLAdvancedPolylineRenderer.h" |
25 #include "Internals/OpenGLBasicPolylineRenderer.h" | 24 #include "Internals/OpenGLBasicPolylineRenderer.h" |
58 assert(alphabet_.get() != NULL); | 57 assert(alphabet_.get() != NULL); |
59 return *alphabet_; | 58 return *alphabet_; |
60 } | 59 } |
61 }; | 60 }; |
62 | 61 |
63 | |
64 const OpenGLCompositor::Font* OpenGLCompositor::GetFont(size_t fontIndex) const | 62 const OpenGLCompositor::Font* OpenGLCompositor::GetFont(size_t fontIndex) const |
65 { | 63 { |
66 Fonts::const_iterator found = fonts_.find(fontIndex); | 64 Fonts::const_iterator found = fonts_.find(fontIndex); |
67 | 65 |
68 if (found == fonts_.end()) | 66 if (found == fonts_.end()) |
73 { | 71 { |
74 assert(found->second != NULL); | 72 assert(found->second != NULL); |
75 return found->second; | 73 return found->second; |
76 } | 74 } |
77 } | 75 } |
78 | |
79 | 76 |
80 Internals::CompositorHelper::ILayerRenderer* OpenGLCompositor::Create(const ISceneLayer& layer) | 77 Internals::CompositorHelper::ILayerRenderer* OpenGLCompositor::Create(const ISceneLayer& layer) |
81 { | 78 { |
82 switch (layer.GetType()) | 79 switch (layer.GetType()) |
83 { | 80 { |
120 default: | 117 default: |
121 return NULL; | 118 return NULL; |
122 } | 119 } |
123 } | 120 } |
124 | 121 |
125 | |
126 OpenGLCompositor::OpenGLCompositor(OpenGL::IOpenGLContext& context, | 122 OpenGLCompositor::OpenGLCompositor(OpenGL::IOpenGLContext& context, |
127 const Scene2D& scene) : | 123 const Scene2D& scene) : |
128 context_(context), | 124 context_(context), |
129 helper_(scene, *this), | 125 helper_(scene, *this), |
130 colorTextureProgram_(context), | 126 colorTextureProgram_(context), |
134 canvasWidth_(0), | 130 canvasWidth_(0), |
135 canvasHeight_(0) | 131 canvasHeight_(0) |
136 { | 132 { |
137 } | 133 } |
138 | 134 |
139 | |
140 OpenGLCompositor::~OpenGLCompositor() | 135 OpenGLCompositor::~OpenGLCompositor() |
141 { | 136 { |
142 for (Fonts::iterator it = fonts_.begin(); it != fonts_.end(); ++it) | 137 for (Fonts::iterator it = fonts_.begin(); it != fonts_.end(); ++it) |
143 { | 138 { |
144 assert(it->second != NULL); | 139 assert(it->second != NULL); |
145 delete it->second; | 140 delete it->second; |
146 } | 141 } |
147 } | 142 } |
148 | 143 |
149 | |
150 void OpenGLCompositor::Refresh() | 144 void OpenGLCompositor::Refresh() |
151 { | 145 { |
152 context_.MakeCurrent(); | 146 context_.MakeCurrent(); |
153 | 147 |
154 canvasWidth_ = context_.GetCanvasWidth(); | 148 canvasWidth_ = context_.GetCanvasWidth(); |
161 helper_.Refresh(canvasWidth_, canvasHeight_); | 155 helper_.Refresh(canvasWidth_, canvasHeight_); |
162 | 156 |
163 context_.SwapBuffer(); | 157 context_.SwapBuffer(); |
164 } | 158 } |
165 | 159 |
166 | |
167 void OpenGLCompositor::SetFont(size_t index, | 160 void OpenGLCompositor::SetFont(size_t index, |
168 const GlyphBitmapAlphabet& dict) | 161 const GlyphBitmapAlphabet& dict) |
169 { | 162 { |
170 context_.MakeCurrent(); | 163 context_.MakeCurrent(); |
171 | 164 |
183 delete found->second; | 176 delete found->second; |
184 | 177 |
185 found->second = font.release(); | 178 found->second = font.release(); |
186 } | 179 } |
187 } | 180 } |
188 | |
189 | 181 |
190 #if ORTHANC_ENABLE_LOCALE == 1 | 182 #if ORTHANC_ENABLE_LOCALE == 1 |
191 void OpenGLCompositor::SetFont(size_t index, | 183 void OpenGLCompositor::SetFont(size_t index, |
192 Orthanc::EmbeddedResources::FileResourceId resource, | 184 Orthanc::EmbeddedResources::FileResourceId resource, |
193 unsigned int fontSize, | 185 unsigned int fontSize, |