diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-04-09 15:52:13 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-04-09 15:52:13 -0700 |
commit | edf26eb8c4704fa07cc7e646b2b9ccd59a698467 (patch) | |
tree | 9b526877a52a7ba22063a12b9a6a65df9b782661 /src/library_sdl.js | |
parent | 7d71275571b6a4ea2c28eb6c1d47646491f23ad4 (diff) |
share context creation code between sdl and glut in browser
Diffstat (limited to 'src/library_sdl.js')
-rw-r--r-- | src/library_sdl.js | 26 |
1 files changed, 2 insertions, 24 deletions
diff --git a/src/library_sdl.js b/src/library_sdl.js index 24b90dce..c5190aa8 100644 --- a/src/library_sdl.js +++ b/src/library_sdl.js @@ -76,7 +76,7 @@ // * SDL_Quit does nothing. mergeInto(LibraryManager.library, { - $SDL__deps: ['$FS'], + $SDL__deps: ['$FS', '$Browser'], $SDL: { defaults: { width: 320, @@ -285,7 +285,7 @@ mergeInto(LibraryManager.library, { } else { canvas = Module['canvas']; } - var ctx = SDL.createContext(canvas, useWebGL); + var ctx = Browser.createContext(canvas, useWebGL); if (usePageCanvas) { Module.ctx = ctx; } @@ -306,28 +306,6 @@ mergeInto(LibraryManager.library, { return surf; }, - createContext: function(canvas, useWebGL) { -#if !USE_TYPED_ARRAYS - if (useWebGL) { - Module.print('(USE_TYPED_ARRAYS needs to be enabled for WebGL)'); - return null; - } -#endif - try { - var ctx = canvas.getContext(useWebGL ? 'experimental-webgl' : '2d'); - if (!ctx) throw 'Could not create canvas :('; - if (useWebGL) { - // Set the background of the WebGL canvas to black, because SDL gives us a - // window which has a black background by default. - canvas.style.backgroundColor = "black"; - } - return ctx; - } catch (e) { - Module.print('(canvas not available)'); - return null; - } - }, - freeSurface: function(surf) { _free(SDL.surfaces[surf].buffer); _free(SDL.surfaces[surf].pixelFormat); |