mirror of https://github.com/mosra/magnum.git
Browse Source
Emscripten supports some hybrid between SDL1 and SDL2. I don't want to add Sdl1Application just for that and create more portability issues, so I just changed some things in Sdl2Application to be compatible with what Emscripten wants. Full SDL2 support is awaited in Emscripten, thus this is future-proof (rather than having SDL1 support, which would be deprecated later). Added documentation about Emscripten usage and template HTML markup to Sdl2Application docs, will move it somewhere else in the future when more than one Application will be supported (e.g. GLUT).pull/23/head
4 changed files with 171 additions and 9 deletions
@ -0,0 +1,44 @@
|
||||
var Module = { |
||||
preRun: [], |
||||
postRun: [], |
||||
|
||||
printErr: function(message) { |
||||
console.error(Array.prototype.slice.call(message).join(' ')); |
||||
}, |
||||
|
||||
print: function(message) { |
||||
console.log(Array.prototype.slice.call(message).join(' ')); |
||||
}, |
||||
|
||||
canvas: document.getElementById('module'), |
||||
|
||||
setStatus: function(message) { |
||||
var status = document.getElementById('status'); |
||||
if(status) status.innerHTML = message; |
||||
}, |
||||
|
||||
setStatusDescription: function(message) { |
||||
var statusDescription = document.getElementById('statusDescription'); |
||||
if(statusDescription) statusDescription.innerHTML = message; |
||||
}, |
||||
|
||||
totalDependencies: 0, |
||||
|
||||
monitorRunDependencies: function(left) { |
||||
this.totalDependencies = Math.max(this.totalDependencies, left); |
||||
|
||||
if(left) { |
||||
Module.setStatus('Downloading...'); |
||||
Module.setStatusDescription((this.totalDependencies - left) + '/' + this.totalDependencies); |
||||
} else { |
||||
Module.setStatus('Download complete'); |
||||
Module.setStatusDescription(''); |
||||
} |
||||
} |
||||
}; |
||||
|
||||
Module.setStatus('Downloading...'); |
||||
|
||||
Module.canvas.addEventListener('contextmenu', function(event) { |
||||
event.preventDefault(); |
||||
}, true); |
||||
Loading…
Reference in new issue