annotate Samples/WebAssembly/BasicScene.cpp @ 890:77c96ba899f9

removing OpenGLCompositor::UpdateSize()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 10 Jul 2019 15:23:13 +0200
parents 2de01660debe
children 0aff28f15ea2 6073c980323a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
616
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Stone of Orthanc
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * the License, or (at your option) any later version.
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * Affero General Public License for more details.
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 *
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 **/
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
826
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 820
diff changeset
22 #include "dev.h"
616
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #include <emscripten.h>
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 #include <emscripten/html5.h>
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 // From Stone
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 #include "../../Framework/Scene2D/ColorTextureSceneLayer.h"
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 #include "../../Framework/StoneInitialization.h"
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 // From Orthanc framework
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 #include <Core/Images/Image.h>
617
7efa2543699d simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 616
diff changeset
33 #include <Core/Logging.h>
618
0925b27e8750 mouse events in wasm sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 617
diff changeset
34 #include <Core/OrthancException.h>
616
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35
826
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 820
diff changeset
36 void PrepareScene(OrthancStone::Scene2D& scene)
616
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 {
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 using namespace OrthancStone;
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 // Texture of 2x2 size
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 if (1)
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 {
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 Orthanc::Image i(Orthanc::PixelFormat_RGB24, 2, 2, false);
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 uint8_t *p = reinterpret_cast<uint8_t*>(i.GetRow(0));
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 p[0] = 255;
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 p[1] = 0;
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 p[2] = 0;
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 p[3] = 0;
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 p[4] = 255;
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 p[5] = 0;
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 p = reinterpret_cast<uint8_t*>(i.GetRow(1));
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 p[0] = 0;
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 p[1] = 0;
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 p[2] = 255;
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 p[3] = 255;
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 p[4] = 0;
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 p[5] = 0;
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62
826
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 820
diff changeset
63 scene.SetLayer(12, new ColorTextureSceneLayer(i));
616
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 std::auto_ptr<ColorTextureSceneLayer> l(new ColorTextureSceneLayer(i));
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 l->SetOrigin(-3, 2);
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 l->SetPixelSpacing(1.5, 1);
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 l->SetAngle(20.0 / 180.0 * M_PI);
826
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 820
diff changeset
69 scene.SetLayer(14, l.release());
616
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 }
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 // Texture of 1x1 size
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 if (1)
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 {
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 Orthanc::Image i(Orthanc::PixelFormat_RGB24, 1, 1, false);
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 uint8_t *p = reinterpret_cast<uint8_t*>(i.GetRow(0));
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 p[0] = 255;
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 p[1] = 0;
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 p[2] = 0;
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 std::auto_ptr<ColorTextureSceneLayer> l(new ColorTextureSceneLayer(i));
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 l->SetOrigin(-2, 1);
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 l->SetAngle(20.0 / 180.0 * M_PI);
826
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 820
diff changeset
85 scene.SetLayer(13, l.release());
616
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 }
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 // Some lines
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 {
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 std::auto_ptr<PolylineSceneLayer> layer(new PolylineSceneLayer);
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 layer->SetThickness(1);
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 PolylineSceneLayer::Chain chain;
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 chain.push_back(ScenePoint2D(0 - 0.5, 0 - 0.5));
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 chain.push_back(ScenePoint2D(0 - 0.5, 2 - 0.5));
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 chain.push_back(ScenePoint2D(2 - 0.5, 2 - 0.5));
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 chain.push_back(ScenePoint2D(2 - 0.5, 0 - 0.5));
820
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 756
diff changeset
99 layer->AddChain(chain, true, 255, 0, 0);
616
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 chain.clear();
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 chain.push_back(ScenePoint2D(-5, -5));
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 chain.push_back(ScenePoint2D(5, -5));
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 chain.push_back(ScenePoint2D(5, 5));
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 chain.push_back(ScenePoint2D(-5, 5));
820
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 756
diff changeset
106 layer->AddChain(chain, true, 0, 255, 0);
616
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 double dy = 1.01;
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 chain.clear();
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 chain.push_back(ScenePoint2D(-4, -4));
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 chain.push_back(ScenePoint2D(4, -4 + dy));
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 chain.push_back(ScenePoint2D(-4, -4 + 2.0 * dy));
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 chain.push_back(ScenePoint2D(4, 2));
820
270c31978df1 BasicMPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 756
diff changeset
114 layer->AddChain(chain, false, 0, 0, 255);
616
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115
826
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 820
diff changeset
116 scene.SetLayer(50, layer.release());
616
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 }
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 // Some text
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 if (1)
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 {
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122 std::auto_ptr<TextSceneLayer> layer(new TextSceneLayer);
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 layer->SetText("Hello");
826
2de01660debe reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 820
diff changeset
124 scene.SetLayer(100, layer.release());
616
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125 }
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 }
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127
617
7efa2543699d simplification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 616
diff changeset
128
618
0925b27e8750 mouse events in wasm sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 617
diff changeset
129 std::auto_ptr<OrthancStone::WebAssemblyViewport> viewport1_;
0925b27e8750 mouse events in wasm sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 617
diff changeset
130 std::auto_ptr<OrthancStone::WebAssemblyViewport> viewport2_;
0925b27e8750 mouse events in wasm sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 617
diff changeset
131 std::auto_ptr<OrthancStone::WebAssemblyViewport> viewport3_;
756
46403ab629f6 Added broker back because the ViewportController needs one
Benjamin Golinvaux <bgo@osimis.io>
parents: 754
diff changeset
132 OrthancStone::MessageBroker broker_;
616
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133
752
6030db24eaea Fixed wasm sample (BasicScene) according to changes (ViewportController) +
Benjamin Golinvaux <bgo@osimis.io>
parents: 665
diff changeset
134 EM_BOOL OnWindowResize(
6030db24eaea Fixed wasm sample (BasicScene) according to changes (ViewportController) +
Benjamin Golinvaux <bgo@osimis.io>
parents: 665
diff changeset
135 int eventType, const EmscriptenUiEvent *uiEvent, void *userData)
616
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136 {
618
0925b27e8750 mouse events in wasm sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 617
diff changeset
137 if (viewport1_.get() != NULL)
616
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138 {
618
0925b27e8750 mouse events in wasm sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 617
diff changeset
139 viewport1_->UpdateSize();
616
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140 }
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141
618
0925b27e8750 mouse events in wasm sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 617
diff changeset
142 if (viewport2_.get() != NULL)
616
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143 {
618
0925b27e8750 mouse events in wasm sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 617
diff changeset
144 viewport2_->UpdateSize();
616
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 }
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146
618
0925b27e8750 mouse events in wasm sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 617
diff changeset
147 if (viewport3_.get() != NULL)
616
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148 {
618
0925b27e8750 mouse events in wasm sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 617
diff changeset
149 viewport3_->UpdateSize();
616
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150 }
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152 return true;
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153 }
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155 extern "C"
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156 {
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157 int main(int argc, char const *argv[])
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158 {
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159 OrthancStone::StoneInitialize();
752
6030db24eaea Fixed wasm sample (BasicScene) according to changes (ViewportController) +
Benjamin Golinvaux <bgo@osimis.io>
parents: 665
diff changeset
160 // Orthanc::Logging::EnableInfoLevel(true);
6030db24eaea Fixed wasm sample (BasicScene) according to changes (ViewportController) +
Benjamin Golinvaux <bgo@osimis.io>
parents: 665
diff changeset
161 // Orthanc::Logging::EnableTraceLevel(true);
616
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162 EM_ASM(window.dispatchEvent(new CustomEvent("WebAssemblyLoaded")););
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163 }
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165 EMSCRIPTEN_KEEPALIVE
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166 void Initialize()
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167 {
752
6030db24eaea Fixed wasm sample (BasicScene) according to changes (ViewportController) +
Benjamin Golinvaux <bgo@osimis.io>
parents: 665
diff changeset
168 viewport1_.reset(
6030db24eaea Fixed wasm sample (BasicScene) according to changes (ViewportController) +
Benjamin Golinvaux <bgo@osimis.io>
parents: 665
diff changeset
169 new OrthancStone::WebAssemblyViewport(broker_, "mycanvas1"));
618
0925b27e8750 mouse events in wasm sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 617
diff changeset
170 PrepareScene(viewport1_->GetScene());
0925b27e8750 mouse events in wasm sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 617
diff changeset
171 viewport1_->UpdateSize();
616
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
172
752
6030db24eaea Fixed wasm sample (BasicScene) according to changes (ViewportController) +
Benjamin Golinvaux <bgo@osimis.io>
parents: 665
diff changeset
173 viewport2_.reset(
6030db24eaea Fixed wasm sample (BasicScene) according to changes (ViewportController) +
Benjamin Golinvaux <bgo@osimis.io>
parents: 665
diff changeset
174 new OrthancStone::WebAssemblyViewport(broker_, "mycanvas2"));
618
0925b27e8750 mouse events in wasm sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 617
diff changeset
175 PrepareScene(viewport2_->GetScene());
0925b27e8750 mouse events in wasm sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 617
diff changeset
176 viewport2_->UpdateSize();
616
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
177
752
6030db24eaea Fixed wasm sample (BasicScene) according to changes (ViewportController) +
Benjamin Golinvaux <bgo@osimis.io>
parents: 665
diff changeset
178 viewport3_.reset(
6030db24eaea Fixed wasm sample (BasicScene) according to changes (ViewportController) +
Benjamin Golinvaux <bgo@osimis.io>
parents: 665
diff changeset
179 new OrthancStone::WebAssemblyViewport(broker_, "mycanvas3"));
618
0925b27e8750 mouse events in wasm sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 617
diff changeset
180 PrepareScene(viewport3_->GetScene());
0925b27e8750 mouse events in wasm sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 617
diff changeset
181 viewport3_->UpdateSize();
616
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
182
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
183 emscripten_set_resize_callback("#window", NULL, false, OnWindowResize);
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
184 }
97926984d5d0 WebAssembly sample using Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
185 }