diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-06-24 20:24:06 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-06-24 20:24:06 -0700 |
commit | 682da36db9b39c9069b6a479c1ad9b14677deda4 (patch) | |
tree | 5b85e89a3f630226906ae1b54e9c535a70aaee78 /src/library_browser.js | |
parent | 415a82bfa600aa976749e01431376b9a0a3c4e0a (diff) | |
parent | 26f17cca734aca2b6717e16f0f22ead0e43571b8 (diff) |
Merge pull request #1302 from Manny-MADE/glut_fixes
Several GLUT library improvements
Diffstat (limited to 'src/library_browser.js')
-rw-r--r-- | src/library_browser.js | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/src/library_browser.js b/src/library_browser.js index 925b64e2..d007d9a7 100644 --- a/src/library_browser.js +++ b/src/library_browser.js @@ -426,8 +426,17 @@ mergeInto(LibraryManager.library, { Browser.mouseMovementX = Browser.getMovementX(event); Browser.mouseMovementY = Browser.getMovementY(event); } - Browser.mouseX = SDL.mouseX + Browser.mouseMovementX; - Browser.mouseY = SDL.mouseY + Browser.mouseMovementY; + + // check if SDL is available + if (typeof SDL != "undefined") { + Browser.mouseX = SDL.mouseX + Browser.mouseMovementX; + Browser.mouseY = SDL.mouseY + Browser.mouseMovementY; + } else { + // just add the mouse delta to the current absolut mouse position + // FIXME: ideally this should be clamped against the canvas size and zero + Browser.mouseX += Browser.mouseMovementX; + Browser.mouseY += Browser.mouseMovementY; + } } else { // Otherwise, calculate the movement based on the changes // in the coordinates. @@ -504,9 +513,12 @@ mergeInto(LibraryManager.library, { this.windowedHeight = canvas.height; canvas.width = screen.width; canvas.height = screen.height; - var flags = {{{ makeGetValue('SDL.screen+Runtime.QUANTUM_SIZE*0', '0', 'i32', 0, 1) }}}; - flags = flags | 0x00800000; // set SDL_FULLSCREEN flag - {{{ makeSetValue('SDL.screen+Runtime.QUANTUM_SIZE*0', '0', 'flags', 'i32') }}} + // check if SDL is available + if (typeof SDL != "undefined") { + var flags = {{{ makeGetValue('SDL.screen+Runtime.QUANTUM_SIZE*0', '0', 'i32', 0, 1) }}}; + flags = flags | 0x00800000; // set SDL_FULLSCREEN flag + {{{ makeSetValue('SDL.screen+Runtime.QUANTUM_SIZE*0', '0', 'flags', 'i32') }}} + } Browser.updateResizeListeners(); }, @@ -514,9 +526,12 @@ mergeInto(LibraryManager.library, { var canvas = Module['canvas']; canvas.width = this.windowedWidth; canvas.height = this.windowedHeight; - var flags = {{{ makeGetValue('SDL.screen+Runtime.QUANTUM_SIZE*0', '0', 'i32', 0, 1) }}}; - flags = flags & ~0x00800000; // clear SDL_FULLSCREEN flag - {{{ makeSetValue('SDL.screen+Runtime.QUANTUM_SIZE*0', '0', 'flags', 'i32') }}} + // check if SDL is available + if (typeof SDL != "undefined") { + var flags = {{{ makeGetValue('SDL.screen+Runtime.QUANTUM_SIZE*0', '0', 'i32', 0, 1) }}}; + flags = flags & ~0x00800000; // clear SDL_FULLSCREEN flag + {{{ makeSetValue('SDL.screen+Runtime.QUANTUM_SIZE*0', '0', 'flags', 'i32') }}} + } Browser.updateResizeListeners(); } |