aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/library_glut.js48
1 files changed, 37 insertions, 11 deletions
diff --git a/src/library_glut.js b/src/library_glut.js
index 5d9fb672..b49073fb 100644
--- a/src/library_glut.js
+++ b/src/library_glut.js
@@ -18,6 +18,11 @@ var LibraryGLUT = {
modifiers: 0,
initWindowWidth: 256,
initWindowHeight: 256,
+ // Set when going fullscreen
+ windowX: 0,
+ windowY: 0,
+ windowWidth: 0,
+ windowHeight: 0,
savePosition: function(event) {
/* TODO maybe loop here ala http://www.quirksmode.org/js/findpos.html */
@@ -183,6 +188,31 @@ var LibraryGLUT = {
}
},
+ // TODO add fullscreen API ala:
+ // http://johndyer.name/native-fullscreen-javascript-api-plus-jquery-plugin/
+ onFullScreenEventChange: function(event){
+ var width;
+ var height;
+ if (document.fullScreen || document.mozFullScreen || document.webkitIsFullScreen) {
+ width = screen["width"];
+ height = screen["height"];
+ } else {
+ width = GLUT.windowWidth;
+ height = GLUT.windowHeight;
+ // TODO set position
+ document.removeEventListener('fullscreenchange', GLUT.onFullScreenEventChange, true);
+ document.removeEventListener('mozfullscreenchange', GLUT.onFullScreenEventChange, true);
+ document.removeEventListener('webkitfullscreenchange', GLUT.onFullScreenEventChange, true);
+ }
+ Module['canvas'].width = width;
+ Module['canvas'].height = height;
+ /* Can't call _glutReshapeWindow as that requests cancelling fullscreen. */
+ if (GLUT.reshapeFunc) {
+ FUNCTION_TABLE[GLUT.reshapeFunc](width, height);
+ }
+ _glutPostRedisplay();
+ },
+
requestFullScreen: function() {
var RFS = function() {};
if (Module["canvas"]['requestFullscreen']) {
@@ -423,18 +453,14 @@ var LibraryGLUT = {
glutFullScreen__deps: ['$GLUT', 'glutPostRedisplay'],
glutFullScreen: function() {
- var width = screen["width"];
- var height = screen["height"];
- /* Can't call _glutReshapeWindow as that requests cancelling fullscreen. */
- Module['canvas'].width = width;
- Module['canvas'].height = height;
- if (GLUT.reshapeFunc) {
- FUNCTION_TABLE[GLUT.reshapeFunc](width, height);
- }
+ GLUT.windowX = 0; // TODO
+ GLUT.windowY = 0; // TODO
+ GLUT.windowWidth = Module['canvas'].width;
+ GLUT.windowHeight = Module['canvas'].height;
+ document.addEventListener('fullscreenchange', GLUT.onFullScreenEventChange, true);
+ document.addEventListener('mozfullscreenchange', GLUT.onFullScreenEventChange, true);
+ document.addEventListener('webkitfullscreenchange', GLUT.onFullScreenEventChange, true);
GLUT.requestFullScreen();
- window.setTimeout(function() {
- _glutPostRedisplay();
- }, 0);
},
glutInitDisplayMode: function(mode) {},