diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2017-02-02 08:18:42 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-02 08:18:42 +0100 |
commit | 40e4c1f6abbe5569a3c2f91d48b9770c8e97ea0d (patch) | |
tree | 12ba447a51df6e9a21d34df6ffdca8b1595e3f96 /platform/javascript | |
parent | 869d710198af9eb3dfee3e167cb432389d04f76d (diff) | |
parent | e06edc67c049c65c3952a8447e22717a0f492020 (diff) |
Merge pull request #7689 from eska014/webgl2
Enable WebGL2 in web export, start fixing build
Diffstat (limited to 'platform/javascript')
-rw-r--r-- | platform/javascript/audio_driver_javascript.h | 2 | ||||
-rw-r--r-- | platform/javascript/detect.py | 13 | ||||
-rw-r--r-- | platform/javascript/export/export.cpp | 4 | ||||
-rw-r--r-- | platform/javascript/godot_shell.html | 16 | ||||
-rw-r--r-- | platform/javascript/javascript_eval.cpp | 2 | ||||
-rw-r--r-- | platform/javascript/os_javascript.cpp | 37 | ||||
-rw-r--r-- | platform/javascript/os_javascript.h | 5 |
7 files changed, 23 insertions, 56 deletions
diff --git a/platform/javascript/audio_driver_javascript.h b/platform/javascript/audio_driver_javascript.h index da146fcdd0..4c2064663a 100644 --- a/platform/javascript/audio_driver_javascript.h +++ b/platform/javascript/audio_driver_javascript.h @@ -36,8 +36,6 @@ class AudioDriverJavaScript : public AudioDriver { public: - void set_singleton(); - virtual const char* get_name() const; virtual Error init(); diff --git a/platform/javascript/detect.py b/platform/javascript/detect.py index 55b05a9123..a701823b2e 100644 --- a/platform/javascript/detect.py +++ b/platform/javascript/detect.py @@ -14,9 +14,7 @@ def get_name(): def can_build(): import os - if (not os.environ.has_key("EMSCRIPTEN_ROOT")): - return False - return True + return os.environ.has_key("EMSCRIPTEN_ROOT") def get_opts(): @@ -79,9 +77,8 @@ def configure(env): # These flags help keep the file size down env.Append(CPPFLAGS=["-fno-exceptions", '-DNO_SAFE_CAST', '-fno-rtti']) env.Append(CPPFLAGS=['-DJAVASCRIPT_ENABLED', '-DUNIX_ENABLED', '-DPTHREAD_NO_RENAME', '-DNO_FCNTL', '-DMPC_FIXED_POINT', '-DTYPED_METHOD_BIND', '-DNO_THREADS']) - env.Append(CPPFLAGS=['-DGLES2_ENABLED']) + env.Append(CPPFLAGS=['-DGLES3_ENABLED']) env.Append(CPPFLAGS=['-DGLES_NO_CLIENT_ARRAYS']) -# env.Append(CPPFLAGS=['-DANDROID_ENABLED', '-DUNIX_ENABLED','-DMPC_FIXED_POINT']) if env['wasm'] == 'yes': env.Append(LINKFLAGS=['-s', 'BINARYEN=1']) @@ -101,14 +98,10 @@ def configure(env): env.Append(CPPFLAGS=['-DJAVASCRIPT_EVAL_ENABLED']) env.Append(LINKFLAGS=['-O2']) + env.Append(LINKFLAGS=['-s', 'USE_WEBGL2=1']) # env.Append(LINKFLAGS=['-g4']) # print "CCCOM is:", env.subst('$CCCOM') # print "P: ", env['p'], " Platofrm: ", env['platform'] import methods - - env.Append(BUILDERS={'GLSL120': env.Builder(action=methods.build_legacygl_headers, suffix='glsl.h', src_suffix='.glsl')}) - env.Append(BUILDERS={'GLSL': env.Builder(action=methods.build_glsl_headers, suffix='glsl.h', src_suffix='.glsl')}) - env.Append(BUILDERS={'GLSL120GLES': env.Builder(action=methods.build_gles2_headers, suffix='glsl.h', src_suffix='.glsl')}) - #env.Append( BUILDERS = { 'HLSL9' : env.Builder(action = methods.build_hlsl_dx9_headers, suffix = 'hlsl.h',src_suffix = '.hlsl') } ) diff --git a/platform/javascript/export/export.cpp b/platform/javascript/export/export.cpp index ab3d159f34..e487383ef4 100644 --- a/platform/javascript/export/export.cpp +++ b/platform/javascript/export/export.cpp @@ -184,8 +184,8 @@ void EditorExportPlatformJavaScript::_fix_html(Vector<uint8_t>& p_html, const St String current_line = lines[i]; current_line = current_line.replace("$GODOT_TMEM",itos((1<<(max_memory+5))*1024*1024)); current_line = current_line.replace("$GODOT_BASE",p_name); - current_line = current_line.replace("$GODOT_CANVAS_WIDTH",GlobalConfig::get_singleton()->get("display/width")); - current_line = current_line.replace("$GODOT_CANVAS_HEIGHT",GlobalConfig::get_singleton()->get("display/height")); + current_line = current_line.replace("$GODOT_CANVAS_WIDTH",GlobalConfig::get_singleton()->get("display/window/width")); + current_line = current_line.replace("$GODOT_CANVAS_HEIGHT",GlobalConfig::get_singleton()->get("display/window/height")); current_line = current_line.replace("$GODOT_HEAD_TITLE",!html_title.empty()?html_title:(String) GlobalConfig::get_singleton()->get("application/name")); current_line = current_line.replace("$GODOT_HEAD_INCLUDE",html_head_include); current_line = current_line.replace("$GODOT_STYLE_FONT_FAMILY",html_font_family); diff --git a/platform/javascript/godot_shell.html b/platform/javascript/godot_shell.html index a8b9594935..65f3b4a340 100644 --- a/platform/javascript/godot_shell.html +++ b/platform/javascript/godot_shell.html @@ -277,10 +277,10 @@ $GODOT_STYLE_INCLUDE statusElement.appendChild(closeNote); Presentation.setStatusVisible(true); }, - isWebGLAvailable: function isWebGLAvailable() { + isWebGL2Available: function isWebGL2Available() { var context; try { - context = canvasElement.getContext("webgl") || canvasElement.getContext("experimental-webgl"); + context = canvasElement.getContext("webgl2") || canvasElement.getContext("experimental-webgl2"); } catch (e) {} return !!context; }, @@ -319,12 +319,12 @@ $GODOT_STYLE_INCLUDE outputElement.firstChild.remove(); } var msg = document.createElement("div"); - if (text.trim().startsWith("**ERROR**") - || text.startsWith("**EXCEPTION**")) { + if (String.prototype.trim.call(text).startsWith("**ERROR**") + || String.prototype.trim.call(text).startsWith("**EXCEPTION**")) { msg.style.color = "#d44"; - } else if (text.trim().startsWith("**WARNING**")) { + } else if (String.prototype.trim.call(text).startsWith("**WARNING**")) { msg.style.color = "#ccc000"; - } else if (text.trim().startsWith("**SCRIPT ERROR**")) { + } else if (String.prototype.trim.call(text).startsWith("**SCRIPT ERROR**")) { msg.style.color = "#c6d"; } msg.textContent = text; @@ -395,8 +395,8 @@ $GODOT_STYLE_INCLUDE } }; - if (!Presentation.isWebGLAvailable()) { - Presentation.setStatus("WebGL appears to be unsupported in the current browser.\nPlease try updating or use a different browser."); + if (!Presentation.isWebGL2Available()) { + Presentation.setStatus("WebGL2 appears to be unsupported in the current browser.\nPlease try updating or use a different browser."); Presentation.preventLoading = true; } else { Presentation.setStatus("Downloading..."); diff --git a/platform/javascript/javascript_eval.cpp b/platform/javascript/javascript_eval.cpp index a79e5473c2..72b7ab06cd 100644 --- a/platform/javascript/javascript_eval.cpp +++ b/platform/javascript/javascript_eval.cpp @@ -156,7 +156,7 @@ Variant JavaScript::eval(const String& p_code, bool p_use_global_exec_context) { void JavaScript::_bind_methods() { - ObjectTypeDB::bind_method(_MD("eval", "code", "use_global_execution_context"), &JavaScript::eval, false); + ClassDB::bind_method(_MD("eval", "code", "use_global_execution_context"), &JavaScript::eval, false); } JavaScript::JavaScript() { diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp index 317a6676a4..b8c3dea3b4 100644 --- a/platform/javascript/os_javascript.cpp +++ b/platform/javascript/os_javascript.cpp @@ -28,7 +28,7 @@ /*************************************************************************/ #include "os_javascript.h" -#include "drivers/gles2/rasterizer_gles2.h" +#include "drivers/gles3/rasterizer_gles3.h" #include "core/io/file_access_buffered_fa.h" #include "drivers/unix/file_access_unix.h" #include "drivers/unix/dir_access_unix.h" @@ -47,7 +47,7 @@ int OS_JavaScript::get_video_driver_count() const { const char * OS_JavaScript::get_video_driver_name(int p_driver) const { - return "GLES2"; + return "GLES3"; } OS::VideoMode OS_JavaScript::get_default_video_mode() const { @@ -237,30 +237,20 @@ void OS_JavaScript::initialize(const VideoMode& p_desired,int p_video_driver,int print_line("Init Audio"); AudioDriverManager::add_driver(&audio_driver_javascript); + audio_driver_javascript.set_singleton(); + if (audio_driver_javascript.init() != OK) { - if (true) { - RasterizerGLES2 *rasterizer_gles22=memnew( RasterizerGLES2(false,false,false,false) ); - rasterizer_gles22->set_use_framebuffers(false); //not supported by emscripten - if (gl_extensions) - rasterizer_gles22->set_extensions(gl_extensions); - rasterizer = rasterizer_gles22; - } else { - //rasterizer = memnew( RasterizerGLES1(true, false) ); + ERR_PRINT("Initializing audio failed."); } + RasterizerGLES3::register_config(); + RasterizerGLES3::make_current(); + print_line("Init VS"); - visual_server = memnew( VisualServerRaster(rasterizer) ); - visual_server->init(); + visual_server = memnew( VisualServerRaster() ); visual_server->cursor_set_visible(false, 0); - /*AudioDriverManagerSW::get_driver(p_audio_driver)->set_singleton(); - - if (AudioDriverManagerSW::get_driver(p_audio_driver)->init()!=OK) { - - ERR_PRINT("Initializing audio failed."); - }*/ - print_line("Init Physicsserver"); physics_server = memnew( PhysicsServerSW ); @@ -767,14 +757,6 @@ void OS_JavaScript::main_loop_request_quit() { main_loop->notification(MainLoop::NOTIFICATION_WM_QUIT_REQUEST); } -void OS_JavaScript::reload_gfx() { - - if (gfx_init_func) - gfx_init_func(gfx_init_ud,use_gl2,video_mode.width,video_mode.height,video_mode.fullscreen); - if (rasterizer) - rasterizer->reload_vram(); -} - Error OS_JavaScript::shell_open(String p_uri) { /* clang-format off */ EM_ASM_({ @@ -877,7 +859,6 @@ OS_JavaScript::OS_JavaScript(GFXInitFunc p_gfx_init_func,void*p_gfx_init_ud, Get main_loop=NULL; last_id=1; gl_extensions=NULL; - rasterizer=NULL; window_maximized=false; get_data_dir_func=p_get_data_dir_func; diff --git a/platform/javascript/os_javascript.h b/platform/javascript/os_javascript.h index d11494a8aa..582f128ce8 100644 --- a/platform/javascript/os_javascript.h +++ b/platform/javascript/os_javascript.h @@ -33,8 +33,6 @@ #include "drivers/unix/os_unix.h" #include "os/main_loop.h" #include "servers/physics/physics_server_sw.h" -#include "servers/spatial_sound/spatial_sound_server_sw.h" -#include "servers/spatial_sound_2d/spatial_sound_2d_server_sw.h" #include "servers/audio_server.h" #include "servers/physics_2d/physics_2d_server_sw.h" #include "servers/visual/rasterizer.h" @@ -70,7 +68,6 @@ private: int64_t time_to_save_sync; int64_t last_sync_time; - Rasterizer *rasterizer; VisualServer *visual_server; PhysicsServer *physics_server; Physics2DServer *physics_2d_server; @@ -165,8 +162,6 @@ public: void set_opengl_extensions(const char* p_gl_extensions); - void reload_gfx(); - virtual Error shell_open(String p_uri); virtual String get_data_dir() const; String get_executable_path() const; |