Scaling fix
This commit is contained in:
parent
5cb356125d
commit
b9d7d9ba7e
2 changed files with 10 additions and 13 deletions
|
|
@ -14,6 +14,8 @@
|
|||
margin: 0px;
|
||||
overflow: hidden;
|
||||
background-color: black;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
canvas.game_canvas {
|
||||
border: 0px none;
|
||||
|
|
@ -23,6 +25,8 @@
|
|||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
|
@ -45,7 +49,6 @@
|
|||
|
||||
return WebAssembly.instantiateStreaming(fetch("index.wasm"), newImports).then(function(output) {
|
||||
var e = output.instance.exports;
|
||||
console.log(e);
|
||||
odinMemoryInterface.setExports(e);
|
||||
odinMemoryInterface.setMemory(e.memory);
|
||||
return successCallback(output.instance);
|
||||
|
|
@ -55,16 +58,14 @@
|
|||
// done setting up. At that point we can run code.
|
||||
onRuntimeInitialized: () => {
|
||||
var e = wasmExports;
|
||||
|
||||
// Calls any procedure marked with @init
|
||||
e._start();
|
||||
|
||||
// See source/main_web/main_web.odin for main_start,
|
||||
// main_update and main_end.
|
||||
e.main_start();
|
||||
|
||||
function send_resize() {
|
||||
var canvas = document.getElementById('canvas');
|
||||
canvas.width = document.documentElement.clientWidth;
|
||||
canvas.height = document.documentElement.clientHeight;
|
||||
console.log(canvas.width, canvas.height);
|
||||
e.web_window_size_changed(canvas.width, canvas.height);
|
||||
}
|
||||
|
||||
|
|
@ -72,17 +73,11 @@
|
|||
send_resize();
|
||||
}, true);
|
||||
|
||||
// This can probably be done better: Ideally we'd feed the
|
||||
// initial size to `main_start`. But there seems to be a
|
||||
// race condition. `canvas` doesn't have it's correct size yet.
|
||||
send_resize();
|
||||
|
||||
// Runs the "main loop".
|
||||
function do_main_update() {
|
||||
if (!e.main_update()) {
|
||||
e.main_end();
|
||||
|
||||
// Calls procedures marked with @fini
|
||||
e._end();
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue