Mercurial > hg > orthanc-stone
annotate OrthancStone/Sources/Scene2D/OpenGLCompositor.cpp @ 1574:fb5e620430ae
fix
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 21 Sep 2020 18:29:53 +0200 |
parents | 85e117739eca |
children | 92fca2b3ba3d |
rev | line source |
---|---|
594 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
1270
2d8ab34c8c91
upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
949
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
594 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU Affero General Public License | |
9 * as published by the Free Software Foundation, either version 3 of | |
10 * the License, or (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * Affero General Public License for more details. | |
1327
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
16 * |
594 | 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/>. | |
19 **/ | |
20 | |
21 #include "OpenGLCompositor.h" | |
22 | |
23 #include "Internals/OpenGLAdvancedPolylineRenderer.h" | |
24 #include "Internals/OpenGLBasicPolylineRenderer.h" | |
25 #include "Internals/OpenGLColorTextureRenderer.h" | |
26 #include "Internals/OpenGLFloatTextureRenderer.h" | |
27 #include "Internals/OpenGLInfoPanelRenderer.h" | |
841
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
617
diff
changeset
|
28 #include "Internals/OpenGLLookupTableTextureRenderer.h" |
594 | 29 #include "Internals/OpenGLTextRenderer.h" |
30 | |
31 namespace OrthancStone | |
32 { | |
33 class OpenGLCompositor::Font : public boost::noncopyable | |
34 { | |
35 private: | |
1298
8a0a62189f46
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1270
diff
changeset
|
36 std::unique_ptr<GlyphTextureAlphabet> alphabet_; |
8a0a62189f46
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1270
diff
changeset
|
37 std::unique_ptr<OpenGL::OpenGLTexture> texture_; |
594 | 38 |
39 public: | |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
40 Font(OpenGL::IOpenGLContext& context, const GlyphBitmapAlphabet& dict) |
594 | 41 { |
42 alphabet_.reset(new GlyphTextureAlphabet(dict)); | |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
43 texture_.reset(new OpenGL::OpenGLTexture(context)); |
594 | 44 |
1298
8a0a62189f46
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1270
diff
changeset
|
45 std::unique_ptr<Orthanc::ImageAccessor> bitmap(alphabet_->ReleaseTexture()); |
594 | 46 texture_->Load(*bitmap, true /* enable linear interpolation */); |
47 } | |
48 | |
49 OpenGL::OpenGLTexture& GetTexture() const | |
50 { | |
51 assert(texture_.get() != NULL); | |
52 return *texture_; | |
53 } | |
54 | |
55 const GlyphTextureAlphabet& GetAlphabet() const | |
56 { | |
57 assert(alphabet_.get() != NULL); | |
58 return *alphabet_; | |
59 } | |
60 }; | |
61 | |
62 const OpenGLCompositor::Font* OpenGLCompositor::GetFont(size_t fontIndex) const | |
63 { | |
64 Fonts::const_iterator found = fonts_.find(fontIndex); | |
65 | |
66 if (found == fonts_.end()) | |
67 { | |
68 return NULL; // Unknown font, nothing should be drawn | |
69 } | |
70 else | |
71 { | |
72 assert(found->second != NULL); | |
73 return found->second; | |
74 } | |
75 } | |
76 | |
77 Internals::CompositorHelper::ILayerRenderer* OpenGLCompositor::Create(const ISceneLayer& layer) | |
78 { | |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
79 if (!context_.IsContextLost()) |
594 | 80 { |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
81 switch (layer.GetType()) |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
82 { |
594 | 83 case ISceneLayer::Type_InfoPanel: |
84 return new Internals::OpenGLInfoPanelRenderer | |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
85 (context_, colorTextureProgram_, dynamic_cast<const InfoPanelSceneLayer&>(layer)); |
594 | 86 |
87 case ISceneLayer::Type_ColorTexture: | |
88 return new Internals::OpenGLColorTextureRenderer | |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
89 (context_, colorTextureProgram_, dynamic_cast<const ColorTextureSceneLayer&>(layer)); |
594 | 90 |
91 case ISceneLayer::Type_FloatTexture: | |
92 return new Internals::OpenGLFloatTextureRenderer | |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
93 (context_, floatTextureProgram_, dynamic_cast<const FloatTextureSceneLayer&>(layer)); |
594 | 94 |
841
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
617
diff
changeset
|
95 case ISceneLayer::Type_LookupTableTexture: |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
617
diff
changeset
|
96 return new Internals::OpenGLLookupTableTextureRenderer |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
617
diff
changeset
|
97 (context_, colorTextureProgram_, dynamic_cast<const LookupTableTextureSceneLayer&>(layer)); |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
617
diff
changeset
|
98 |
594 | 99 case ISceneLayer::Type_Polyline: |
100 return new Internals::OpenGLAdvancedPolylineRenderer | |
1571 | 101 (context_, linesProgram_, dynamic_cast<const PolylineSceneLayer&>(layer)); |
594 | 102 //return new Internals::OpenGLBasicPolylineRenderer(context_, dynamic_cast<const PolylineSceneLayer&>(layer)); |
103 | |
104 case ISceneLayer::Type_Text: | |
105 { | |
106 const TextSceneLayer& l = dynamic_cast<const TextSceneLayer&>(layer); | |
107 const Font* font = GetFont(l.GetFontIndex()); | |
108 if (font == NULL) | |
109 { | |
949
32eaf4929b08
OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader now implement IGeometryProvider so that the geometry reference can be switched (CT or DOSE, for instance) + VolumeImageGeometry::SetSize renamed to VolumeImageGeometry::SetSizeInVoxels + prevent text layer update if text or properties do not change + a few stream operator<< for debug (Vector, Matrix,...) + fixed memory access aligment issues in ImageBuffer3D::ExtractSagittalSlice + fix for wrong screen Y offset of mpr slices in DicomVolumeImageMPRSlicer.
Benjamin Golinvaux <bgo@osimis.io>
parents:
947
diff
changeset
|
110 LOG(WARNING) << "There is no font at index " << l.GetFontIndex(); |
594 | 111 return NULL; |
112 } | |
113 else | |
114 { | |
115 return new Internals::OpenGLTextRenderer | |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
116 (context_, textProgram_, font->GetAlphabet(), font->GetTexture(), l); |
594 | 117 } |
118 } | |
119 | |
120 default: | |
121 return NULL; | |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
122 } |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
123 } |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
124 else |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
125 { |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
126 // context is lost. returning null. |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
127 return NULL; |
594 | 128 } |
129 } | |
130 | |
1211
d10d2acb8a02
compositors do not keep a reference to the scene anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
949
diff
changeset
|
131 OpenGLCompositor::OpenGLCompositor(OpenGL::IOpenGLContext& context) : |
594 | 132 context_(context), |
133 colorTextureProgram_(context), | |
134 floatTextureProgram_(context), | |
135 linesProgram_(context), | |
136 textProgram_(context), | |
137 canvasWidth_(0), | |
138 canvasHeight_(0) | |
139 { | |
1246
3fe803f65c47
proper initialization of opengl canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1211
diff
changeset
|
140 if (!context_.IsContextLost()) |
3fe803f65c47
proper initialization of opengl canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1211
diff
changeset
|
141 { |
3fe803f65c47
proper initialization of opengl canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1211
diff
changeset
|
142 canvasWidth_ = context_.GetCanvasWidth(); |
3fe803f65c47
proper initialization of opengl canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1211
diff
changeset
|
143 canvasHeight_ = context_.GetCanvasHeight(); |
3fe803f65c47
proper initialization of opengl canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1211
diff
changeset
|
144 } |
3fe803f65c47
proper initialization of opengl canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1211
diff
changeset
|
145 |
1211
d10d2acb8a02
compositors do not keep a reference to the scene anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
949
diff
changeset
|
146 ResetScene(); |
594 | 147 } |
148 | |
149 OpenGLCompositor::~OpenGLCompositor() | |
150 { | |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
151 if (!context_.IsContextLost()) |
594 | 152 { |
1327
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
153 try |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
154 { |
1327
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
155 try |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
156 { |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
157 context_.MakeCurrent(); // this can throw if context lost! |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
158 } |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
159 catch (...) |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
160 { |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
161 LOG(ERROR) << "context_.MakeCurrent() failed in OpenGLCompositor::~OpenGLCompositor()!"; |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
162 } |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
163 |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
164 for (Fonts::iterator it = fonts_.begin(); it != fonts_.end(); ++it) |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
165 { |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
166 try |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
167 { |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
168 |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
169 assert(it->second != NULL); |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
170 delete it->second; |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
171 } |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
172 catch (...) |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
173 { |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
174 LOG(ERROR) << "Exception thrown while deleting OpenGL-based font!"; |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
175 } |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
176 } |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
177 } |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
178 catch (...) |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
179 { |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
180 // logging threw an exception! |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
181 } |
594 | 182 } |
183 } | |
184 | |
1211
d10d2acb8a02
compositors do not keep a reference to the scene anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
949
diff
changeset
|
185 void OpenGLCompositor::Refresh(const Scene2D& scene) |
594 | 186 { |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
187 if (!context_.IsContextLost()) |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
188 { |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
189 context_.MakeCurrent(); // this can throw if context lost! |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
190 canvasWidth_ = context_.GetCanvasWidth(); |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
191 canvasHeight_ = context_.GetCanvasHeight(); |
594 | 192 |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
193 glViewport(0, 0, canvasWidth_, canvasHeight_); |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
194 glClearColor(0, 0, 0, 1); |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
195 glClear(GL_COLOR_BUFFER_BIT); |
594 | 196 |
1211
d10d2acb8a02
compositors do not keep a reference to the scene anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
949
diff
changeset
|
197 helper_->Refresh(scene, canvasWidth_, canvasHeight_); |
594 | 198 |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
199 context_.SwapBuffer(); |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
200 } |
594 | 201 } |
202 | |
203 void OpenGLCompositor::SetFont(size_t index, | |
204 const GlyphBitmapAlphabet& dict) | |
205 { | |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
206 if (!context_.IsContextLost()) |
594 | 207 { |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
208 context_.MakeCurrent(); // this can throw if context lost |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
209 |
1298
8a0a62189f46
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1270
diff
changeset
|
210 std::unique_ptr<Font> font(new Font(context_, dict)); |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
211 |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
212 Fonts::iterator found = fonts_.find(index); |
594 | 213 |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
214 if (found == fonts_.end()) |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
215 { |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
216 fonts_[index] = font.release(); |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
217 } |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
218 else |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
219 { |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
220 assert(found->second != NULL); |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
221 delete found->second; |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
222 |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
223 found->second = font.release(); |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
224 } |
594 | 225 } |
226 } | |
227 | |
228 #if ORTHANC_ENABLE_LOCALE == 1 | |
229 void OpenGLCompositor::SetFont(size_t index, | |
1471
28c64c246312
working on a shared library
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1327
diff
changeset
|
230 const std::string& ttf, |
594 | 231 unsigned int fontSize, |
232 Orthanc::Encoding codepage) | |
233 { | |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
234 if (!context_.IsContextLost()) |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
235 { |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
236 FontRenderer renderer; |
1471
28c64c246312
working on a shared library
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1327
diff
changeset
|
237 renderer.LoadFont(ttf, fontSize); |
594 | 238 |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
239 GlyphBitmapAlphabet dict; |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
240 dict.LoadCodepage(renderer, codepage); |
594 | 241 |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
242 SetFont(index, dict); |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
942
diff
changeset
|
243 } |
594 | 244 } |
245 #endif | |
1482
5c96bf3f1d32
IOpenGL::RefreshCanvasSize()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1471
diff
changeset
|
246 |
5c96bf3f1d32
IOpenGL::RefreshCanvasSize()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1471
diff
changeset
|
247 |
5c96bf3f1d32
IOpenGL::RefreshCanvasSize()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1471
diff
changeset
|
248 void OpenGLCompositor::RefreshCanvasSize() |
5c96bf3f1d32
IOpenGL::RefreshCanvasSize()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1471
diff
changeset
|
249 { |
5c96bf3f1d32
IOpenGL::RefreshCanvasSize()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1471
diff
changeset
|
250 if (!context_.IsContextLost()) |
5c96bf3f1d32
IOpenGL::RefreshCanvasSize()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1471
diff
changeset
|
251 { |
5c96bf3f1d32
IOpenGL::RefreshCanvasSize()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1471
diff
changeset
|
252 context_.MakeCurrent(); // this can throw if context lost! |
5c96bf3f1d32
IOpenGL::RefreshCanvasSize()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1471
diff
changeset
|
253 context_.RefreshCanvasSize(); // Difference with Refresh(scene) |
5c96bf3f1d32
IOpenGL::RefreshCanvasSize()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1471
diff
changeset
|
254 canvasWidth_ = context_.GetCanvasWidth(); |
5c96bf3f1d32
IOpenGL::RefreshCanvasSize()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1471
diff
changeset
|
255 canvasHeight_ = context_.GetCanvasHeight(); |
5c96bf3f1d32
IOpenGL::RefreshCanvasSize()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1471
diff
changeset
|
256 } |
5c96bf3f1d32
IOpenGL::RefreshCanvasSize()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1471
diff
changeset
|
257 } |
594 | 258 } |