Mercurial > hg > orthanc-stone
annotate Framework/OpenGL/SdlOpenGLContext.h @ 1268:9a0a95c0b578
sync
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 31 Jan 2020 17:25:27 +0100 |
parents | efc5b62b9539 |
children | 4cc997207d8a 2d8ab34c8c91 |
rev | line source |
---|---|
595
6e471e6cf09b
CairoPolylineRenderer, SdlOpenGLWindow
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
6e471e6cf09b
CairoPolylineRenderer, SdlOpenGLWindow
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Stone of Orthanc |
6e471e6cf09b
CairoPolylineRenderer, SdlOpenGLWindow
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
6e471e6cf09b
CairoPolylineRenderer, SdlOpenGLWindow
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
6e471e6cf09b
CairoPolylineRenderer, SdlOpenGLWindow
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium |
6e471e6cf09b
CairoPolylineRenderer, SdlOpenGLWindow
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 * |
6e471e6cf09b
CairoPolylineRenderer, SdlOpenGLWindow
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
6e471e6cf09b
CairoPolylineRenderer, SdlOpenGLWindow
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Affero General Public License |
6e471e6cf09b
CairoPolylineRenderer, SdlOpenGLWindow
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 * as published by the Free Software Foundation, either version 3 of |
6e471e6cf09b
CairoPolylineRenderer, SdlOpenGLWindow
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * the License, or (at your option) any later version. |
6e471e6cf09b
CairoPolylineRenderer, SdlOpenGLWindow
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * |
6e471e6cf09b
CairoPolylineRenderer, SdlOpenGLWindow
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, but |
6e471e6cf09b
CairoPolylineRenderer, SdlOpenGLWindow
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * WITHOUT ANY WARRANTY; without even the implied warranty of |
6e471e6cf09b
CairoPolylineRenderer, SdlOpenGLWindow
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
6e471e6cf09b
CairoPolylineRenderer, SdlOpenGLWindow
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * Affero General Public License for more details. |
6e471e6cf09b
CairoPolylineRenderer, SdlOpenGLWindow
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * |
6e471e6cf09b
CairoPolylineRenderer, SdlOpenGLWindow
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Affero General Public License |
6e471e6cf09b
CairoPolylineRenderer, SdlOpenGLWindow
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
6e471e6cf09b
CairoPolylineRenderer, SdlOpenGLWindow
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 **/ |
6e471e6cf09b
CairoPolylineRenderer, SdlOpenGLWindow
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 |
6e471e6cf09b
CairoPolylineRenderer, SdlOpenGLWindow
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 |
6e471e6cf09b
CairoPolylineRenderer, SdlOpenGLWindow
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 #pragma once |
6e471e6cf09b
CairoPolylineRenderer, SdlOpenGLWindow
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 |
6e471e6cf09b
CairoPolylineRenderer, SdlOpenGLWindow
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 #if ORTHANC_ENABLE_SDL == 1 |
6e471e6cf09b
CairoPolylineRenderer, SdlOpenGLWindow
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 |
1047 | 26 #include "IOpenGLContext.h" |
27 #include "../Viewport/SdlWindow.h" | |
595
6e471e6cf09b
CairoPolylineRenderer, SdlOpenGLWindow
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
891
diff
changeset
|
29 #include <Core/Enumerations.h> |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
891
diff
changeset
|
30 |
595
6e471e6cf09b
CairoPolylineRenderer, SdlOpenGLWindow
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 namespace OrthancStone |
6e471e6cf09b
CairoPolylineRenderer, SdlOpenGLWindow
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 { |
891
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
656
diff
changeset
|
33 class SdlOpenGLContext : public OpenGL::IOpenGLContext |
595
6e471e6cf09b
CairoPolylineRenderer, SdlOpenGLWindow
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 { |
6e471e6cf09b
CairoPolylineRenderer, SdlOpenGLWindow
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 private: |
6e471e6cf09b
CairoPolylineRenderer, SdlOpenGLWindow
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 SdlWindow window_; |
6e471e6cf09b
CairoPolylineRenderer, SdlOpenGLWindow
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 SDL_GLContext context_; |
6e471e6cf09b
CairoPolylineRenderer, SdlOpenGLWindow
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 |
6e471e6cf09b
CairoPolylineRenderer, SdlOpenGLWindow
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 public: |
891
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
656
diff
changeset
|
40 SdlOpenGLContext(const char* title, |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
656
diff
changeset
|
41 unsigned int width, |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
656
diff
changeset
|
42 unsigned int height, |
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
656
diff
changeset
|
43 bool allowDpiScaling = true); |
595
6e471e6cf09b
CairoPolylineRenderer, SdlOpenGLWindow
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 |
891
0aff28f15ea2
new abstraction: IViewport
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
656
diff
changeset
|
45 ~SdlOpenGLContext(); |
595
6e471e6cf09b
CairoPolylineRenderer, SdlOpenGLWindow
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 |
6e471e6cf09b
CairoPolylineRenderer, SdlOpenGLWindow
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 SdlWindow& GetWindow() |
6e471e6cf09b
CairoPolylineRenderer, SdlOpenGLWindow
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 { |
6e471e6cf09b
CairoPolylineRenderer, SdlOpenGLWindow
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 return window_; |
6e471e6cf09b
CairoPolylineRenderer, SdlOpenGLWindow
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 } |
6e471e6cf09b
CairoPolylineRenderer, SdlOpenGLWindow
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 |
1045
6a9300ecfa13
tests for context loss are now restricted to WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
52 virtual bool IsContextLost() ORTHANC_OVERRIDE |
6a9300ecfa13
tests for context loss are now restricted to WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
53 { |
6a9300ecfa13
tests for context loss are now restricted to WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
54 // On desktop applications, an OpenGL context should never be lost |
6a9300ecfa13
tests for context loss are now restricted to WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
55 return false; |
6a9300ecfa13
tests for context loss are now restricted to WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
956
diff
changeset
|
56 } |
595
6e471e6cf09b
CairoPolylineRenderer, SdlOpenGLWindow
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
891
diff
changeset
|
58 virtual void MakeCurrent() ORTHANC_OVERRIDE; |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
891
diff
changeset
|
59 |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
891
diff
changeset
|
60 virtual void SwapBuffer() ORTHANC_OVERRIDE; |
595
6e471e6cf09b
CairoPolylineRenderer, SdlOpenGLWindow
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 |
947
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
891
diff
changeset
|
62 virtual unsigned int GetCanvasWidth() const ORTHANC_OVERRIDE; |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
891
diff
changeset
|
63 |
1091b2adeb5a
Fixed animation frame stopping when returning false + big work on the OpenGL
Benjamin Golinvaux <bgo@osimis.io>
parents:
891
diff
changeset
|
64 virtual unsigned int GetCanvasHeight() const ORTHANC_OVERRIDE; |
595
6e471e6cf09b
CairoPolylineRenderer, SdlOpenGLWindow
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 }; |
6e471e6cf09b
CairoPolylineRenderer, SdlOpenGLWindow
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
66 } |
6e471e6cf09b
CairoPolylineRenderer, SdlOpenGLWindow
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
67 |
6e471e6cf09b
CairoPolylineRenderer, SdlOpenGLWindow
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
68 #endif |