diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-07-25 11:30:15 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-07-25 11:30:15 -0700 |
commit | 96cdbee9649d440161cff3088ca2a82ec1e54c78 (patch) | |
tree | a80e3e61e955582d7d29bd4d4800901302d96409 | |
parent | 5739787049a07e1bf478af4bffad9e8906fb1e4b (diff) |
allow apps to link both GL and SDL 2D backends and use just one
-rw-r--r-- | src/library_gl.js | 4 | ||||
-rw-r--r-- | tests/sdl_canvas.c | 13 |
2 files changed, 15 insertions, 2 deletions
diff --git a/src/library_gl.js b/src/library_gl.js index adf9d611..fb9a57a0 100644 --- a/src/library_gl.js +++ b/src/library_gl.js @@ -169,6 +169,8 @@ var LibraryGL = { if (GL.initExtensions.done) return; GL.initExtensions.done = true; + if (!Module.useWebGL) return; // an app might link both gl and 2d backends + GL.compressionExt = Module.ctx.getExtension('WEBGL_compressed_texture_s3tc') || Module.ctx.getExtension('MOZ_WEBGL_compressed_texture_s3tc') || Module.ctx.getExtension('WEBKIT_WEBGL_compressed_texture_s3tc'); @@ -1362,7 +1364,7 @@ var LibraryGL = { // GL Immediate mode $GLImmediate__postset: 'Browser.moduleContextCreatedCallbacks.push(function() { GL.immediate.init() });', - $GLImmediate__deps: ['$Browser'], + $GLImmediate__deps: ['$Browser', '$GL'], $GLImmediate: { MAX_TEXTURES: 7, diff --git a/tests/sdl_canvas.c b/tests/sdl_canvas.c index ab1340a8..5d1c849c 100644 --- a/tests/sdl_canvas.c +++ b/tests/sdl_canvas.c @@ -3,7 +3,18 @@ #include <SDL/SDL_ttf.h> #include <emscripten.h> -int main() { + +int main(int argc, char **argv) { +#if EMSCRIPTEN + // include GL stuff, to check that we can compile hybrid 2d/GL apps + extern void glBegin(int mode); + extern void glBindBuffer(int target, int buffer); + if (argc == 9876) { + glBegin(0); + glBindBuffer(0, 0); + } +#endif + SDL_Init(SDL_INIT_VIDEO); SDL_Surface *screen = SDL_SetVideoMode(600, 450, 32, SDL_HWSURFACE); |