diff options
author | Ehsan Akhgari <ehsan.akhgari@gmail.com> | 2012-02-01 15:15:50 -0500 |
---|---|---|
committer | Ehsan Akhgari <ehsan.akhgari@gmail.com> | 2012-02-06 11:08:04 -0500 |
commit | 88c6cb7612c472f2efc3a94c44e05c6115232e67 (patch) | |
tree | 6d15fd4341ecaf1d90de95dc8c30c36c3dfc9c2f | |
parent | 78a230ab665daad0fe11d40bdaca1c995fbe9add (diff) |
Disable WebGL if typed arrays are not being used.
This fixes issue #195
-rw-r--r-- | src/library_gl.js | 4 | ||||
-rw-r--r-- | src/library_sdl.js | 6 | ||||
-rw-r--r-- | tests/hello_world_gles_shell.html | 6 | ||||
-rwxr-xr-x | tests/runner.py | 21 |
4 files changed, 25 insertions, 12 deletions
diff --git a/src/library_gl.js b/src/library_gl.js index e1a7c73b..5cb30299 100644 --- a/src/library_gl.js +++ b/src/library_gl.js @@ -513,6 +513,7 @@ var LibraryGLUT = { }, glutCreateWindow: function(name) { +#if USE_TYPED_ARRAYS try { var ctx = Module.canvas.getContext('experimental-webgl'); if (!ctx) throw 'Could not create canvas :('; @@ -523,6 +524,9 @@ var LibraryGLUT = { } catch (e) { Module.print('(canvas not available)'); } +#else + Module.print('(USE_TYPED_ARRAYS needs to be enabled for WebGL)'); +#endif }, glutInitDisplayMode: function(mode) {}, diff --git a/src/library_sdl.js b/src/library_sdl.js index 35c619b8..7b413c13 100644 --- a/src/library_sdl.js +++ b/src/library_sdl.js @@ -173,6 +173,12 @@ mergeInto(LibraryManager.library, { }, createContext: function(useWebGL) { +#if !USE_TYPED_ARRAYS + if (useWebGL) { + Module.print('(USE_TYPED_ARRAYS needs to be enabled for WebGL)'); + return null; + } +#endif try { var ctx = Module.canvas.getContext(useWebGL ? 'experimental-webgl' : '2d'); if (!ctx) throw 'Could not create canvas :('; diff --git a/tests/hello_world_gles_shell.html b/tests/hello_world_gles_shell.html index 7f0b2013..d3429e3a 100644 --- a/tests/hello_world_gles_shell.html +++ b/tests/hello_world_gles_shell.html @@ -25,9 +25,6 @@ canvas: document.getElementById('canvas') }; - // The compiled code - {{{ SCRIPT_CODE }}} - // Test code function simulateKeyEvent(keyCode) { var event = document.createEvent("KeyboardEvent"); @@ -50,6 +47,9 @@ }, 0); } addEventListener("load", doTest, false); + + // The compiled code + {{{ SCRIPT_CODE }}} </script> </body> </html> diff --git a/tests/runner.py b/tests/runner.py index a1fa8690..4eb085ff 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -5645,16 +5645,8 @@ f.close() class TestServerHandler(BaseHTTPServer.BaseHTTPRequestHandler): def do_GET(s): assert s.path == expectedResult, 'Expected %s, got %s' % (expectedResult, s.path) - httpd.shutdown() - def handle_timeout(): - assert False, 'Timed out while waiting for the browser test to finish' - httpd.shutdown() httpd = BaseHTTPServer.HTTPServer(('localhost', 8888), TestServerHandler) - httpd.timeout = 5; - server_thread = threading.Thread(target=httpd.serve_forever) - server_thread.daemon = True - server_thread.start() - server_thread.join(5.5) + httpd.handle_request() # Finally, do some web browser tests def run_browser(html_file, message, expectedResult = None): @@ -5707,6 +5699,17 @@ f.close() assert os.path.exists('something.html'), output run_browser('something.html', 'You should see animating gears.', '/report_gl_result?true') + # Make sure that OpenGL ES is not available if typed arrays are not used + clear() + output = Popen([EMCC, path_from_root('tests', 'hello_world_gles.c'), '-o', 'something.html', + '-DHAVE_BUILTIN_SINCOS', + '-s', 'USE_TYPED_ARRAYS=0', + '--shell-file', path_from_root('tests', 'hello_world_gles_shell.html')], + stdout=PIPE, stderr=PIPE).communicate() + assert len(output[0]) == 0, output[0] + assert os.path.exists('something.html'), output + run_browser('something.html', 'You should not see animating gears.', '/report_gl_result?false') + def test_eliminator(self): input = open(path_from_root('tools', 'eliminator', 'eliminator-test.js')).read() expected = open(path_from_root('tools', 'eliminator', 'eliminator-test-output.js')).read() |