Mercurial > hg > orthanc-stone
annotate Samples/Sdl/RtViewer/RtViewerSdl.cpp @ 1389:5c83be3a6be5
split SDL / common + RtViewer rename + html test file
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Tue, 28 Apr 2020 08:58:41 +0200 |
parents | dfb48f0794b1 |
children | ffdb82850e98 |
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 |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
21 #include "RtViewer.h" |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
22 #include "SampleHelpers.h" |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
23 |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
24 #include <Framework/StoneException.h> |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
25 |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
26 #include <boost/program_options.hpp> |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
27 #include <SDL.h> |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
28 |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
29 #include <string> |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
30 |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
31 static void GLAPIENTRY |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
32 OpenGLMessageCallback(GLenum source, |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
33 GLenum type, |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
34 GLuint id, |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
35 GLenum severity, |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
36 GLsizei length, |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
37 const GLchar* message, |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
38 const void* userParam) |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
39 { |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
40 if (severity != GL_DEBUG_SEVERITY_NOTIFICATION) |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
41 { |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
42 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
|
43 (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
|
44 type, severity, message); |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
45 } |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
46 } |
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 namespace OrthancStone |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
49 { |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
50 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
|
51 { |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
52 namespace po = boost::program_options; |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
53 po::options_description desc("Usage:"); |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
54 |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
55 desc.add_options() |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
56 ("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
|
57 "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
|
58 |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
59 ("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
|
60 "Base URL of the Orthanc instance") |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
61 |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
62 ("ctseries", po::value<std::string>()->default_value("a04ecf01-79b2fc33-58239f7e-ad9db983-28e81afa"), |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
63 "Orthanc ID of the CT series to load") |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
64 |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
65 ("rtdose", po::value<std::string>()->default_value("830a69ff-8e4b5ee3-b7f966c8-bccc20fb-d322dceb"), |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
66 "Orthanc ID of the RTDOSE instance to load") |
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 ("rtstruct", po::value<std::string>()->default_value("54460695-ba3885ee-ddf61ac0-f028e31d-a6e474d9"), |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
69 "Orthanc ID of the RTSTRUCT instance to load") |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
70 ; |
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 po::variables_map vm; |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
73 try |
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 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
|
76 po::notify(vm); |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
77 } |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
78 catch (std::exception& e) |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
79 { |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
80 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
|
81 } |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
82 |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
83 if (vm.count("loglevel") > 0) |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
84 { |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
85 std::string logLevel = vm["loglevel"].as<std::string>(); |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
86 OrthancStoneHelpers::SetLogLevel(logLevel); |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
87 } |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
88 |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
89 if (vm.count("orthanc") > 0) |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
90 { |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
91 // maybe check URL validity here |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
92 orthancUrl_ = vm["orthanc"].as<std::string>(); |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
93 } |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
94 |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
95 if (vm.count("ctseries") > 0) |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
96 { |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
97 ctSeriesId_ = vm["ctseries"].as<std::string>(); |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
98 } |
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 if (vm.count("rtdose") > 0) |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
101 { |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
102 doseInstanceId_ = vm["rtdose"].as<std::string>(); |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
103 } |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
104 |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
105 if (vm.count("rtstruct") > 0) |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
106 { |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
107 rtStructInstanceId_ = vm["rtstruct"].as<std::string>(); |
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 } |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
110 |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
111 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
|
112 { |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
113 ProcessOptions(argc, argv); |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
114 |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
115 { |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
116 std::unique_ptr<IViewport::ILock> lock(viewport_->Lock()); |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
117 ViewportController& controller = lock->GetController(); |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
118 Scene2D& scene = controller.GetScene(); |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
119 ICompositor& compositor = lock->GetCompositor(); |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
120 |
1389
5c83be3a6be5
split SDL / common + RtViewer rename + html test file
Benjamin Golinvaux <bgo@osimis.io>
parents:
1386
diff
changeset
|
121 // False means we do NOT let a hi-DPI aware desktop managedr treat this as a legacy application that requires |
5c83be3a6be5
split SDL / common + RtViewer rename + html test file
Benjamin Golinvaux <bgo@osimis.io>
parents:
1386
diff
changeset
|
122 // scaling. |
1386
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
123 controller.FitContent(compositor.GetCanvasWidth(), compositor.GetCanvasHeight()); |
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 glEnable(GL_DEBUG_OUTPUT); |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
126 glDebugMessageCallback(OpenGLMessageCallback, 0); |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
127 |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
128 compositor.SetFont(0, Orthanc::EmbeddedResources::UBUNTU_FONT, |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
129 FONT_SIZE_0, Orthanc::Encoding_Latin1); |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
130 compositor.SetFont(1, Orthanc::EmbeddedResources::UBUNTU_FONT, |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
131 FONT_SIZE_1, Orthanc::Encoding_Latin1); |
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 //////// from loader |
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 loadersContext_.reset(new GenericLoadersContext(1, 4, 1)); |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
136 loadersContext_->StartOracle(); |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
137 |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
138 /** |
1389
5c83be3a6be5
split SDL / common + RtViewer rename + html test file
Benjamin Golinvaux <bgo@osimis.io>
parents:
1386
diff
changeset
|
139 It is very important that the Oracle (responsible for network I/O) be started before creating and firing the |
1386
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
140 loaders, for any command scheduled by the loader before the oracle is started will be lost. |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
141 */ |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
142 PrepareLoadersAndSlicers(); |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
143 |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
144 bool stopApplication = false; |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
145 |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
146 while (!stopApplication) |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
147 { |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
148 SDL_Event event; |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
149 while (!stopApplication && SDL_PollEvent(&event)) |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
150 { |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
151 if (event.type == SDL_QUIT) |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
152 { |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
153 stopApplication = true; |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
154 break; |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
155 } |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
156 else if (event.type == SDL_WINDOWEVENT && |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
157 event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED) |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
158 { |
1389
5c83be3a6be5
split SDL / common + RtViewer rename + html test file
Benjamin Golinvaux <bgo@osimis.io>
parents:
1386
diff
changeset
|
159 DisableTracker(); |
1386
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
160 } |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
161 else if (event.type == SDL_KEYDOWN && |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
162 event.key.repeat == 0 /* Ignore key bounce */) |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
163 { |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
164 switch (event.key.keysym.sym) |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
165 { |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
166 case SDLK_f: |
1389
5c83be3a6be5
split SDL / common + RtViewer rename + html test file
Benjamin Golinvaux <bgo@osimis.io>
parents:
1386
diff
changeset
|
167 // TODO: implement GetWindow to be able to do: |
5c83be3a6be5
split SDL / common + RtViewer rename + html test file
Benjamin Golinvaux <bgo@osimis.io>
parents:
1386
diff
changeset
|
168 // viewport_->GetWindow().ToggleMaximize(); |
1386
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
169 ORTHANC_ASSERT(false, "Please implement GetWindow()"); |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
170 break; |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
171 case SDLK_q: |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
172 stopApplication = true; |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
173 break; |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
174 default: |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
175 break; |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
176 } |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
177 } |
1389
5c83be3a6be5
split SDL / common + RtViewer rename + html test file
Benjamin Golinvaux <bgo@osimis.io>
parents:
1386
diff
changeset
|
178 // the code above is rather application-neutral. |
5c83be3a6be5
split SDL / common + RtViewer rename + html test file
Benjamin Golinvaux <bgo@osimis.io>
parents:
1386
diff
changeset
|
179 // the following call handles events specific to the application |
1386
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
180 HandleApplicationEvent(event); |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
181 } |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
182 SDL_Delay(1); |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
183 } |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
184 loadersContext_->StopOracle(); |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
185 } |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1384
diff
changeset
|
186 } |