aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/library_browser.js1
-rw-r--r--src/library_gl.js2
-rw-r--r--src/library_sdl.js44
3 files changed, 47 insertions, 0 deletions
diff --git a/src/library_browser.js b/src/library_browser.js
index d49c4103..e9860742 100644
--- a/src/library_browser.js
+++ b/src/library_browser.js
@@ -77,6 +77,7 @@ mergeInto(LibraryManager.library, {
}
if (setInModule) {
Module.ctx = ctx;
+ Module.useWebGL = useWebGL;
Browser.moduleContextCreatedCallbacks.forEach(function(callback) { callback() });
}
return ctx;
diff --git a/src/library_gl.js b/src/library_gl.js
index 3eba76d0..2be48ba1 100644
--- a/src/library_gl.js
+++ b/src/library_gl.js
@@ -1517,6 +1517,8 @@ var LibraryGL = {
Module.printErr('WARNING: using emscripten GL immediate mode emulation. This is very limited in what it supports');
GL.immediate.initted = true;
+ if (!Module.useWebGL) return; // a 2D canvas may be currently used TODO: make sure we are actually called in that case
+
this.matrixStack['m'] = [];
this.matrixStack['p'] = [];
for (var i = 0; i < GL.immediate.MAX_TEXTURES; i++) {
diff --git a/src/library_sdl.js b/src/library_sdl.js
index 85a04d27..442057c8 100644
--- a/src/library_sdl.js
+++ b/src/library_sdl.js
@@ -475,6 +475,37 @@ var LibrarySDL = {
return -1; // -1 == all modes are ok. TODO
},
+ SDL_VideoModeOK: function(width, height, depth, flags) {
+ // SDL_VideoModeOK returns 0 if the requested mode is not supported under any bit depth, or returns the
+ // bits-per-pixel of the closest available mode with the given width, height and requested surface flags
+ return depth; // all modes are ok.
+ },
+
+ SDL_VideoDriverName: function(buf, max_size) {
+ if (SDL.startTime === null) {
+ return 0; //return NULL
+ }
+ //driverName - emscripten_sdl_driver
+ var driverName = [101, 109, 115, 99, 114, 105, 112, 116, 101,
+ 110, 95, 115, 100, 108, 95, 100, 114, 105, 118, 101, 114];
+
+ var index = 0;
+ var size = driverName.length;
+
+ if (max_size <= size) {
+ size = max_size - 1; //-1 cause null-terminator
+ }
+
+ while (index < size) {
+ var value = driverName[index];
+ {{{ makeSetValue('buf', 'index', 'value', 'i8') }}};
+ index++;
+ }
+
+ {{{ makeSetValue('buf', 'index', '0', 'i8') }}};
+ return buf;
+ },
+
SDL_SetVideoMode: function(width, height, depth, flags) {
['mousedown', 'mouseup', 'mousemove', 'DOMMouseScroll'].forEach(function(event) {
Module['canvas'].addEventListener(event, SDL.receiveEvent, true);
@@ -484,6 +515,10 @@ var LibrarySDL = {
return SDL.screen = SDL.makeSurface(width, height, flags, true, 'screen');
},
+ SDL_QuitSubSystem: function(flags) {
+ Module.print('SDL_QuitSubSystem called (and ignored)');
+ },
+
SDL_Quit: function() {
for (var i = 0; i < SDL.audios; i++) {
SDL.audios[i].pause();
@@ -597,6 +632,10 @@ var LibrarySDL = {
// We actually do the whole screen in Unlock...
},
+ SDL_UpdateRects: function(surf, numrects, rects) {
+ // We actually do the whole screen in Unlock...
+ },
+
SDL_Delay: function(delay) {
throw 'SDL_Delay called! Potential infinite loop, quitting. ' + new Error().stack;
},
@@ -614,6 +653,11 @@ var LibrarySDL = {
return SDL.keyboardState;
},
+ SDL_GetKeyState__deps: ['SDL_GetKeyboardState'],
+ SDL_GetKeyState: function() {
+ return _SDL_GetKeyboardState();
+ },
+
SDL_GetModState: function() {
// TODO: numlock, capslock, etc.
return (SDL.shiftKey ? 0x0001 & 0x0002 : 0) | // KMOD_LSHIFT & KMOD_RSHIFT