Mercurial > hg > orthanc-stone
annotate Applications/Samples/Sdl/RtViewer/RtViewerSdl.cpp @ 1591:5887a4f8594b
moving platform-specific files out of the "OrthancStone" folder
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 23 Oct 2020 13:15:03 +0200 |
parents | 92fca2b3ba3d |
children | 4c9e68291467 |
rev | line source |
---|---|
1386
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
1 /** |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
2 * Stone of Orthanc |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
6 * |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
8 * modify it under the terms of the GNU Affero General Public License |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
9 * as published by the Free Software Foundation, either version 3 of |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
10 * the License, or (at your option) any later version. |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
11 * |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, but |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
13 * WITHOUT ANY WARRANTY; without even the implied warranty of |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
15 * Affero General Public License for more details. |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
16 * |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
17 * You should have received a copy of the GNU Affero General Public License |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
19 **/ |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
20 |
1457 | 21 #include "../../Common/RtViewerApp.h" |
22 #include "../../Common/RtViewerView.h" | |
1392
ffdb82850e98
Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1389
diff
changeset
|
23 #include "../SdlHelpers.h" |
1386
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
24 |
1471
28c64c246312
working on a shared library
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1457
diff
changeset
|
25 #include <EmbeddedResources.h> |
28c64c246312
working on a shared library
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1457
diff
changeset
|
26 |
1393
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
27 // Stone of Orthanc includes |
1542 | 28 #include "../../../../OrthancStone/Sources/Loaders/GenericLoadersContext.h" |
29 #include "../../../../OrthancStone/Sources/OpenGL/OpenGLIncludes.h" | |
30 #include "../../../../OrthancStone/Sources/StoneException.h" | |
31 #include "../../../../OrthancStone/Sources/StoneInitialization.h" | |
1591
5887a4f8594b
moving platform-specific files out of the "OrthancStone" folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1576
diff
changeset
|
32 #include "../../../Platforms/Sdl/SdlOpenGLContext.h" |
1392
ffdb82850e98
Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1389
diff
changeset
|
33 |
1393
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
34 // Orthanc (a.o. for screenshot capture) |
1507
169adf9090a6
replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1471
diff
changeset
|
35 #include <Compatibility.h> // For std::unique_ptr<> |
1457 | 36 #include <Images/Image.h> |
37 #include <Images/ImageProcessing.h> | |
38 #include <Images/PngWriter.h> | |
1393
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
39 |
1386
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
40 |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
41 #include <boost/program_options.hpp> |
1393
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
42 #include <boost/shared_ptr.hpp> |
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
43 |
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
44 // #include <boost/pointer_cast.hpp> this include might be necessary in more recent boost versions |
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
45 |
1386
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
46 #include <SDL.h> |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
47 |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
48 #include <string> |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
49 |
1430
5128b448a6ee
yet another try to fix OS X
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1429
diff
changeset
|
50 |
1431
1eaf19af15bf
OpenGL: OS X does not seem to support debug output functionality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1430
diff
changeset
|
51 #if !defined(__APPLE__) |
1eaf19af15bf
OpenGL: OS X does not seem to support debug output functionality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1430
diff
changeset
|
52 /** |
1eaf19af15bf
OpenGL: OS X does not seem to support debug output functionality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1430
diff
changeset
|
53 * OpenGL: "OS X does not seem to support debug output functionality |
1eaf19af15bf
OpenGL: OS X does not seem to support debug output functionality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1430
diff
changeset
|
54 * (as gathered online)." |
1eaf19af15bf
OpenGL: OS X does not seem to support debug output functionality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1430
diff
changeset
|
55 * https://learnopengl.com/In-Practice/Debugging |
1eaf19af15bf
OpenGL: OS X does not seem to support debug output functionality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1430
diff
changeset
|
56 **/ |
1430
5128b448a6ee
yet another try to fix OS X
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1429
diff
changeset
|
57 static void GLAPIENTRY |
1386
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
58 OpenGLMessageCallback(GLenum source, |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
59 GLenum type, |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
60 GLuint id, |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
61 GLenum severity, |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
62 GLsizei length, |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
63 const GLchar* message, |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
64 const void* userParam) |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
65 { |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
66 if (severity != GL_DEBUG_SEVERITY_NOTIFICATION) |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
67 { |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
68 fprintf(stderr, "GL CALLBACK: %s type = 0x%x, severity = 0x%x, message = %s\n", |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
69 (type == GL_DEBUG_TYPE_ERROR ? "** GL ERROR **" : ""), |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
70 type, severity, message); |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
71 } |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
72 } |
1431
1eaf19af15bf
OpenGL: OS X does not seem to support debug output functionality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1430
diff
changeset
|
73 #endif |
1386
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
74 |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
75 namespace OrthancStone |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
76 { |
1404
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
77 void RtViewerView::EnableGLDebugOutput() |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
78 { |
1431
1eaf19af15bf
OpenGL: OS X does not seem to support debug output functionality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1430
diff
changeset
|
79 #if !defined(__APPLE__) |
1404
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
80 glEnable(GL_DEBUG_OUTPUT); |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
81 glDebugMessageCallback(OpenGLMessageCallback, 0); |
1431
1eaf19af15bf
OpenGL: OS X does not seem to support debug output functionality
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1430
diff
changeset
|
82 #endif |
1404
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
83 } |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
84 |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
85 boost::shared_ptr<IViewport> RtViewerView::CreateViewport(const std::string& canvasId) |
1393
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
86 { |
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
87 // False means we do NOT let Windows treat this as a legacy application that needs to be scaled |
1404
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
88 return SdlOpenGLViewport::Create(canvasId, 1024, 1024, false); |
1393
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
89 } |
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
90 |
1386
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
91 void RtViewerApp::ProcessOptions(int argc, char* argv[]) |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
92 { |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
93 namespace po = boost::program_options; |
1532
c7a37c3a0b8e
print help in sdl samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1525
diff
changeset
|
94 po::options_description desc("Usage"); |
1386
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
95 |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
96 desc.add_options() |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
97 ("loglevel", po::value<std::string>()->default_value("WARNING"), |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
98 "You can choose WARNING, INFO or TRACE for the logging level: Errors and warnings will always be displayed. (default: WARNING)") |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
99 |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
100 ("orthanc", po::value<std::string>()->default_value("http://localhost:8042"), |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
101 "Base URL of the Orthanc instance") |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
102 |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
103 ("ctseries", po::value<std::string>()->default_value("a04ecf01-79b2fc33-58239f7e-ad9db983-28e81afa"), |
1525
31b0449a163a
JPEG mode re-enabled in MPR RT viewer + some docs
Benjamin Golinvaux <bgo@osimis.io>
parents:
1517
diff
changeset
|
104 "Orthanc ID of the CT series to load. This must be supplied.") |
1386
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
105 |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
106 ("rtdose", po::value<std::string>()->default_value("830a69ff-8e4b5ee3-b7f966c8-bccc20fb-d322dceb"), |
1525
31b0449a163a
JPEG mode re-enabled in MPR RT viewer + some docs
Benjamin Golinvaux <bgo@osimis.io>
parents:
1517
diff
changeset
|
107 "Orthanc ID of the RTDOSE instance to load. This may be an empty string.") |
1386
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
108 |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
109 ("rtstruct", po::value<std::string>()->default_value("54460695-ba3885ee-ddf61ac0-f028e31d-a6e474d9"), |
1525
31b0449a163a
JPEG mode re-enabled in MPR RT viewer + some docs
Benjamin Golinvaux <bgo@osimis.io>
parents:
1517
diff
changeset
|
110 "Orthanc ID of the RTSTRUCT instance to load. This may be an empty string.") |
1386
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
111 ; |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
112 |
1532
c7a37c3a0b8e
print help in sdl samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1525
diff
changeset
|
113 std::cout << desc << std::endl; |
c7a37c3a0b8e
print help in sdl samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1525
diff
changeset
|
114 |
1386
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
115 po::variables_map vm; |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
116 try |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
117 { |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
118 po::store(po::parse_command_line(argc, argv, desc), vm); |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
119 po::notify(vm); |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
120 } |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
121 catch (std::exception& e) |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
122 { |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
123 std::cerr << "Please check your command line options! (\"" << e.what() << "\")" << std::endl; |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
124 } |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
125 |
1393
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
126 for (po::variables_map::iterator it = vm.begin(); it != vm.end(); ++it) |
1386
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
127 { |
1393
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
128 std::string key = it->first; |
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
129 const po::variable_value& value = it->second; |
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
130 const std::string& strValue = value.as<std::string>(); |
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
131 SetArgument(key, strValue); |
1386
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
132 } |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
133 } |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
134 |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
135 void RtViewerApp::RunSdl(int argc, char* argv[]) |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
136 { |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
137 ProcessOptions(argc, argv); |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
138 |
1392
ffdb82850e98
Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1389
diff
changeset
|
139 /** |
ffdb82850e98
Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1389
diff
changeset
|
140 Create the shared loaders context |
ffdb82850e98
Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1389
diff
changeset
|
141 */ |
ffdb82850e98
Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1389
diff
changeset
|
142 loadersContext_.reset(new GenericLoadersContext(1, 4, 1)); |
1393
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
143 |
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
144 // we are in SDL --> downcast to concrete type |
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
145 boost::shared_ptr<GenericLoadersContext> loadersContext = boost::dynamic_pointer_cast<GenericLoadersContext>(loadersContext_); |
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
146 |
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
147 /** |
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
148 Url of the Orthanc instance |
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
149 Typically, in a native application (Qt, SDL), it will be an absolute URL like "http://localhost:8042". In |
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
150 wasm on the browser, it could be an absolute URL, provided you do not have cross-origin problems, or a relative |
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
151 URL. In our wasm samples, it is set to "..", because we set up either a reverse proxy or an Orthanc ServeFolders |
1517
307a805d0587
rtviewer --> stone-rtviewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
1512
diff
changeset
|
152 plugin that serves the main web application from an URL like "http://localhost:8042/stone-rtviewer" (with ".." |
307a805d0587
rtviewer --> stone-rtviewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
1512
diff
changeset
|
153 leading to the main Orthanc root URL) |
1393
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
154 */ |
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
155 std::string orthancUrl = arguments_["orthanc"]; |
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
156 |
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
157 { |
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
158 Orthanc::WebServiceParameters p; |
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
159 if (HasArgument("orthanc")) |
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
160 { |
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
161 p.SetUrl(orthancUrl); |
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
162 } |
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
163 if (HasArgument("user")) |
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
164 { |
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
165 ORTHANC_ASSERT(HasArgument("password")); |
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
166 p.SetCredentials(GetArgument("user"), GetArgument("password")); |
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
167 } |
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
168 else |
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
169 { |
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
170 ORTHANC_ASSERT(!HasArgument("password")); |
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
171 } |
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
172 loadersContext->SetOrthancParameters(p); |
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
173 } |
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
174 |
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
175 loadersContext->StartOracle(); |
1392
ffdb82850e98
Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1389
diff
changeset
|
176 |
1404
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
177 CreateLoaders(); |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
178 |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
179 /** |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
180 Create viewports |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
181 */ |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
182 CreateView("RtViewer Axial", VolumeProjection_Axial); |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
183 CreateView("RtViewer Coronal", VolumeProjection_Coronal); |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
184 CreateView("RtViewer Sagittal", VolumeProjection_Sagittal); |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
185 |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
186 for (size_t i = 0; i < views_.size(); ++i) |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
187 { |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
188 views_[i]->PrepareViewport(); |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
189 views_[i]->EnableGLDebugOutput(); |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
190 } |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
191 |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
192 DefaultViewportInteractor interactor; |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
193 |
1392
ffdb82850e98
Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1389
diff
changeset
|
194 /** |
ffdb82850e98
Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1389
diff
changeset
|
195 It is very important that the Oracle (responsible for network I/O) be started before creating and firing the |
ffdb82850e98
Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1389
diff
changeset
|
196 loaders, for any command scheduled by the loader before the oracle is started will be lost. |
ffdb82850e98
Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1389
diff
changeset
|
197 */ |
1404
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
198 StartLoaders(); |
1392
ffdb82850e98
Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1389
diff
changeset
|
199 |
1393
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
200 |
1406
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
201 SdlRunLoop(views_, interactor); |
1393
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
202 loadersContext->StopOracle(); |
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
203 } |
1392
ffdb82850e98
Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1389
diff
changeset
|
204 |
1404
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
205 void RtViewerView::TakeScreenshot(const std::string& target, |
1393
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
206 unsigned int canvasWidth, |
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
207 unsigned int canvasHeight) |
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
208 { |
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
209 std::unique_ptr<IViewport::ILock> lock(viewport_->Lock()); |
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
210 ViewportController& controller = lock->GetController(); |
1573 | 211 const Scene2D& scene = controller.GetScene(); |
1392
ffdb82850e98
Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1389
diff
changeset
|
212 |
1471
28c64c246312
working on a shared library
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1457
diff
changeset
|
213 std::string ttf; |
28c64c246312
working on a shared library
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1457
diff
changeset
|
214 Orthanc::EmbeddedResources::GetFileResource(ttf, Orthanc::EmbeddedResources::UBUNTU_FONT); |
28c64c246312
working on a shared library
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1457
diff
changeset
|
215 |
1393
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
216 CairoCompositor compositor(canvasWidth, canvasHeight); |
1471
28c64c246312
working on a shared library
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1457
diff
changeset
|
217 compositor.SetFont(0, ttf, FONT_SIZE_0, Orthanc::Encoding_Latin1); |
1393
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
218 compositor.Refresh(scene); |
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
219 |
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
220 Orthanc::ImageAccessor canvas; |
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
221 compositor.GetCanvas().GetReadOnlyAccessor(canvas); |
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
222 |
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
223 Orthanc::Image png(Orthanc::PixelFormat_RGB24, canvas.GetWidth(), canvas.GetHeight(), false); |
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
224 Orthanc::ImageProcessing::Convert(png, canvas); |
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
225 |
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
226 Orthanc::PngWriter writer; |
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
227 writer.WriteToFile(target, png); |
1392
ffdb82850e98
Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1389
diff
changeset
|
228 } |
1406
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
229 |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
230 static boost::shared_ptr<OrthancStone::RtViewerView> GetViewFromWindowId( |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
231 const std::vector<boost::shared_ptr<OrthancStone::RtViewerView> >& views, |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
232 Uint32 windowID) |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
233 { |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
234 using namespace OrthancStone; |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
235 for (size_t i = 0; i < views.size(); ++i) |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
236 { |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
237 boost::shared_ptr<OrthancStone::RtViewerView> view = views[i]; |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
238 boost::shared_ptr<IViewport> viewport = view->GetViewport(); |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
239 boost::shared_ptr<SdlViewport> sdlViewport = boost::dynamic_pointer_cast<SdlViewport>(viewport); |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
240 Uint32 curWindowID = sdlViewport->GetSdlWindowId(); |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
241 if (windowID == curWindowID) |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
242 return view; |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
243 } |
1427 | 244 return boost::shared_ptr<OrthancStone::RtViewerView>(); |
1406
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
245 } |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
246 |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
247 void RtViewerApp::SdlRunLoop(const std::vector<boost::shared_ptr<OrthancStone::RtViewerView> >& views, |
1535
301571299212
DefaultViewportInteractor::SetWindowingLayer()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1532
diff
changeset
|
248 OrthancStone::DefaultViewportInteractor& interactor) |
1406
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
249 { |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
250 using namespace OrthancStone; |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
251 |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
252 // const std::vector<boost::shared_ptr<OrthancStone::RtViewerView> >& views |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
253 std::vector<boost::shared_ptr<OrthancStone::SdlViewport> > viewports; |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
254 for (size_t i = 0; i < views.size(); ++i) |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
255 { |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
256 boost::shared_ptr<RtViewerView> view = views[i]; |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
257 boost::shared_ptr<IViewport> viewport = view->GetViewport(); |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
258 boost::shared_ptr<SdlViewport> sdlViewport = |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
259 boost::dynamic_pointer_cast<SdlViewport>(viewport); |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
260 viewports.push_back(sdlViewport); |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
261 } |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
262 |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
263 { |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
264 int scancodeCount = 0; |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
265 const uint8_t* keyboardState = SDL_GetKeyboardState(&scancodeCount); |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
266 |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
267 bool stop = false; |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
268 while (!stop) |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
269 { |
1434
c6bfcc105414
Rewrite of the event loop to compact all refresh events. HUGE speedup when using the trackers, especially in Debug mode.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1431
diff
changeset
|
270 std::vector<SDL_Event> sdlEvents; |
c6bfcc105414
Rewrite of the event loop to compact all refresh events. HUGE speedup when using the trackers, especially in Debug mode.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1431
diff
changeset
|
271 std::map<Uint32,SDL_Event> userEventsMap; |
c6bfcc105414
Rewrite of the event loop to compact all refresh events. HUGE speedup when using the trackers, especially in Debug mode.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1431
diff
changeset
|
272 |
1406
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
273 { |
1573 | 274 SDL_Event sdlEvent; |
275 | |
276 // FIRST: collect all pending events | |
277 while (SDL_PollEvent(&sdlEvent) != 0) | |
1434
c6bfcc105414
Rewrite of the event loop to compact all refresh events. HUGE speedup when using the trackers, especially in Debug mode.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1431
diff
changeset
|
278 { |
1573 | 279 if ( (sdlEvent.type >= SDL_USEREVENT) && |
280 (sdlEvent.type < SDL_LASTEVENT) ) | |
281 { | |
282 // we don't want to have multiple refresh events , | |
283 // and since every refresh event is a user event with a special type, | |
284 // we use a map | |
285 userEventsMap[sdlEvent.type] = sdlEvent; | |
286 } | |
287 else | |
288 { | |
289 sdlEvents.push_back(sdlEvent); | |
290 } | |
1434
c6bfcc105414
Rewrite of the event loop to compact all refresh events. HUGE speedup when using the trackers, especially in Debug mode.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1431
diff
changeset
|
291 } |
c6bfcc105414
Rewrite of the event loop to compact all refresh events. HUGE speedup when using the trackers, especially in Debug mode.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1431
diff
changeset
|
292 } |
c6bfcc105414
Rewrite of the event loop to compact all refresh events. HUGE speedup when using the trackers, especially in Debug mode.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1431
diff
changeset
|
293 |
c6bfcc105414
Rewrite of the event loop to compact all refresh events. HUGE speedup when using the trackers, especially in Debug mode.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1431
diff
changeset
|
294 // SECOND: add all user events to sdlEvents |
c6bfcc105414
Rewrite of the event loop to compact all refresh events. HUGE speedup when using the trackers, especially in Debug mode.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1431
diff
changeset
|
295 for (std::map<Uint32,SDL_Event>::const_iterator it = userEventsMap.begin(); it != userEventsMap.end(); ++it) |
1573 | 296 { |
1434
c6bfcc105414
Rewrite of the event loop to compact all refresh events. HUGE speedup when using the trackers, especially in Debug mode.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1431
diff
changeset
|
297 sdlEvents.push_back(it->second); |
1573 | 298 } |
1434
c6bfcc105414
Rewrite of the event loop to compact all refresh events. HUGE speedup when using the trackers, especially in Debug mode.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1431
diff
changeset
|
299 |
c6bfcc105414
Rewrite of the event loop to compact all refresh events. HUGE speedup when using the trackers, especially in Debug mode.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1431
diff
changeset
|
300 // now process the events |
c6bfcc105414
Rewrite of the event loop to compact all refresh events. HUGE speedup when using the trackers, especially in Debug mode.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1431
diff
changeset
|
301 for (std::vector<SDL_Event>::const_iterator it = sdlEvents.begin(); it != sdlEvents.end(); ++it) |
c6bfcc105414
Rewrite of the event loop to compact all refresh events. HUGE speedup when using the trackers, especially in Debug mode.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1431
diff
changeset
|
302 { |
c6bfcc105414
Rewrite of the event loop to compact all refresh events. HUGE speedup when using the trackers, especially in Debug mode.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1431
diff
changeset
|
303 const SDL_Event& sdlEvent = *it; |
c6bfcc105414
Rewrite of the event loop to compact all refresh events. HUGE speedup when using the trackers, especially in Debug mode.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1431
diff
changeset
|
304 |
c6bfcc105414
Rewrite of the event loop to compact all refresh events. HUGE speedup when using the trackers, especially in Debug mode.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1431
diff
changeset
|
305 if (sdlEvent.type == SDL_QUIT) |
1406
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
306 { |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
307 stop = true; |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
308 break; |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
309 } |
1434
c6bfcc105414
Rewrite of the event loop to compact all refresh events. HUGE speedup when using the trackers, especially in Debug mode.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1431
diff
changeset
|
310 else if (sdlEvent.type == SDL_WINDOWEVENT && |
c6bfcc105414
Rewrite of the event loop to compact all refresh events. HUGE speedup when using the trackers, especially in Debug mode.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1431
diff
changeset
|
311 (sdlEvent.window.event == SDL_WINDOWEVENT_RESIZED || |
c6bfcc105414
Rewrite of the event loop to compact all refresh events. HUGE speedup when using the trackers, especially in Debug mode.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1431
diff
changeset
|
312 sdlEvent.window.event == SDL_WINDOWEVENT_SIZE_CHANGED)) |
1406
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
313 { |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
314 boost::shared_ptr<RtViewerView> view = GetViewFromWindowId( |
1434
c6bfcc105414
Rewrite of the event loop to compact all refresh events. HUGE speedup when using the trackers, especially in Debug mode.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1431
diff
changeset
|
315 views, sdlEvent.window.windowID); |
1406
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
316 |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
317 boost::shared_ptr<SdlViewport> sdlViewport = |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
318 boost::dynamic_pointer_cast<SdlViewport>(view->GetViewport()); |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
319 |
1434
c6bfcc105414
Rewrite of the event loop to compact all refresh events. HUGE speedup when using the trackers, especially in Debug mode.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1431
diff
changeset
|
320 sdlViewport->UpdateSize(sdlEvent.window.data1, sdlEvent.window.data2); |
1406
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
321 } |
1434
c6bfcc105414
Rewrite of the event loop to compact all refresh events. HUGE speedup when using the trackers, especially in Debug mode.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1431
diff
changeset
|
322 else if (sdlEvent.type == SDL_WINDOWEVENT && |
c6bfcc105414
Rewrite of the event loop to compact all refresh events. HUGE speedup when using the trackers, especially in Debug mode.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1431
diff
changeset
|
323 (sdlEvent.window.event == SDL_WINDOWEVENT_SHOWN || |
c6bfcc105414
Rewrite of the event loop to compact all refresh events. HUGE speedup when using the trackers, especially in Debug mode.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1431
diff
changeset
|
324 sdlEvent.window.event == SDL_WINDOWEVENT_EXPOSED)) |
1406
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
325 { |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
326 boost::shared_ptr<RtViewerView> view = GetViewFromWindowId( |
1434
c6bfcc105414
Rewrite of the event loop to compact all refresh events. HUGE speedup when using the trackers, especially in Debug mode.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1431
diff
changeset
|
327 views, sdlEvent.window.windowID); |
1406
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
328 boost::shared_ptr<SdlViewport> sdlViewport = |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
329 boost::dynamic_pointer_cast<SdlViewport>(view->GetViewport()); |
1576
92fca2b3ba3d
sanitizing the handling of canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1573
diff
changeset
|
330 |
92fca2b3ba3d
sanitizing the handling of canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1573
diff
changeset
|
331 { |
92fca2b3ba3d
sanitizing the handling of canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1573
diff
changeset
|
332 std::unique_ptr<OrthancStone::IViewport::ILock> lock(sdlViewport->Lock()); |
92fca2b3ba3d
sanitizing the handling of canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1573
diff
changeset
|
333 lock->RefreshCanvasSize(); |
92fca2b3ba3d
sanitizing the handling of canvas size
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1573
diff
changeset
|
334 } |
1406
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
335 } |
1434
c6bfcc105414
Rewrite of the event loop to compact all refresh events. HUGE speedup when using the trackers, especially in Debug mode.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1431
diff
changeset
|
336 else if (sdlEvent.type == SDL_KEYDOWN && |
c6bfcc105414
Rewrite of the event loop to compact all refresh events. HUGE speedup when using the trackers, especially in Debug mode.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1431
diff
changeset
|
337 sdlEvent.key.repeat == 0 /* Ignore key bounce */) |
1406
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
338 { |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
339 boost::shared_ptr<RtViewerView> view = GetViewFromWindowId( |
1434
c6bfcc105414
Rewrite of the event loop to compact all refresh events. HUGE speedup when using the trackers, especially in Debug mode.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1431
diff
changeset
|
340 views, sdlEvent.window.windowID); |
1406
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
341 |
1434
c6bfcc105414
Rewrite of the event loop to compact all refresh events. HUGE speedup when using the trackers, especially in Debug mode.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1431
diff
changeset
|
342 switch (sdlEvent.key.keysym.sym) |
1406
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
343 { |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
344 case SDLK_f: |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
345 { |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
346 boost::shared_ptr<SdlViewport> sdlViewport = |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
347 boost::dynamic_pointer_cast<SdlViewport>(view->GetViewport()); |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
348 sdlViewport->ToggleMaximize(); |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
349 } |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
350 break; |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
351 |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
352 case SDLK_s: |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
353 { |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
354 std::unique_ptr<OrthancStone::IViewport::ILock> lock(view->GetViewport()->Lock()); |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
355 lock->GetCompositor().FitContent(lock->GetController().GetScene()); |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
356 lock->Invalidate(); |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
357 } |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
358 break; |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
359 |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
360 case SDLK_q: |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
361 stop = true; |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
362 break; |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
363 |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
364 default: |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
365 break; |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
366 } |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
367 } |
1434
c6bfcc105414
Rewrite of the event loop to compact all refresh events. HUGE speedup when using the trackers, especially in Debug mode.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1431
diff
changeset
|
368 else if (sdlEvent.type == SDL_MOUSEBUTTONDOWN || |
c6bfcc105414
Rewrite of the event loop to compact all refresh events. HUGE speedup when using the trackers, especially in Debug mode.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1431
diff
changeset
|
369 sdlEvent.type == SDL_MOUSEMOTION || |
c6bfcc105414
Rewrite of the event loop to compact all refresh events. HUGE speedup when using the trackers, especially in Debug mode.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1431
diff
changeset
|
370 sdlEvent.type == SDL_MOUSEBUTTONUP) |
1406
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
371 { |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
372 boost::shared_ptr<RtViewerView> view = GetViewFromWindowId( |
1434
c6bfcc105414
Rewrite of the event loop to compact all refresh events. HUGE speedup when using the trackers, especially in Debug mode.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1431
diff
changeset
|
373 views, sdlEvent.window.windowID); |
1406
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
374 |
1507
169adf9090a6
replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1471
diff
changeset
|
375 std::unique_ptr<OrthancStone::IViewport::ILock> lock(view->GetViewport()->Lock()); |
1406
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
376 if (lock->HasCompositor()) |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
377 { |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
378 OrthancStone::PointerEvent p; |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
379 OrthancStoneHelpers::GetPointerEvent(p, lock->GetCompositor(), |
1434
c6bfcc105414
Rewrite of the event loop to compact all refresh events. HUGE speedup when using the trackers, especially in Debug mode.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1431
diff
changeset
|
380 sdlEvent, keyboardState, scancodeCount); |
1406
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
381 |
1434
c6bfcc105414
Rewrite of the event loop to compact all refresh events. HUGE speedup when using the trackers, especially in Debug mode.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1431
diff
changeset
|
382 switch (sdlEvent.type) |
1406
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
383 { |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
384 case SDL_MOUSEBUTTONDOWN: |
1535
301571299212
DefaultViewportInteractor::SetWindowingLayer()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1532
diff
changeset
|
385 interactor.SetWindowingLayer(view->GetCtLayerIndex()); |
1406
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
386 lock->GetController().HandleMousePress(interactor, p, |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
387 lock->GetCompositor().GetCanvasWidth(), |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
388 lock->GetCompositor().GetCanvasHeight()); |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
389 lock->Invalidate(); |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
390 break; |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
391 |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
392 case SDL_MOUSEMOTION: |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
393 if (lock->GetController().HandleMouseMove(p)) |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
394 { |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
395 lock->Invalidate(); |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
396 } |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
397 break; |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
398 |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
399 case SDL_MOUSEBUTTONUP: |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
400 lock->GetController().HandleMouseRelease(p); |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
401 lock->Invalidate(); |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
402 break; |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
403 |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
404 default: |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
405 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
406 } |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
407 } |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
408 } |
1434
c6bfcc105414
Rewrite of the event loop to compact all refresh events. HUGE speedup when using the trackers, especially in Debug mode.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1431
diff
changeset
|
409 else if (sdlEvent.type == SDL_MOUSEWHEEL) |
1406
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
410 { |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
411 boost::shared_ptr<RtViewerView> view = GetViewFromWindowId( |
1434
c6bfcc105414
Rewrite of the event loop to compact all refresh events. HUGE speedup when using the trackers, especially in Debug mode.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1431
diff
changeset
|
412 views, sdlEvent.window.windowID); |
1406
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
413 |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
414 int delta = 0; |
1434
c6bfcc105414
Rewrite of the event loop to compact all refresh events. HUGE speedup when using the trackers, especially in Debug mode.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1431
diff
changeset
|
415 if (sdlEvent.wheel.y < 0) |
1406
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
416 delta = -1; |
1434
c6bfcc105414
Rewrite of the event loop to compact all refresh events. HUGE speedup when using the trackers, especially in Debug mode.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1431
diff
changeset
|
417 if (sdlEvent.wheel.y > 0) |
1406
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
418 delta = 1; |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
419 |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
420 view->Scroll(delta); |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
421 } |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
422 else |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
423 { |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
424 for (size_t i = 0; i < views.size(); ++i) |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
425 { |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
426 boost::shared_ptr<SdlViewport> sdlViewport = |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
427 boost::dynamic_pointer_cast<SdlViewport>(views[i]->GetViewport()); |
1434
c6bfcc105414
Rewrite of the event loop to compact all refresh events. HUGE speedup when using the trackers, especially in Debug mode.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1431
diff
changeset
|
428 if (sdlViewport->IsRefreshEvent(sdlEvent)) |
c6bfcc105414
Rewrite of the event loop to compact all refresh events. HUGE speedup when using the trackers, especially in Debug mode.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1431
diff
changeset
|
429 { |
1406
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
430 sdlViewport->Paint(); |
1434
c6bfcc105414
Rewrite of the event loop to compact all refresh events. HUGE speedup when using the trackers, especially in Debug mode.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1431
diff
changeset
|
431 } |
1406
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
432 } |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
433 } |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
434 } |
1408
875c9a28236e
Fixed busy CPU in RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
1406
diff
changeset
|
435 // Small delay to avoid using 100% of CPU |
875c9a28236e
Fixed busy CPU in RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
1406
diff
changeset
|
436 SDL_Delay(1); |
1406
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
437 } |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
438 } |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
439 } |
1386
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
440 } |
1392
ffdb82850e98
Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1389
diff
changeset
|
441 |
ffdb82850e98
Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1389
diff
changeset
|
442 boost::weak_ptr<OrthancStone::RtViewerApp> g_app; |
ffdb82850e98
Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1389
diff
changeset
|
443 |
ffdb82850e98
Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1389
diff
changeset
|
444 /** |
ffdb82850e98
Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1389
diff
changeset
|
445 * IMPORTANT: The full arguments to "main()" are needed for SDL on |
ffdb82850e98
Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1389
diff
changeset
|
446 * Windows. Otherwise, one gets the linking error "undefined reference |
ffdb82850e98
Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1389
diff
changeset
|
447 * to `SDL_main'". https://wiki.libsdl.org/FAQWindows |
ffdb82850e98
Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1389
diff
changeset
|
448 **/ |
ffdb82850e98
Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1389
diff
changeset
|
449 int main(int argc, char* argv[]) |
ffdb82850e98
Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1389
diff
changeset
|
450 { |
ffdb82850e98
Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1389
diff
changeset
|
451 using namespace OrthancStone; |
ffdb82850e98
Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1389
diff
changeset
|
452 |
ffdb82850e98
Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1389
diff
changeset
|
453 StoneInitialize(); |
1591
5887a4f8594b
moving platform-specific files out of the "OrthancStone" folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1576
diff
changeset
|
454 OrthancStone::SdlWindow::GlobalInitialize(); |
1392
ffdb82850e98
Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1389
diff
changeset
|
455 |
ffdb82850e98
Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1389
diff
changeset
|
456 try |
ffdb82850e98
Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1389
diff
changeset
|
457 { |
ffdb82850e98
Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1389
diff
changeset
|
458 boost::shared_ptr<RtViewerApp> app = RtViewerApp::Create(); |
ffdb82850e98
Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1389
diff
changeset
|
459 g_app = app; |
ffdb82850e98
Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1389
diff
changeset
|
460 app->RunSdl(argc,argv); |
ffdb82850e98
Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1389
diff
changeset
|
461 } |
ffdb82850e98
Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1389
diff
changeset
|
462 catch (Orthanc::OrthancException& e) |
ffdb82850e98
Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1389
diff
changeset
|
463 { |
ffdb82850e98
Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1389
diff
changeset
|
464 LOG(ERROR) << "EXCEPTION: " << e.What(); |
ffdb82850e98
Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1389
diff
changeset
|
465 } |
1591
5887a4f8594b
moving platform-specific files out of the "OrthancStone" folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1576
diff
changeset
|
466 |
5887a4f8594b
moving platform-specific files out of the "OrthancStone" folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1576
diff
changeset
|
467 OrthancStone::SdlWindow::GlobalFinalize(); |
1392
ffdb82850e98
Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1389
diff
changeset
|
468 StoneFinalize(); |
ffdb82850e98
Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1389
diff
changeset
|
469 |
ffdb82850e98
Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1389
diff
changeset
|
470 return 0; |
ffdb82850e98
Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1389
diff
changeset
|
471 } |
ffdb82850e98
Sdl run loop in /Common (might revert if need to customize)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1389
diff
changeset
|
472 |