comparison Framework/Viewport/SdlViewport.h @ 891:0aff28f15ea2

new abstraction: IViewport
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 10 Jul 2019 18:18:42 +0200
parents
children 0c5201499af8
comparison
equal deleted inserted replaced
890:77c96ba899f9 891:0aff28f15ea2
1 /**
2 * Stone of Orthanc
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
4 * Department, University Hospital of Liege, Belgium
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium
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.
16 *
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 #pragma once
22
23 #if !defined(ORTHANC_ENABLE_SDL)
24 # error Macro ORTHANC_ENABLE_SDL must be defined
25 #endif
26
27 #if ORTHANC_ENABLE_SDL != 1
28 # error SDL must be enabled to use this file
29 #endif
30
31 #if !defined(ORTHANC_ENABLE_OPENGL)
32 # error The macro ORTHANC_ENABLE_OPENGL must be defined
33 #endif
34
35 #if ORTHANC_ENABLE_OPENGL != 1
36 # error Support for OpenGL is disabled
37 #endif
38
39 #include "../../Applications/Sdl/SdlOpenGLContext.h"
40 #include "../Scene2D/OpenGLCompositor.h"
41 #include "ViewportBase.h"
42
43 namespace OrthancStone
44 {
45 class SdlViewport : public ViewportBase
46 {
47 private:
48 SdlOpenGLContext context_;
49 OpenGLCompositor compositor_;
50
51 public:
52 SdlViewport(const char* title,
53 unsigned int width,
54 unsigned int height);
55
56 SdlViewport(const char* title,
57 unsigned int width,
58 unsigned int height,
59 boost::shared_ptr<Scene2D>& scene);
60
61 virtual void Refresh()
62 {
63 compositor_.Refresh();
64 }
65
66 virtual unsigned int GetCanvasWidth() const
67 {
68 return compositor_.GetCanvasWidth();
69 }
70
71 virtual unsigned int GetCanvasHeight() const
72 {
73 return compositor_.GetCanvasHeight();
74 }
75
76 OpenGLCompositor& GetCompositor()
77 {
78 return compositor_;
79 }
80
81 SdlOpenGLContext& GetContext()
82 {
83 return context_;
84 }
85 };
86 }