comparison Platforms/WebAssembly/wasm-application.ts @ 231:5027cb2feb51 am

viewport is now part of the Application itself and not global anymore
author am@osimis.io
date Thu, 14 Jun 2018 18:49:19 +0200
parents 7d2631320615
children 68856534f005
comparison
equal deleted inserted replaced
230:7d2631320615 231:5027cb2feb51
4 if (!('WebAssembly' in window)) { 4 if (!('WebAssembly' in window)) {
5 alert('Sorry, your browser does not support WebAssembly :('); 5 alert('Sorry, your browser does not support WebAssembly :(');
6 } 6 }
7 7
8 declare var StoneFrameworkModule : Stone.Framework; 8 declare var StoneFrameworkModule : Stone.Framework;
9
10 var viewport = null;
11 9
12 // global functions 10 // global functions
13 var WasmWebService_NotifyError: Function = null; 11 var WasmWebService_NotifyError: Function = null;
14 var WasmWebService_NotifySuccess: Function = null; 12 var WasmWebService_NotifySuccess: Function = null;
15 var NotifyUpdateContent: Function = null; 13 var NotifyUpdateContent: Function = null;
75 } 73 }
76 74
77 75
78 function InitializeWasmApplication(canvasId: string): void { 76 function InitializeWasmApplication(canvasId: string): void {
79 77
80 console.log("Creating main viewport");
81
82 viewport = new Stone.WasmViewport(StoneFrameworkModule, canvasId);
83 viewport.Initialize(CreateCppViewport());
84
85 document.getElementById(canvasId).onclick = function () {
86 viewport.Redraw();
87 };
88
89
90 /************************************** */ 78 /************************************** */
91 CreateWasmApplication(); 79 CreateWasmApplication();
92 80
93 // parse uri and transmit the parameters to the app before initializing it 81 // parse uri and transmit the parameters to the app before initializing it
94 var parameters = GetUriParameters(); 82 var parameters = GetUriParameters();
97 if (parameters.hasOwnProperty(key)) { 85 if (parameters.hasOwnProperty(key)) {
98 SetStartupParameter(key, parameters[key]); 86 SetStartupParameter(key, parameters[key]);
99 } 87 }
100 } 88 }
101 89
102 StartWasmApplication(viewport.GetCppViewport()); 90 StartWasmApplication();
103 /************************************** */ 91 /************************************** */
104 92
105 UpdateContentThread(); 93 UpdateContentThread();
106 } 94 }
107 95
110 Stone.Framework.Initialize(true, function () { 98 Stone.Framework.Initialize(true, function () {
111 99
112 console.log("Connecting C++ methods to JS methods"); 100 console.log("Connecting C++ methods to JS methods");
113 101
114 SetStartupParameter = StoneFrameworkModule.cwrap('SetStartupParameter', null, ['string', 'string']); 102 SetStartupParameter = StoneFrameworkModule.cwrap('SetStartupParameter', null, ['string', 'string']);
115 CreateWasmApplication = StoneFrameworkModule.cwrap('CreateWasmApplication', null, ['any']); 103 CreateWasmApplication = StoneFrameworkModule.cwrap('CreateWasmApplication', null, ['number']);
116 CreateCppViewport = StoneFrameworkModule.cwrap('CreateCppViewport', 'any', []); 104 CreateCppViewport = StoneFrameworkModule.cwrap('CreateCppViewport', 'number', []);
117 ReleaseCppViewport = StoneFrameworkModule.cwrap('ReleaseCppViewport', null, ['any']); 105 ReleaseCppViewport = StoneFrameworkModule.cwrap('ReleaseCppViewport', null, ['number']);
118 StartWasmApplication = StoneFrameworkModule.cwrap('StartWasmApplication', null, []); 106 StartWasmApplication = StoneFrameworkModule.cwrap('StartWasmApplication', null, []);
119 107
120 WasmWebService_NotifySuccess = StoneFrameworkModule.cwrap('WasmWebService_NotifySuccess', null, ['number', 'string', 'array', 'number', 'number']); 108 WasmWebService_NotifySuccess = StoneFrameworkModule.cwrap('WasmWebService_NotifySuccess', null, ['number', 'string', 'array', 'number', 'number']);
121 WasmWebService_NotifyError = StoneFrameworkModule.cwrap('WasmWebService_NotifyError', null, ['number', 'string', 'number']); 109 WasmWebService_NotifyError = StoneFrameworkModule.cwrap('WasmWebService_NotifyError', null, ['number', 'string', 'number']);
122 NotifyUpdateContent = StoneFrameworkModule.cwrap('NotifyUpdateContent', null, []); 110 NotifyUpdateContent = StoneFrameworkModule.cwrap('NotifyUpdateContent', null, []);