aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJukka Jylänki <jujjyl@gmail.com>2012-06-05 00:23:17 +0300
committerJukka Jylänki <jujjyl@gmail.com>2012-06-05 00:23:17 +0300
commitc19e66ece36a240d0c49d43f0d2de875a07fe3d8 (patch)
tree7d0a67413b7e3ba3e5853ede8d661a9d70a05e56
parent6619a867c06b6e740bc9eaa37479aa10e492266c (diff)
Added a helper function emscripten_set_canvas_size function which allows to resize the <canvas> element on the web page in 'generic' fashion without having to depend on SDL or X11 headers in C code. This function is intended to be used in conjunction with EGL to specify a custom pixel resolution for the canvas (EGL API does not have expressiveness to do arbitrary pixel sizes).
-rw-r--r--src/library_browser.js5
-rw-r--r--system/include/emscripten.h6
2 files changed, 11 insertions, 0 deletions
diff --git a/src/library_browser.js b/src/library_browser.js
index e9860742..efb9e444 100644
--- a/src/library_browser.js
+++ b/src/library_browser.js
@@ -244,6 +244,11 @@ mergeInto(LibraryManager.library, {
styleSheet.insertRule('canvas.emscripten { border: 1px solid black; cursor: none; }', 0);
},
+ emscripten_set_canvas_size: function(width, height) {
+ Module['canvas'].width = width;
+ Module['canvas'].height = height;
+ },
+
emscripten_get_now: function() {
if (window['performance'] && window['performance']['now']) {
return window['performance']['now']();
diff --git a/system/include/emscripten.h b/system/include/emscripten.h
index d0e6cc46..4da31ec3 100644
--- a/system/include/emscripten.h
+++ b/system/include/emscripten.h
@@ -65,6 +65,12 @@ void emscripten_async_call(void (*func)(), int millis) {
void emscripten_hide_mouse();
/*
+ * Resizes the pixel width and height of the <canvas> element
+ * on the Emscripten web page.
+ */
+void emscripten_set_canvas_size(int width, int height);
+
+/*
* Returns the highest-precision representation of the
* current time that the browser provides. This uses either
* Date.now or performance.now. The result is *not* an