Mercurial > hg > orthanc-stone
comparison Applications/Platforms/Sdl/SdlViewport.h @ 1804:5a872e69c74f
reorganization
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 20 May 2021 14:48:51 +0200 |
parents | 9ac2a65d4172 |
children | 3889ae96d2e9 |
comparison
equal
deleted
inserted
replaced
1803:d1849468729b | 1804:5a872e69c74f |
---|---|
30 | 30 |
31 #if !defined(ORTHANC_ENABLE_OPENGL) | 31 #if !defined(ORTHANC_ENABLE_OPENGL) |
32 # error The macro ORTHANC_ENABLE_OPENGL must be defined | 32 # error The macro ORTHANC_ENABLE_OPENGL must be defined |
33 #endif | 33 #endif |
34 | 34 |
35 #if ORTHANC_ENABLE_OPENGL != 1 | |
36 # error Support for OpenGL is disabled | |
37 #endif | |
38 | |
39 #include "SdlOpenGLContext.h" | 35 #include "SdlOpenGLContext.h" |
40 #include "../../../OrthancStone/Sources/Scene2D/OpenGLCompositor.h" | |
41 #include "../../../OrthancStone/Sources/Scene2D/CairoCompositor.h" | 36 #include "../../../OrthancStone/Sources/Scene2D/CairoCompositor.h" |
42 #include "../../../OrthancStone/Sources/Viewport/IViewport.h" | 37 #include "../../../OrthancStone/Sources/Viewport/IViewport.h" |
38 | |
39 #if ORTHANC_ENABLE_OPENGL == 1 | |
40 # include "../../../OrthancStone/Sources/Scene2D/OpenGLCompositor.h" | |
41 #endif | |
43 | 42 |
44 #include <SDL_events.h> | 43 #include <SDL_events.h> |
45 | 44 |
46 // TODO: required for UndoStack injection | 45 // TODO: required for UndoStack injection |
47 // I don't like it either :) | 46 // I don't like it either :) |
137 // Must be invoked from the main SDL thread | 136 // Must be invoked from the main SDL thread |
138 virtual void Paint() = 0; | 137 virtual void Paint() = 0; |
139 }; | 138 }; |
140 | 139 |
141 | 140 |
141 #if ORTHANC_ENABLE_OPENGL == 1 | |
142 class SdlOpenGLViewport : public SdlViewport | 142 class SdlOpenGLViewport : public SdlViewport |
143 { | 143 { |
144 private: | 144 private: |
145 SdlOpenGLContext context_; | 145 SdlOpenGLContext context_; |
146 | 146 |
151 | 151 |
152 protected: | 152 protected: |
153 virtual void RefreshCanvasSize() ORTHANC_OVERRIDE; | 153 virtual void RefreshCanvasSize() ORTHANC_OVERRIDE; |
154 | 154 |
155 public: | 155 public: |
156 static boost::shared_ptr<SdlOpenGLViewport> Create(const std::string&, | 156 static boost::shared_ptr<SdlOpenGLViewport> Create(const std::string& title, |
157 unsigned int width, | 157 unsigned int width, |
158 unsigned int height, | 158 unsigned int height, |
159 bool allowDpiScaling = true); | 159 bool allowDpiScaling = true); |
160 | 160 |
161 | 161 |
165 | 165 |
166 virtual void Paint() ORTHANC_OVERRIDE; | 166 virtual void Paint() ORTHANC_OVERRIDE; |
167 | 167 |
168 virtual void ToggleMaximize() ORTHANC_OVERRIDE; | 168 virtual void ToggleMaximize() ORTHANC_OVERRIDE; |
169 }; | 169 }; |
170 #endif | |
170 | 171 |
171 | 172 |
172 class SdlCairoViewport : public SdlViewport | 173 class SdlCairoViewport : public SdlViewport |
173 { | 174 { |
174 private: | 175 private: |
175 SdlWindow window_; | 176 SdlWindow window_; |
176 SDL_Surface* sdlSurface_; | 177 SDL_Surface* sdlSurface_; |
177 | 178 |
178 void CreateSdlSurfaceFromCompositor(const CairoCompositor& compositor); | 179 void CreateSdlSurfaceFromCompositor(const CairoCompositor& compositor); |
179 | 180 |
180 SdlCairoViewport(const char* title, | 181 SdlCairoViewport(const std::string& title, |
181 unsigned int width, | 182 unsigned int width, |
182 unsigned int height, | 183 unsigned int height, |
183 bool allowDpiScaling = true); | 184 bool allowDpiScaling); |
184 | 185 |
185 protected: | 186 protected: |
186 virtual void RefreshCanvasSize() ORTHANC_OVERRIDE; | 187 virtual void RefreshCanvasSize() ORTHANC_OVERRIDE; |
187 | 188 |
188 public: | 189 public: |
189 static boost::shared_ptr<SdlCairoViewport> Create(const char* title, | 190 static boost::shared_ptr<SdlCairoViewport> Create(const std::string& title, |
190 unsigned int width, | 191 unsigned int width, |
191 unsigned int height, | 192 unsigned int height, |
192 bool allowDpiScaling = true); | 193 bool allowDpiScaling = true); |
193 | |
194 | 194 |
195 virtual ~SdlCairoViewport(); | 195 virtual ~SdlCairoViewport(); |
196 | 196 |
197 virtual uint32_t GetSdlWindowId() ORTHANC_OVERRIDE; | 197 virtual uint32_t GetSdlWindowId() ORTHANC_OVERRIDE; |
198 | 198 |