Files
UnrealEngineUWP/Engine/Build/HTML5/GameX.html.template
Jack Porter ae727f8dab Copying //UE4/Dev-Mobile to //UE4/Dev-Main (Source: //UE4/Dev-Mobile @ 3383462)
#lockdown Nick.Penwarden

==========================
MAJOR FEATURES + CHANGES
==========================

Change 3292174 on 2017/02/08 by Nick.Shin

	HTML5 emscripten: wasm and webgl2 support

	- Linux toolchain

	#jira UEPLAT-1437  Switch [to] web assembly

Change 3292193 on 2017/02/08 by Nick.Shin

	HTML5 emscripten: wasm and webgl2 support

	- ThirdParty libs compiled with new toolchain with wasm support

	#jira UEPLAT-1437  Switch [to] web assembly

Change 3292215 on 2017/02/08 by Nick.Shin

	HTML5 emscripten: wasm and wbegl2 support

	- emscripten toolchain

	#jira UEPLAT-1437  Switch [to] web assembly

Change 3292222 on 2017/02/08 by Nick.Shin

	HTML5 emscripten: wasm support

	- ENGINE changes (c# & cpp files)

	#jira UEPLAT-1437  Switch [to] web assembly

Change 3292223 on 2017/02/08 by Nick.Shin

	HTML5 merge ThirdParty lib build scripts from Dev-Platform to Dev-Mobile

Change 3292228 on 2017/02/08 by Nick.Shin

	HTML5 emscripten: webgl support

	- webgl patches
	- and a lot of UE4 patches to package HTML5 on LINUX
	- mostly from mozilla's jukka -- thx jukka!

	#jira  UEPLAT-828  (4.16)  Support ES3 / WebGL2 in HTML5

Change 3292285 on 2017/02/08 by Nick.Shin

	HTML5 emscripten: wasm and webgl2 support

	- Windows toolchain

	#jira UEPLAT-1437  Switch [to] web assembly

Change 3293994 on 2017/02/09 by Nick.Shin

	HTML5 emscripten: wasm and webgl2 support

	- OSX toolchain

	#jira UEPLAT-1437  Switch [to] web assembly

Change 3294391 on 2017/02/09 by Nick.Shin

	HTML5 "black box issues" revisited

	- jukka rewrote the window resize handler -- much cleaner and more straightforward

	#jira UE-36341  HTML5 - View is incorrectly drawn
	#jira UE-32311  Templates on Firefox/Chrome on HTML5 are not full screen during Launch On

Change 3296421 on 2017/02/10 by Jack.Porter

	Fix landscape spline segment splitting placing when using streaming levels

Change 3296587 on 2017/02/10 by Jack.Porter

	Additional fix for landscape spline segment splitting when using streaming levels

Change 3301241 on 2017/02/14 by Mi.Wang

	Fixed DeviceProfileEditor bug for incorrect clamp the Texture Mip LOD size. #jira UE-36237 #rb jack.porter

Change 3301387 on 2017/02/14 by Nick.Shin

	HTML5 emscripten: webgl support

	- webgl patches from mozilla's jukka
	  + hardware instancing
	  + glBlitFramebuffer
	  + GL AlaphaBlendOperation

	#jira  UEPLAT-828  (4.16)  Support ES3 / WebGL2 in HTML5

Change 3301405 on 2017/02/14 by Nick.Shin

	HTML5 plugin fix when blueprint projects are promoted to code projects automatically.

	#jira UE-41710  HTML5 - Package Failure - Failed to Produce item ProjectName-OnlineSubsystemNull.bc

Change 3302278 on 2017/02/14 by Omar.Rodriguez

	UE-36651: Mac Vulkan Android Projects crash on launch.

	* Glslang library has been built for Mac but flag was not updated
	* Set GlslangAvailable to true for Mac when building an Android project with vulkan

	#jira UE-36651

Change 3302773 on 2017/02/14 by Chris.Babcock

	Add a dropdown with some common console commands on Android (contributed by rafortis)
	#jira UE-40834
	#PR #3143
	#ue4
	#android

Change 3305604 on 2017/02/16 by Nick.Shin

	HTML5 webgl2 shader- turn on: instance static mesh vertex factory

	#jira  UEPLAT-828  (4.16)  Support ES3 / WebGL2 in HTML5

Change 3308154 on 2017/02/16 by Nick.Shin

	HTML5 GitHub PR

	#jira UE-42019  GitHub 3258 : Added suport for emscripten --pre-js and --post-js option when building for HTML5

Change 3308510 on 2017/02/16 by Nick.Shin

	HTML5 webgl2 shader fixes

	#jria UEMOB-201  Support ES3 / WebGL2 in HTML5

Change 3308971 on 2017/02/17 by Jack.Porter

	Fix for landscape painting when height<0 in the Ortho viewports

Change 3309075 on 2017/02/17 by Allan.Bentham

	Include static subject meshes when masking out modulated shadow casters.

	#jira UE-41581

Change 3309531 on 2017/02/17 by Chris.Babcock

	Handle large OBB files in APK
	#jira UE-41443
	#ue4
	#android

Change 3311320 on 2017/02/19 by Dmitriy.Dyomin

	Fixed: Particle Cutout Crashes On Mobile Devices That Don't Support Hardware Instancing (Mali-400 GPU)
	#jira UE-41970

Change 3311347 on 2017/02/20 by Dmitriy.Dyomin

	Fixed: Engine Crashes When Previewing ES3_1 With Material Using World Position Offset (Need Custom Stencil)
	#jira UE-41976

Change 3311398 on 2017/02/20 by Dmitriy.Dyomin

	Fixed: Landscapes do not render on PowerVR device
	#jira UE-35530

Change 3311428 on 2017/02/20 by Dmitriy.Dyomin

	Fixed: Exposure Is More Extreme In High-End Mobile Preview Modes
	#jira UE-42036

Change 3311448 on 2017/02/20 by Dmitriy.Dyomin

	Fixed: Packaged game Crashes on android after entering "Help" command twice
	#jira UE-41956

Change 3311587 on 2017/02/20 by Allan.Bentham

	ES2 GLSL - Silently swap all uint to ints
	#jira UE-41548

Change 3313930 on 2017/02/21 by Allan.Bentham

	Print literal uints as ints when generating ES2 code.
	#jira UE-41548

Change 3317924 on 2017/02/22 by Nick.Shin

	HTML5 emscripten: wasm & webgl2 support - RC1

	- Linux toolchain

	#jira UEMOB-263  Switch [to] web assembly
	#jira UEMOB-201  Support ES3 / WebGL2 in HTML5

Change 3317929 on 2017/02/22 by Nick.Shin

	HTML5 emscripten: wasm & webgl2 support - RC1

	- ThirdParty libs compiled with new toolchain with wasm and webgl2 support

	#jira UEMOB-263  Switch [to] web assembly
	#jira UEMOB-201  Support ES3 / WebGL2 in HTML5

Change 3317951 on 2017/02/22 by Nick.Shin

	HTML5 emscripten: wasm & webgl2 support - RC1

	- emscripten toolchain

	WARNING: emscripten/incoming/source/include/libc/bit (the file) might need to be deleted first

	#jira UEMOB-263  Switch [to] web assembly
	#jira UEMOB-201  Support ES3 / WebGL2 in HTML5

Change 3318004 on 2017/02/22 by Nick.Shin

	HTML5 emscripten: wasm & webgl2 support - RC1

	- windows toolchain

	#jira UEMOB-263  Switch [to] web assembly
	#jira UEMOB-201  Support ES3 / WebGL2 in HTML5

Change 3318669 on 2017/02/23 by Nick.Shin

	HTML5 emscripten: wasm & webgl2 support - RC1

	- OSX toolchain

	#jira UEMOB-263  Switch [to] web assembly
	#jira UEMOB-201  Support ES3 / WebGL2 in HTML5

Change 3318672 on 2017/02/23 by Nick.Shin

	HTML5 webgl2 shader fixes

	#jria UEMOB-201  Support ES3 / WebGL2 in HTML5

Change 3318819 on 2017/02/23 by Dmitriy.Dyomin

	Fixed: Rendering artifacts with bloom on iPhone7 Metal
	#jira UE-40978

Change 3319702 on 2017/02/23 by Chris.Babcock

	Disable eglSwapInterval since it can cause issues with some drivers
	#ue4
	#android

Change 3320880 on 2017/02/24 by Dmitriy.Dyomin

	Added r.Mobile.TonemapperFilm cvar which can be used to enable/disable filmic tonemapper on mobile, independently from desktop (disabled by default)
	#jira UEMOB-195

Change 3321042 on 2017/02/24 by Jack.Porter

	Fixed incorrect sizeof in Vulkan pipleine cache
	pointed out here: http://coconutlizard.co.uk/blog/ue4/ue4-its-a-size-jim/

	#code_review: rolando.caloca

Change 3322383 on 2017/02/24 by Chris.Babcock

	Fix issue with ad banner on Android 7.0 devices
	#jira UE-42390
	#ue4
	#android

Change 3322479 on 2017/02/24 by Omar.Rodriguez

	UEMOB-199 - WEX: Improved virtual keyboard for Android

	* Calculating the area covered by the virtual keyboard
	* Calling OnVirtualKeyboardShown and OnVirtualKeyboardHidden events
	* Passing the Rect of the area covered by the virtual keyboard OnVirtualKeyboardShown event

	#jira UEMOB-199

Change 3323353 on 2017/02/27 by Allan.Bentham

	Fix broken mobile scene captures when !mobileHDR and RHINeedsToSwitchVerticalAxis
	#jira UE-42191

Change 3323431 on 2017/02/27 by Allan.Bentham

	CIS fix

Change 3323687 on 2017/02/27 by Allan.Bentham

	Disable GRHINeedsUnatlasedCSMDepthsWorkaround for mobile devices.
	#jira UE-42131

Change 3324652 on 2017/02/28 by Dmitriy.Dyomin

	Fixed: Canvas elements appear darker on iOS Metal

Change 3324885 on 2017/02/28 by Jack.Porter

	Fixed "Minimum iOS Version" setting display name

	#jira UE-42270

Change 3324899 on 2017/02/28 by Jack.Porter

	GitHub 3063 : removed duplicate gc.MaxObjectsInGame setting in IOSEngine.ini
	#jira UE-40018

	#3063

Change 3324932 on 2017/02/28 by Jack.Porter

	GitHub 3257 : iPhonePackager errors in output log when opening project settings on Windows

	#jira UE-41984
	#3257
	#codereview: Peter.Sauerbrei

Change 3324956 on 2017/02/28 by Jack.Porter

	FOpenGLFrontend::GetMaxSamplers incorrect for IOS
	#jira UE-42038
	#3264

Change 3325478 on 2017/02/28 by Allan.Bentham

	PR # 3188   : Fix far distance bug with cascaded shadows on mobile (Metal) and PC mobile preview  (Contributed by ufna)

	#jira UE-41442

Change 3327300 on 2017/03/01 by Allan.Bentham

	PR #3175   : Fixes high quality reflection blending seams  (Contributed by kallehamalainen)
	#jira UE-41257

Change 3328917 on 2017/03/02 by Nick.Shin

	HTML5 project settings

	expose ini settings to edtior HTML5 project settings panel

	#jira UE-42331  Project Settings - HTML5 SDK - HTML Device population should be moved to an .ini
	#jira UE-41584  Editor locks up when adding an element for HTML5 devices on Mac
	#jira UE-41701  Editor freezes when setting browser filepath for inserted element in project settings

Change 3329169 on 2017/03/02 by Allan.Bentham

	increase render thread timeout to 1 minute for suntemple / android.
	Prevents low end devices timing out during load.
	#jira UE-40696

Change 3330849 on 2017/03/02 by Nick.Shin

	HTML5 project settings

	expose ini settings to edtior HTML5 project settings panel

	#jira UE-42331  Project Settings - HTML5 SDK - HTML Device population should be moved to an .ini

Change 3331078 on 2017/03/03 by Dmitriy.Dyomin

	Fixed: Device output log partial lines

	integrated from WEX (3250488)

Change 3331112 on 2017/03/03 by Dmitriy.Dyomin

	Reduced state setup for slate draw calls (saves about 4ms RT time on mobile)

	integrated from WEX (3256584)

Change 3331117 on 2017/03/03 by Dmitriy.Dyomin

	Fixed redundant blend state changes in opengl

	integrated from WEX (3256586)

Change 3331173 on 2017/03/03 by Dmitriy.Dyomin

	Slate pixel shaders will use half precision where possible on mobile

	integrated from WEX (3256656)

Change 3332865 on 2017/03/06 by Dmitriy.Dyomin

	Better MobileContentScaleFactor defaults for iOS devices
	#jira UEMOB-330

Change 3333129 on 2017/03/06 by Peter.Sauerbrei

	move to Library/Caches instead of documents for saved files
	re-enable iterative deploy on TVOS
	#jira UEMOB-284

Change 3334692 on 2017/03/06 by Jack.Porter

	Allow r.MobileContentScaleFactor to be changed at runtime on Android

	#jira UEMOB-173

Change 3336255 on 2017/03/07 by Nick.Shin

	HTML5 project settings

	marking SIMD and multithreading as experimental - these do not play nice with WASM builds currently...

	#jira UE-42331  Project Settings - HTML5 SDK - HTML Device population should be moved to an .ini

Change 3337094 on 2017/03/08 by Nick.Shin

	HTML5 project settings

	marking SIMD and multithreading as experimental - these do not play nice with WASM builds currently...

	#jira UE-42331  Project Settings - HTML5 SDK - HTML Device population should be moved to an .ini

Change 3338800 on 2017/03/08 by Chris.Babcock

	Update AAR handling to deal with versioning, subproject dependencies for resources, and scope
	#jira UE-42677
	#ue4
	#android

Change 3338813 on 2017/03/08 by Chris.Babcock

	Pass build configuration to UPL for access during packaging as $S(Configuration)
	#jira UE-42678
	#ue4
	#android
	#ios

Change 3339401 on 2017/03/09 by Alicia.Cano

	Android runtime permissions
	- Fix for WRITE_EXTERNAL_STORAGE if it is not granted at time of onCreate for non-shipping builds
	- Fix for Location Services
	- Fix for if target sdk is not set to 23+
	#jira UE-38512
	#android
	#rb: chris.babcock

Change 3340736 on 2017/03/09 by Chris.Babcock

	Implement support for new controllers (Xbox Wireless, SteelSeries Stratus XL, PS4) (contributed by TRS-justing)
	#jira UE-41965
	#PR #3254
	#ue4
	#android

Change 3340744 on 2017/03/09 by Jack.Porter

	Expose Custom Depth to Foliage
	#jira UE-6061

Change 3340849 on 2017/03/09 by Dmitriy.Dyomin

	Fixed: iOS movie become laggy and crashes when played in iPhone 6/6s.
	#jira UE-42351

Change 3341268 on 2017/03/10 by Alicia.Cano

	PR #2894: Initial VoiceModuleAndroid support. (Contributed by devbm)
	#jira UE-37945
	#android
	#rb: chris.babcock, jack.porter

Change 3341303 on 2017/03/10 by Allan.Bentham

	Remove optimisation that prevents full specular occulsion on mobile.
	PR #3186  : Specular can't be blocked on high-end mobile.
	#jira UE-41393

Change 3342304 on 2017/03/10 by Alicia.Cano

	build fix
	#rb: chris.babcock

Change 3343344 on 2017/03/13 by Alicia.Cano

	build fix
	#rb: chris.babcock

Change 3343591 on 2017/03/13 by Brent.Pease

	iOS multiplayer fix part 1. Correct byte ordering.

	#jira UE-34875

Change 3343669 on 2017/03/13 by Chris.Babcock

	Update carefullyredist script version
	#jira UE-42832

Change 3344212 on 2017/03/13 by Will.Fissler

	Various compile fixes for Xcode 8.3.
	These fixes must also be added to //UE4/Release-4.15.
	#jira UE-41313

Change 3344396 on 2017/03/13 by Chris.Babcock

	Fix Java 1.5 obsolete warnings
	#jira UE-42851
	#ue4
	#android

Change 3345132 on 2017/03/14 by Will.Fissler

	Added ifdef wrapper to check clang version for presentDrawable.

Change 3345336 on 2017/03/14 by Will.Fissler

	Moved #if (__clang_major__ > 8) || (__clang_major__ == 8 && __clang_minor__ >= 1) check inside of the presentDrawable method.

Change 3345460 on 2017/03/14 by Will.Fissler

	ifdef changes for presentDrawable. The last submission duped the changes, instead of merging. #rb none

Change 3346046 on 2017/03/14 by Will.Fissler

	Fixed MetalCommandBuffer.cpp [again] after last submission duped changes instead of merging.

Change 3346367 on 2017/03/14 by Chris.Babcock

	Fix issue with GoogleVR ARMv7 libraries included for other architectures in link
	#ue4
	#android

Change 3347682 on 2017/03/15 by Allan.Bentham

	Enable HW sRGB correction with retainer widget's render target.
	Use slate's gamma correction for mobile (where no such support exists)
	Render retainer box RT content with gamma correction.
	#jira UE-40967

Change 3348712 on 2017/03/15 by Nick.Shin

	HTML5 - upload to S3

	updated to AWS "signature version 4" authentication

	#jira UE-42525  HTML5 Upload to Amazon S3 fails with Incorrect Configuration error

Change 3349254 on 2017/03/16 by Jack.Porter

	Fix for crash using the mobile previewer when the LQ lightmap shader permutation is disabled.
	#jira UE-42971

Change 3349739 on 2017/03/16 by Nick.Shin

	HTML5 - upload to S3

	better error message feedback on upload failures

	#jira UE-42525  HTML5 Upload to Amazon S3 fails with Incorrect Configuration error

Change 3349765 on 2017/03/16 by Alicia.Cano

	Disable mouseover events in Mobile Previewer

	#jira UE-19903
	#mobile
	#rb: Jack.Porter

Change 3350049 on 2017/03/16 by Nick.Shin

	HTML5 - upload to S3

	folder in bucket is optional

	#jira UE-42525  HTML5 Upload to Amazon S3 fails with Incorrect Configuration error

Change 3350153 on 2017/03/16 by Nick.Shin

	HTML5 - upload to S3

	updated S3 public link generator

	#jira UE-42525  HTML5 Upload to Amazon S3 fails with Incorrect Configuration error

Change 3351582 on 2017/03/17 by Will.Fissler

	Reverting the attempted fix for Xcode 8.3: Result += " -mcpu=cortex-a9";

	Currently we cannot build arm64 for iOS with this change.

Change 3352085 on 2017/03/17 by Alicia.Cano

	iOS doesn't honor request to close the virtual keyboard leading to a crash
	#jira UE-36447
	#ios
	#rb:Peter.Sauerbrei

Change 3353313 on 2017/03/19 by Ben.Marsh

	Always allow large *.js files in Github.

Change 3354444 on 2017/03/20 by Nick.Shin

	HTML5 - upload to S3

	to help make it obvious that "upload to S3" checkbox is set/or not -- disable S3 details if checkbox for "uploading to S3" is not set

	#jira UE-42525  HTML5 Upload to Amazon S3 fails with Incorrect Configuration error

Change 3355618 on 2017/03/20 by Nick.Shin

	HTML5 Save Game System

	- ripped out HTML5 code [from Engine's SaveGameSystem.h] and placed it in HTML5Platform.cpp
	- cleaned up HTML5PlatformFile.cpp (make it match as clost to linux's version)
	- created HTML5's own PlatformFeature & SaveGameSystem files -- and updated HTML5PlatformMisc to make use of the the new HTML5 SaveGame code

	#jira UE-42081 Remove heinous HTML5 code from engine

Change 3355621 on 2017/03/20 by Nick.Shin

	remove temp debugging code

	#jira UE-42081 Remove heinous HTML5 code from engine

Change 3356937 on 2017/03/21 by Chris.Babcock

	Add "stat vulkanrhi" to new console dropdown
	#jira UE-43149
	#ue4
	#android

Change 3357652 on 2017/03/21 by Nick.Shin

	HTML5 performance speed ups

	added "use fixed timestep" setting option for HTML5 builds (this has been separated from Engine - General Settings - Framerate)
	- this is slightly different to smooth framerate and fixed framerate - thus, the timestep option was put in the HTML5 specific panel

	this option is based on the suggestions by jukka's post:
	- https://answers.unrealengine.com/questions/409629/smooth-frame-rate-and-use-fixed-frame-rate-should.html

	however, using this option will make the player "run faster" on (for example) thirdperson blueprint template -- but, it has no effect on other (for example) zen garden...

	#jira UE-30214 - Implement a warning message for fps settings

Change 3360415 on 2017/03/23 by Allan.Bentham

	Fix crash that occurs when ES3.1 preview is used with r.MobileHDR32bppMode modes.

Change 3360418 on 2017/03/23 by Allan.Bentham

	Disable filmic tonemapper if r.MobileHDR32bppMode is in use.
	#jira UE-40913

Change 3360557 on 2017/03/23 by Allan.Bentham

	Better fix for mobile CSM shadow flickering (UE-42131), now works for PC OpenGL based mobile preview.
	#jira UE-42131

Change 3362258 on 2017/03/23 by Dmitriy.Dyomin

	Fixed: Canvas texture element gamma issues on iOS Metal

Change 3362321 on 2017/03/24 by Dmitriy.Dyomin

	GitHub 3173 : MaterialAO support for mobile rendering path (contributed by kallehamalainen)

	#3173

Change 3363550 on 2017/03/24 by Alicia.Cano

	build fix for devices < Android 5.0
	#jira UE-43299
	#android
	#rb: chris.babcock

Change 3363687 on 2017/03/24 by Chris.Babcock

	Fix Android password hiding in input dialog
	#jira WEX-5159
	#ue4
	#android

Change 3365280 on 2017/03/27 by Dmitriy.Dyomin

	Fix for GL_EXT_shader_framebuffer_fetch on Zenfone5. Use UE_EXT_shader_framebuffer_fetch define on all devices to enable extension

Change 3365291 on 2017/03/27 by Dmitriy.Dyomin

	Copied form WEX CL# 3308653
	Fixed: Enabling shader cache causes crash on NVIDIA Shield

	#jira UE-41639

Change 3365293 on 2017/03/27 by Dmitriy.Dyomin

	GitHub 3411 : Fix crash in patching utils mount method (contributed by nverenik)
	#jira UE-43247
	#3411

Change 3365340 on 2017/03/27 by Dmitriy.Dyomin

	Fixed: Moving sublevel in world composition browser does not appear in Undo History
	#jira UE-35535

Change 3365564 on 2017/03/27 by Allan.Bentham

	SkyLightComponent now serializes IrradianceMap SH values.
	clicking Recapture sky button in mobile preview switches back to SM4/5 to update captures.
	Skylights that are dirty from load will trigger reflection capture update once shaders are rebuilt.
	#jira UE-42436

Change 3366282 on 2017/03/27 by Nick.Shin

	remove dead links

	these files to not exist anywhere in the make-3.81 subfolders

	#UDN-354501
	#jira none

Change 3366306 on 2017/03/27 by Nick.Shin

	HTML5 - disable multi-threading for wasm

	#jira UE-43219 - HTML5 disable multi-threading for wasm

Change 3366307 on 2017/03/27 by Nick.Shin

	HTML5 packaging Shipping builds

	big cleanup / additions to *gz file support for amazon s3

	* both, uploading to s3
	* and allowing s3 to host the games there

	#jira UE-43002 HTML5 in Shipping fails downloading symbols files
	#jria UE-43001 HTML5 Shipping Projects fail looking for compressed files when "Compress files during shipping packaging" is not selected.

Change 3367385 on 2017/03/28 by Allan.Bentham

	Display skylight serialization warning only when cooking for mobile platforms.
	#jira UE-42436

Change 3368583 on 2017/03/28 by Chris.Babcock

	Expose JAVA_HOME setting in Android SDK project settings on Mac
	#jira UE-43418
	#ue4
	#android

Change 3368803 on 2017/03/28 by Chris.Babcock

	Fix features requested in manifest for "Daydream and Cardboard" mode
	#jira UE-43314
	#ue4
	#android

Change 3369087 on 2017/03/28 by Jack.Porter

	Changed tooltip and added supported devices in paretheses for Android Mobile Deferred / ES31+AEP
	#jira UE-42438

Change 3369372 on 2017/03/29 by Allan.Bentham

	Fix disappearing meshes when r.mobile.allowdistancefieldshadows is disabled.
	#jira UE-43366

Change 3369381 on 2017/03/29 by Jack.Porter

	Show warnings when mobile shader permutations required for rendering are disbaled
	Made FReadOnlyCVARCache a singleton and added mobile CVars, used for MobileBasePassRendering.
	#jira UE-43050

Change 3369430 on 2017/03/29 by Allan.Bentham

	fix CIS build

Change 3369740 on 2017/03/29 by Allan.Bentham

	Added Android option to enable builds with hidden symbol visbility by default. (bBuildWithHiddenSymbolVisibility)
	Android links with -gc-sections to remove unused code/data
	Add JNI_METHOD for java accessible native functions, fixed up existing JNI functions to use macro.
	Add support for map file generation with android.
	Add 'bBuildWithHiddenSymbolVisibility' to AndroidPlatform.HasDefaultBuildConfig()
	bBuildWithHiddenSymbolVisibility defaults to false in BaseEngine.ini

	#jira UEMOB-168

Change 3369975 on 2017/03/29 by Nick.Shin

	HTML5 - AWS S3 shareable link for shipping builds corrected

	#jira UE-43379 Amazon S3 Shareable link does not generate correct filepath.

Change 3369998 on 2017/03/29 by Nick.Shin

	HTML5 python build scripts

	PR:
	1cb836d43c

	#jira none

Change 3370214 on 2017/03/29 by Nick.Shin

	HTML5 - default bUseFixedTimeStep to false...

	#jira UE-43380 - Default HTML5 gamespeed is faster than equivalent platforms

Change 3370762 on 2017/03/29 by Chris.Babcock

	Fixes to new keyboard for Android
	- Ensure the local scope ScreenRect passed into OnVirtualKeyboardShown in AndroidJNI is captured by value instead of by reference.
	- Moved ShowVirtualKeyboardInput's bKeyboardShowing early-out checks into the UI thread task. This allows the keyboard to continue showing when changing focus between multiple EditableTextBox widgets.
	#ue4
	#android

Change 3371344 on 2017/03/30 by Jack.Porter

	Fixed issue where Vulkan screenshot R/B channels were reversed on Android
	#jira UE-43479

Change 3372926 on 2017/03/30 by Peter.Sauerbrei

	start the process of sunsetting 32-bit and GLES2 on iOS
	#jira UE-42266

Change 3372970 on 2017/03/30 by Nick.Shin

	HTML5 - 1.37.9 emscripten: wasm & webgl2 support

	- windows toolchain

	#jira UEMOB-263  Switch [to] web assembly
	#jira UEMOB-201  Support ES3 / WebGL2 in HTML5

	#rn

Change 3372989 on 2017/03/30 by Peter.Sauerbrei

	fix for Xcode 8.3 build with 32-bit

Change 3373007 on 2017/03/30 by Peter.Sauerbrei

	fix for crash when online subsystem is disabled on IOS

Change 3373108 on 2017/03/30 by Nick.Shin

	HTML5 - 1.37.9 emscripten: wasm & webgl2 support

	- emscripten toolchain

	WARNING: emscripten/incoming/source/include/libc/bit (the file) might need to be deleted first

	#jira UEMOB-263  Switch [to] web assembly
	#jira UEMOB-201  Support ES3 / WebGL2 in HTML5

	#rn

Change 3373163 on 2017/03/30 by Nick.Shin

	HTML5 - 1.37.9 emscripten: wasm & webgl2 support

	- OSX toolchain

	#jira UEMOB-263  Switch [to] web assembly
	#jira UEMOB-201  Support ES3 / WebGL2 in HTML5

	#rn

Change 3373169 on 2017/03/30 by Nick.Shin

	HTML5 - 1.37.9 emscripten: wasm & webgl2 support

	license file updated

	#jira UEMOB-263  Switch [to] web assembly
	#jira UEMOB-201  Support ES3 / WebGL2 in HTML5

	#rnx

Change 3373287 on 2017/03/30 by Nick.Shin

	HTML5 - 1.36.11 emscripten - remove old SDK

	#jira none

	#rnx

Change 3373289 on 2017/03/30 by Nick.Shin

	HTML5 - 1.37.9 emscripten: wasm & webgl2 support

	- Linux toolchain

	#jira UEMOB-263  Switch [to] web assembly
	#jira UEMOB-201  Support ES3 / WebGL2 in HTML5

	#rn

Change 3373595 on 2017/03/30 by Chris.Babcock

	Reenable GooglePlay for ARM64 now that it doesn't crash
	#jira UE-36198
	#ue4
	#android

Change 3373606 on 2017/03/30 by Chris.Babcock

	Submitting Allan's shelved EXT_shader_framebuffer_fetch fix
	#ue4
	#android

Change 3375456 on 2017/03/31 by Chris.Babcock

	Add missing keycodes for Android keyboard (@ and #)
	#jira WEX-5777
	#ue4
	#android

Change 3376309 on 2017/04/03 by Allan.Bentham

	Fix overflow issues with mobile DoF.

Change 3377041 on 2017/04/03 by Will.Fissler

	Adding Testbed content for PlatformShowcase.

Change 3377582 on 2017/04/03 by Alicia.Cano

	adding back in GET_ACCOUNTS permission as it is required for Reset Achievements

	#jira: UE-43265
	#android
	#rb: Chris.Babcock

Change 3377643 on 2017/04/03 by Peter.Sauerbrei

	fix for memory leak in MallocBinned
	#jira UE-43008

Change 3378033 on 2017/04/04 by Nick.Shin

	HTML5 - 1.37.9 emscripten: wasm & webgl2 support

	- ThirdParty libs compiled with new toolchain with wasm and webgl2 support

	#jira UEMOB-263  Switch [to] web assembly
	#jira UEMOB-201  Support ES3 / WebGL2 in HTML5

	#rn

Change 3378034 on 2017/04/04 by Nick.Shin

	HTML5 - 1.37.9 emscripten: wasm & webgl2 support

	- ThirdParty build scripts

	#jira UEMOB-263  Switch [to] web assembly
	#jira UEMOB-201  Support ES3 / WebGL2 in HTML5

Change 3378035 on 2017/04/04 by Nick.Shin

	HTML5 - Update GameX template to make it work with trunk Emscripten

	PR
	dc2b26f452 (commitcomment-21454978)

	#jira none

	#rn

Change 3378044 on 2017/04/04 by Nick.Shin

	HTML5 harfbuzz - double checking recompiled with NO multithreading

	wasm currently does not support pthreads

	*** THIS IS STILL WIP ***
	checking in to match 3rd party libs compiled configuration

	#jira UE-28588 - Build HarfBuzz for HTML5

	#rnx

Change 3378264 on 2017/04/04 by Allan.Bentham

	Fix crash when using consolas font on android sdk 24
	#jira UE-43464

Change 3379097 on 2017/04/04 by Nick.Shin

	CIS HTML5 build warning fix

	#jria none

	#rnx

Change 3379333 on 2017/04/04 by Chris.Babcock

	Prevent inserting extra permissions into manifest multiple times
	#jira UE-43583
	#ue4
	#android

Change 3380870 on 2017/04/05 by Chris.Babcock

	Fix merge issue

Change 3380898 on 2017/04/05 by Chris.Babcock

	Fixed again

Change 3381443 on 2017/04/05 by Chris.Babcock

	Fix for GearVR non-unity build
	#ue4
	#android

Change 3381941 on 2017/04/05 by Chris.Babcock

	Fix HTTPChunkInstaller texture format checks and missing #define warning
	#jira UE-43706
	#ue4
	#android

Change 3382056 on 2017/04/05 by Chris.Babcock

	Updates to Android AARs needed for Facebook plugin

Change 3382097 on 2017/04/05 by Chris.Babcock

	Disable java console cmd receiver only in shipping builds
	#jira UE-43710
	#ue4
	#android

Change 3382497 on 2017/04/06 by Allan.Bentham

	Fix Fortnite Cooked Server crashes when joining game from lobby.
	#jira UE-43695

Change 3383227 on 2017/04/06 by Will.Fissler

	Reverted case sensitive change, from yesterday, and implemented a pragma instead.

	#jira UE-41313

[CL 3383473 by Jack Porter in Main branch]
2017-04-06 16:13:17 -04:00

1205 lines
54 KiB
Plaintext

<!DOCTYPE html>
<html lang="en">
<head>
<title>%GAME%</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script>
// Configuration item: enable this hosting an asm.js fallback, and set to false if hosting only Wasm version.
const supportsAsmJsAsFallback = true;
// Minimum WebGL version that the page needs in order to run. UE4 will attempt to use WebGL 2 if available.
// Set this to 1 to run with a WebGL 1 fallback if the graphical features required by your UE4 project are
// low enough that they do not strictly require WebGL 2.
const requiredWebGLVersion = 1;
// Add ?webgl1 GET param to explicitly test the WebGL 1 fallback version even if browser does support WebGL 2.
const explicitlyUseWebGL1 = (location.search.indexOf('webgl1') != -1);
// Add ?asmjs GET param to explicitly test the asm.js fallback version even if browser does support WebAssembly.
const explicitlyLoadedAsmJs = (location.search.indexOf('asmjs') != -1);
// Deduce which version to load up.
var supportsWasm = (typeof WebAssembly === 'object' && typeof WebAssembly.Memory === 'function');
var runningAsmJs = explicitlyLoadedAsmJs || (!supportsWasm && supportsAsmJsAsFallback);
if (runningAsmJs) {
supportsWasm = false; // Pretend that Wasm doesn't exist if explicitly asked to run asm.js version.
console.log('Running asm.js fallback');
}
// By default, Shipping builds serve out compressed assets, and Development builds serve uncompressed assets.
// Change the following line to customize. When hosting UE4 builds live on a production CDN, compression
// should always be enabled, since uncompressed files are too huge to be downloaded over the web.
const serveCompressedAssets = %SERVE_COMPRESSED%;
// For the large .data file, there's two ways to manage compression: either UE4 UnrealPak tool can compress it in engine, or
// it can be gzip compressed on disk like other assets. Compressing via UnrealPak has the advantage of storing a smaller data
// file to IndexedDB, whereas gzip compressing to disk has the advantage of starting up the page slightly faster.
// If true, serve out 'UE4Game.data.gz', if false, serve out 'UE4Game.data'.
const dataFileIsGzipCompressed = false;
var Module = {
// state management
infoPrinted: false,
lastcurrentDownloadedSize: 0,
totalDependencies: 0,
dataBytesStoredInIndexedDB: 0, // Track how much data is currently stored in IndexedDB.
assetDownloadProgress: {}, // Track how many bytes of each needed asset has been downloaded so far.
UE4_indexedDBName: 'UE4_assetDatabase_%GAME%', // TODO Nick: this should be an ascii ID string without special characters that is unique to the project that is being packaged
UE4_indexedDBVersion: 1, // Bump this number to invalidate existing IDB storages in browsers. // TODO Nick: Perhaps UE4 could automatically bump this number up when repackaging the project?
preRun: [function() { addRunDependency('wait-for-compiled-code'); }]
};
// Tests if type === 'browser' or type === 'os' is 64-bit or not.
function heuristicIs64Bit(type) {
function contains(str, substrList) { for(var i in substrList) if (str.indexOf(substrList[i]) != -1) return true; return false; }
var ua = (navigator.userAgent + ' ' + navigator.oscpu + ' ' + navigator.platform).toLowerCase();
if (contains(ua, ['wow64'])) return type === 'os'; // 32bit browser on 64bit OS
if (contains(ua, ['x86_64', 'amd64', 'ia64', 'win64', 'x64', 'arm64', 'irix64', 'mips64', 'ppc64', 'sparc64'])) return true;
if (contains(ua, ['i386', 'i486', 'i586', 'i686', 'x86', 'arm7', 'android', 'mobile', 'win32'])) return false;
if (contains(ua, ['intel mac os'])) return true;
return false;
}
// For best stability on 32-bit browsers, allocate asm.js/WebAssembly heap up front before proceeding
// to load any other page content. This mitigates the chances that loading up page assets first would
// fragment the memory area of the browser process.
var pageSize = supportsWasm ? 64 * 1024 : 16 * 1024 * 1024;
var heuristic64BitBrowser = heuristicIs64Bit('browser');
function alignPageUp(size) { return pageSize * Math.ceil(size / pageSize); }
// The application should not be able to allocate more than MAX bytes of memory. If the application
// attempts to allocate any more, it will be forbidden. Use this field to defensively impose a
// strict limit to an application to keep it from going rogue with its memory usage beyond some
// undesired limit. The absolute maximum that is possible is one memory page short of 2GB.
var MAX_MEMORY_64BIT = Infinity;
var MAX_MEMORY_32BIT = Infinity;
var MAX_MEMORY = Math.min(alignPageUp(heuristic64BitBrowser ? MAX_MEMORY_64BIT : MAX_MEMORY_32BIT), 2048 * 1024 * 1024 - pageSize);
// The application needs at least this much memory to run. If the browser can't provide this,
// the page startup should be aborted in an out-of-memory exception.
var MIN_MEMORY = Math.min(alignPageUp(32 * 1024 * 1024), MAX_MEMORY);
// As a hint to the implementation, the application would prefer to reserve this much address
// space at startup, and the browser will attempt its best to satisfy this. If this is not
// possible, the browser will attempt to allocate anything as close to this IDEAL amount as
// possible, but at least MIN bytes.
var IDEAL_MEMORY_64BIT = %HEAPSIZE%;
var IDEAL_MEMORY_32BIT = %HEAPSIZE%;
var IDEAL_MEMORY = Math.min(Math.max(alignPageUp(heuristic64BitBrowser ? IDEAL_MEMORY_64BIT : IDEAL_MEMORY_32BIT), MIN_MEMORY), MAX_MEMORY);
// If true, assume the application will have most of its memory allocation pressure inside the
// application heap, so reserve address space there up front. If false, assume that the memory
// allocation pressure is outside the heap, so avoid reserving memory up front, until needed.
var RESERVE_MAX_64BIT = true;
var RESERVE_MAX_32BIT = false;
var RESERVE_MAX = heuristic64BitBrowser ? RESERVE_MAX_64BIT : RESERVE_MAX_32BIT;
// Try to get as much memory close to IDEAL, but at least MIN. For asm.js, start by reserving
// MAX if requested to do so.
for(var mem = (RESERVE_MAX && !supportsWasm) ? MAX_MEMORY : IDEAL_MEMORY; mem >= MIN_MEMORY; mem -= pageSize) {
try {
if (supportsWasm) {
if (RESERVE_MAX) Module['wasmMemory'] = new WebAssembly.Memory({ initial: mem / pageSize, maximum: MAX_MEMORY / pageSize });
else Module['wasmMemory'] = new WebAssembly.Memory({ initial: mem / pageSize });
Module['buffer'] = Module['wasmMemory'].buffer;
} else {
Module['buffer'] = new ArrayBuffer(mem);
}
if (Module['buffer'].byteLength != mem) throw 'Out of memory';
break;
} catch(e) { /*nop*/ }
}
function MB(x) { return (x/1024/1024) + 'MB'; }
if (!Module['buffer'] || !(Module['buffer'].byteLength >= MIN_MEMORY)) {
delete Module['buffer'];
throw 'Out of memory';
}
Module['TOTAL_MEMORY'] = Module['buffer'].byteLength;
Module['MAX_MEMORY'] = MAX_MEMORY;
console.log('Initial memory size: ' + MB(Module['TOTAL_MEMORY']) + ' (MIN_MEMORY: ' + MB(MIN_MEMORY) + ', IDEAL_MEMORY: ' + MB(IDEAL_MEMORY) + ', MAX_MEMORY: ' + MB(MAX_MEMORY) + ', RESERVE_MAX: ' + RESERVE_MAX + ', heuristic64BitBrowser: ' + heuristic64BitBrowser + ', heuristic64BitOS: ' + heuristicIs64Bit('os') + ')');
</script>
<script src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<style type="text/css">
html, body, .container {
height: 100%;
font-family: "Helvetica Neue", "HelveticaNeue", Helvetica, Arial, sans-serif;
}
.h4, h4 {
margin-top: 1pt;
margin-bottom: 1pt;
font-size: 10pt;
}
.container {
display: table;
vertical-align: middle;
border: 0px;
border-spacing: 0px;
}
.glyphicon-spin {
animation: spin 2000ms infinite linear;
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(359deg);
}
}
@-webkit-keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(359deg);
}
}
.wrapper {
position: relative;
margin: 1em auto 10px auto;
text-align: center;
min-width: 640px;
width: 100%;
height: 480px; /* initial height, will be dynamically adjusted at runtime */
max-width: 95%;
display: block;
align-items: center;
position: relative;
text-align: center;
justify-content: center;
}
.emscripten {
padding-right: 0;
margin-left: auto;
margin-right: auto;
display: block;
display: -webkit-box;
display: -moz-box;
display: box;
-webkit-box-align: center;
-moz-box-align: center;
box-align: center;
-webkit-box-pack: center;
-moz-box-pack: center;
box-pack: center;
}
#canvas:not([fullscreen]) {
padding-right: 0;
margin-left: auto;
margin-right: auto;
width: 100%;
}
.texthalf {
height: 37%;
border: 0px;
padding: 0px;
overflow-y: scroll;
font-size: 2em;
}
.buttonarea {
min-height: 3%;
border-top: 0px;
border-bottom: 0px;
padding: 0px;
margin-right: 0px;
margin-top: 0px;
margin-bottom: 0px;
}
.btn { padding: 0px; text-align: center; min-width: 150px }
.progress { background: rgba(245, 245, 245, 1); border: 0px solid rgba(245, 245, 245, 1); border-radius: 0px; height: 4px; }
.progress-bar-custom { background: rgba(153, 153, 153, 1); }
.centered-axis-xy {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%,-50%);
}
</style>
<div class="wrapper" id="mainarea">
<div class="alert alert-warning centered-axis-xy" style="min-height: 20px; display:none;" role="alert" id="compilingmessage">
<div id='loadTasks'> </div>
</div>
<canvas id="canvas" class="emscripten" oncontextmenu="event.preventDefault()" style="display:none;">
</div>
<div class="row buttonarea text-center" id="buttonrow">
<div class="col-sm-2 text-center"></div>
<div class="col-sm-2 text-center"><button type="button" class="btn btn-primary" onclick="Module['pauseMainLoop']();">Pause</button></div>
<div class="col-sm-2 text-center"><button type="button" class="btn btn-primary" onclick="Module['resumeMainLoop']();">Resume</button></div>
<div class="col-sm-2 text-center"></div>
<div class="col-sm-2 text-center"><button type="button" class="btn btn-primary" id='clear_indexeddb' onclick="deleteIndexedDBStorage();">Clear IndexedDB</button></div>
<div class="col-sm-2 text-center"><button type="button" class="btn btn-primary" id="fullscreen_request">FullScreen</button></div>
<div class="col-sm-2 text-center"></div>
<div class="col-sm-2 text-center"></div>
</div>
<div class="texthalf text-normal jumbotron " id="logwindow" style='display:none'></div>
<script type="text/javascript">
// combine all parallel downloads into one progress bar.
var totalDownloadSize = 0;
var currentDownloadedSize = 0;
// helper functions.
// http://stackoverflow.com/questions/4750015/regular-expression-to-find-urls-within-a-string
function getHTMLGetParam(name) {
if (name=(new RegExp('[?&]'+encodeURIComponent(name)+'=([^&]*)')).exec(location.search))
return decodeURIComponent(name[1]);
}
var UE4 = {
on_fatal: function() {
try {
UE4.on_fatal = Module.cwrap('on_fatal', null, ['string', 'string']);
} catch(e) {
UE4.on_fatal = function() {};
}
},
};
Module['preinitializedWebGLContext'] = null;
function getGpuInfo() {
var gl = Module['preinitializedWebGLContext'];
if (!gl) return '(no GL: ' + Module['webGLErrorReason'] + ')';
var glInfo = '';
var debugInfo = gl.getExtension('WEBGL_debug_renderer_info');
if (debugInfo) glInfo += gl.getParameter(debugInfo.UNMASKED_VENDOR_WEBGL) + ' ' + gl.getParameter(debugInfo.UNMASKED_RENDERER_WEBGL) + '/';
glInfo += gl.getParameter(gl.VENDOR) + ' ' + gl.getParameter(gl.RENDERER);
glInfo += ' ' + gl.getParameter(gl.VERSION);
glInfo += ', ' + gl.getParameter(gl.SHADING_LANGUAGE_VERSION);
if (Module['softwareWebGL']) glInfo += ' (software)';
return glInfo;
}
function detectWebGL() {
var canvas = Module['canvas'] || document.createElement("canvas");
// If you run into problems with WebGL 2, or for quick testing purposes, you can disable UE4
// from using WebGL 2 and revert back to WebGL 1 by setting the following flag to true.
var disableWebGL2 = false;
if (explicitlyUseWebGL1) {
disableWebGL2 = true;
console.log('Disabled WebGL 2 as requested by ?webgl1 GET param.');
}
var names = ["webgl", "experimental-webgl"];
if (disableWebGL2) {
WebGL2RenderingContext = undefined;
} else {
names = ["webgl2"].concat(names);
}
function testError(e) { Module['webGLErrorReason'] = e.statusMessage; };
canvas.addEventListener("webglcontextcreationerror", testError, false);
try {
for(var failIfMajorPerformanceCaveat = 1; failIfMajorPerformanceCaveat >= 0; --failIfMajorPerformanceCaveat) {
for(var i in names) {
try {
var context = canvas.getContext(names[i], {antialias:false,alpha:false,depth:true,stencil:true,failIfMajorPerformanceCaveat:!!failIfMajorPerformanceCaveat});
Module['preinitializedWebGLContext'] = context;
Module['softwareWebGL'] = !failIfMajorPerformanceCaveat;
if (context && typeof context.getParameter == "function") {
if (typeof WebGL2RenderingContext !== 'undefined' && context instanceof WebGL2RenderingContext && names[i] == 'webgl2') {
return 2;
} else {
// We were able to precreate only a WebGL 1 context, remove support for WebGL 2 from the rest of the page execution.
WebGL2RenderingContext = undefined;
return 1;
}
}
} catch(e) { Module['webGLErrorReason'] = e.toString(); }
}
}
} finally {
canvas.removeEventListener("webglcontextcreationerror", testError, false);
}
return 0;
}
Module['canvas'] = document.getElementById('canvas');
// Canvas scaling mode should be set to one of: 1=STRETCH, 2=ASPECT, or 3=FIXED.
// This dictates how the canvas size changes when the browser window is resized
// by dragging from the corner.
var canvasWindowedScaleMode = 2 /*ASPECT*/;
// High DPI setting configures whether to match the canvas size 1:1 with
// the physical pixels on the screen.
// For background, see https://www.khronos.org/webgl/wiki/HandlingHighDPI
var canvasWindowedUseHighDpi = true;
// Stores the initial size of the canvas in physical pixel units.
// If canvasWindowedScaleMode == 3 (FIXED), this size defines the fixed resolution
// that the app will render to.
// If canvasWindowedScaleMode == 2 (ASPECT), this size defines only the aspect ratio
// that the canvas will be constrained to.
// If canvasWindowedScaleMode == 1 (STRETCH), these size values are ignored.
var canvasAspectRatioWidth = 1366;
var canvasAspectRatioHeight = 768;
// Fullscreen scaling mode behavior (export these to Module object for the engine to read)
// This value is one of:
// 0=NONE: The same canvas size is kept when entering fullscreen without change.
// 1=STRETCH: The canvas is resized to the size of the whole screen, potentially changing aspect ratio.
// 2=ASPECT: The canvas is resized to the size of the whole screen, but retaining current aspect ratio.
// 3=FIXED: The canvas is centered on screen with a fixed resolution.
Module['UE4_fullscreenScaleMode'] = canvasWindowedScaleMode;
// When entering fullscreen mode, should UE4 engine resize the canvas?
// 0=No resizing (do it manually in resizeCanvas()), 1=Resize to standard DPI, 2=Resize to highDPI
Module['UE4_fullscreenCanvasResizeMode'] = canvasWindowedUseHighDpi ? 2/*HIDPI*/ : 1/*Standard DPI*/;
// Specifies how canvas is scaled to fullscreen, if not rendering in 1:1 pixel perfect mode.
// One of 0=Default, 1=Nearest, 2=Bilinear
Module['UE4_fullscreenFilteringMode'] = 0;
document.addEventListener('error', function(){document.getElementById('clear_indexeddb').style.display = 'inline-block';}, false);
// Startup task which is run after UE4 engine has launched.
function postRunEmscripten() {
taskFinished(TASK_MAIN);
$("#compilingmessage").remove();
// The default Emscripten provided canvas resizing behavior is not needed,
// since we are controlling the canvas sizes here, so stub those functions out.
Browser.updateCanvasDimensions = function() {};
Browser.setCanvasSize = function() {};
// If you'd like to configure the initial canvas size to render using the resolution
// defined in UE4 DefaultEngine.ini [SystemSettings] r.setRes=WidthxHeight,
// uncomment the following two lines before calling resizeCanvas() below:
// canvasAspectRatioWidth = UE_JSlib.UE_GSystemResolution_ResX();
// canvasAspectRatioHeight = UE_JSlib.UE_GSystemResolution_ResY();
// Configure the size of the canvas and display it.
resizeCanvas();
Module['canvas'].style.display = 'block';
// Whenever the browser window size changes, relayout the canvas size on the page.
window.addEventListener('resize', resizeCanvas, false);
window.addEventListener('orientationchange', resizeCanvas, false);
// The following is needed if game is within an iframe - main window already has focus...
window.focus();
}
Module.postRun = [postRunEmscripten];
// The resizeCanvas() function recomputes the canvas size on the page as the user changes
// the browser window size.
function resizeCanvas(aboutToEnterFullscreen) {
// Configuration variables, feel free to play around with these to tweak.
var minimumCanvasHeightCssPixels = 480; // the visible size of the canvas should always be at least this high (in CSS pixels)
var minimumCanvasHeightFractionOfBrowserWindowHeight = 0.65; // and also vertically take up this much % of the total browser client area height.
if (aboutToEnterFullscreen) { // UE4 engine is calling this function right before entering fullscreen?
// If you want to perform specific resolution setup here, do so by setting Module['canvas'].width x Module['canvas'].height now,
// and configure Module['UE4_fullscreenXXX'] fields above. Most of the time, the defaults are good, so no need to resize here.
// Return true here if you want to abort entering fullscreen mode altogether.
return;
}
// The browser called resizeCanvas() to notify that we just entered fullscreen? In that case, we never react, since the strategy is
// to always set the canvas size right before entering fullscreen.
if (document.fullscreenElement || document.mozFullScreenElement || document.webkitFullscreenElement || document.msFullscreenElement) {
return;
}
var mainArea = document.getElementById('mainarea');
var canvasRect = mainArea.getBoundingClientRect();
// Compute the unconstrained size for the div that encloses the canvas, in CSS pixel units.
var cssWidth = canvasRect.right - canvasRect.left;
var cssHeight = Math.max(minimumCanvasHeightCssPixels, canvasRect.bottom - canvasRect.top, window.innerHeight * minimumCanvasHeightFractionOfBrowserWindowHeight);
if (canvasWindowedScaleMode == 3/*NONE*/) {
// In fixed display mode, render to a statically determined WebGL render target size.
var newRenderTargetWidth = canvasAspectRatioWidth;
var newRenderTargetHeight = canvasAspectRatioHeight;
} else {
// Convert unconstrained render target size from CSS to physical pixel units.
var newRenderTargetWidth = canvasWindowedUseHighDpi ? (cssWidth * window.devicePixelRatio) : cssWidth;
var newRenderTargetHeight = canvasWindowedUseHighDpi ? (cssHeight * window.devicePixelRatio) : cssHeight;
// Apply aspect ratio constraints, if desired.
if (canvasWindowedScaleMode == 2/*ASPECT*/) {
if (cssWidth * canvasAspectRatioHeight > canvasAspectRatioWidth * cssHeight) {
newRenderTargetWidth = newRenderTargetHeight * canvasAspectRatioWidth / canvasAspectRatioHeight;
} else {
newRenderTargetHeight = newRenderTargetWidth * canvasAspectRatioHeight / canvasAspectRatioWidth;
}
}
// WebGL render target sizes are always full integer pixels in size, so rounding is critical for CSS size computations below.
newRenderTargetWidth = Math.round(newRenderTargetWidth);
newRenderTargetHeight = Math.round(newRenderTargetHeight);
}
// Very subtle but important behavior is that the size of a DOM element on a web page in CSS pixel units can be a fraction, e.g. on
// high DPI scaling displays (CSS pixel units are "virtual" pixels). If the CSS size and physical pixel size of the WebGL canvas do
// not correspond to each other 1:1 after window.devicePixelRatio scaling has been applied, the result can look blurry. Therefore always
// first compute the WebGL render target size first in physical pixels, and convert that back to CSS pixels so that the CSS pixel size
// will perfectly align up and the result look clear without scaling applied.
cssWidth = canvasWindowedUseHighDpi ? (newRenderTargetWidth / window.devicePixelRatio) : newRenderTargetWidth;
cssHeight = canvasWindowedUseHighDpi ? (newRenderTargetHeight / window.devicePixelRatio) : newRenderTargetHeight;
Module['canvas'].width = newRenderTargetWidth;
Module['canvas'].height = newRenderTargetHeight;
Module['canvas'].style.width = cssWidth + 'px';
Module['canvas'].style.height = mainArea.style.height = cssHeight + 'px';
// Tell the engine that the web page has changed the size of the WebGL render target on the canvas (Module['canvas'].width/height).
// This will update the GL viewport and propagate the change throughout the engine.
// If the CSS style size is changed, this function doesn't need to be called.
if (UE_JSlib.UE_CanvasSizeChanged) UE_JSlib.UE_CanvasSizeChanged();
}
Module['UE4_resizeCanvas'] = resizeCanvas;
Module.arguments = [%UE4CMDLINE%];
// we are serving via a server and it is unreal file server?
if (location.host != "" && getHTMLGetParam("cookonthefly") == "true") {
Module.arguments.push("' -filehostIp=" + location.protocol + "//" + location.host + " '");
}
function addLog(info, color) {
$("#logwindow").append("<h4><small>" + info + " </small></h4>");
}
Module.print = addLog;
Module.printErr = function(text) {
console.error(text);
};
// Module.locateFile() routes asset downloads to either gzip compressed or uncompressed assets.
Module.locateFile = function(name) {
var serveGzipped = serveCompressedAssets;
// When serving from file:// URLs, don't read .gz compressed files, because these files can't be transparently uncompressed.
var isFileProtocol = name.indexOf('file://') != -1 || location.protocol.indexOf('file') != -1;
if (isFileProtocol) {
if (!Module['shownFileProtocolWarning']) {
showWarningRibbon('Attempting to load the page via the "file://" protocol. This only works in Firefox, and even there only when not using compression, so attempting to load uncompressed assets. Please host the page on a web server and visit it via a "http://" URL.');
Module['shownFileProtocolWarning'] = true;
}
serveGzipped = false;
}
// Asset packages do not benefit from gzip compression because they are already compressed at UE4 packaging time,
// and uncompressing very large gzip files would just slow down startup times.
if (!dataFileIsGzipCompressed && name.split('.').slice(-1)[0] == 'data') serveGzipped = false;
return serveGzipped ? (name + 'gz') : name;
};
Module.getPreloadedPackage = function(remotePackageName, remotePackageSize) {
return Module['preloadedPackages'] ? Module['preloadedPackages'][remotePackageName] : null;
}
// Asynchronously appends the given script code to DOM. This is to ensure that
// browsers parse and compile the JS code parallel to all other execution.
function addScriptToDom(scriptCode) {
return new Promise(function(resolve, reject) {
var script = document.createElement('script');
var blob = (scriptCode instanceof Blob) ? scriptCode : new Blob([scriptCode], { type: 'text/javascript' });
var objectUrl = URL.createObjectURL(blob);
script.src = objectUrl;
script.onload = function() {
script.onload = script.onerror = null; // Remove these onload and onerror handlers, because these capture the inputs to the Promise and the input function, which would leak a lot of memory!
URL.revokeObjectURL(objectUrl); // Free up the blob. Note that for debugging purposes, this can be useful to comment out to be able to read the sources in debugger.
resolve();
}
script.onerror = function(e) {
script.onload = script.onerror = null; // Remove these onload and onerror handlers, because these capture the inputs to the Promise and the input function, which would leak a lot of memory!
URL.revokeObjectURL(objectUrl);
console.error('script failed to add to dom: ' + e);
console.error(scriptCode);
console.error(e);
// The onerror event sends a DOM Level 3 event error object, which does not seem to have any kind of human readable error reason (https://developer.mozilla.org/en-US/docs/Web/Events/error)
// There is another error event object at https://developer.mozilla.org/en-US/docs/Web/API/ErrorEvent, which would have an error reason. Perhaps that error event might sometimes be fired,
// but if not, guess that the error reason was an OOM, since we are dealing with large .js files.
reject(e.message || "(out of memory?)");
}
document.body.appendChild(script);
});
}
var TASK_DOWNLOADING = 0;
var TASK_COMPILING = 1;
var TASK_SHADERS = 2;
var TASK_MAIN = 3;
var loadTasks = [ 'Downloading', runningAsmJs ? 'Compiling asm.js' : 'Compiling WebAssembly', 'Building shaders', 'Launching engine'];
function taskProgress(taskId, progress) {
var c = document.getElementById('compilingmessage');
if (c) c.style.display = 'block';
else return;
var l = document.getElementById('load_' + taskId);
if (!l) {
var tasks = document.getElementById('loadTasks');
if (!tasks) return;
l = document.createElement('div');
l.innerHTML = '<span id="icon_' + taskId + '" class="glyphicon glyphicon-refresh glyphicon-spin"></span> <span id="load_' + taskId + '"></span>';
tasks.appendChild(l);
l = document.getElementById('load_' + taskId);
}
if (!l.startTime) l.startTime = performance.now();
var text = loadTasks[taskId];
if (progress && progress.total) {
text += ': ' + (progress.currentShow || progress.current) + '/' + (progress.totalShow || progress.total) + ' (' + (progress.current * 100 / progress.total).toFixed(0) + '%)';
} else {
text += '...';
}
l.innerHTML = text;
}
function showErrorDialog(errorText) {
console.error('error: ' + errorText);
var existingErrorDialog = document.getElementById('errorDialog');
if (existingErrorDialog) {
existingErrorDialog.innerHTML += '<br>' + errorText;
} else {
$('#mainarea').empty();
$('#mainarea').append('<div class="alert alert-danger centered-axis-xy" style ="min-height: 10pt" role="alert" id="errorDialog">' + errorText + '</div></div>');
}
}
function showWarningRibbon(warningText) {
var existingWarningDialog = document.getElementById('warningDialog');
if (existingWarningDialog) {
existingWarningDialog.innerHTML += '<br>' + warningText;
} else {
$('#buttonrow').prepend('<div class="alert alert-warning centered-axis-x" role="warning" id="warningDialog" style="padding-top:5px; padding-bottom: 5px">' + warningText + '</div></div>');
}
}
function taskFinished(taskId, error) {
var l = document.getElementById('load_' + taskId);
var icon = document.getElementById('icon_' + taskId);
if (l && icon) {
var totalTime = performance.now() - l.startTime;
if (!error) {
l.innerHTML = loadTasks[taskId] + ' (' + (totalTime/1000).toFixed(2) + 's)';
icon.className = 'glyphicon glyphicon-ok';
}
else {
l.innerHTML = loadTasks[taskId] + ': FAILED! ' + error;
icon.className = 'glyphicon glyphicon-remove';
showErrorDialog(loadTasks[taskId] + ' failed: <br> ' + error);
}
}
}
window.onerror = function(e) {
showErrorDialog(e.toString());
}
function formatBytes(bytes) {
if (bytes >= 1024*1024*1024) return (bytes / (1024*1024*1024)).toFixed(1) + ' GB';
if (bytes >= 1024*1024) return (bytes / (1024*1024)).toFixed(0) + ' MB';
if (bytes >= 1024) return (bytes / 1024).toFixed(1) + ' KB';
return bytes + ' B';
}
function reportDataBytesStoredInIndexedDB(deltaBytes) {
if (deltaBytes === null) Module['dataBytesStoredInIndexedDB'] = 0; // call with deltaBytes == null to report that DB was cleared.
else Module['dataBytesStoredInIndexedDB'] += deltaBytes;
document.getElementById('clear_indexeddb').innerText = 'Clear IndexedDB (' + formatBytes(Module['dataBytesStoredInIndexedDB']) + ')';
}
function reportDownloadProgress(url, downloadedBytes, totalBytes, finished) {
Module['assetDownloadProgress'][url] = {
current: downloadedBytes,
total: totalBytes,
finished: finished
};
var aggregated = {
current: 0,
total: 0,
finished: true
};
for(var i in Module['assetDownloadProgress']) {
aggregated.current += Module['assetDownloadProgress'][i].current;
aggregated.total += Module['assetDownloadProgress'][i].total;
aggregated.finished = aggregated.finished && Module['assetDownloadProgress'][i].finished;
}
aggregated.currentShow = formatBytes(aggregated.current);
aggregated.totalShow = formatBytes(aggregated.total);
if (aggregated.finished) taskFinished(TASK_DOWNLOADING);
else taskProgress(TASK_DOWNLOADING, aggregated);
}
function download(url, responseType) {
return new Promise(function(resolve, reject) {
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.responseType = responseType || 'blob';
reportDownloadProgress(url, 0, 1);
xhr.onload = function() {
if (xhr.status == 0 || (xhr.status >= 200 && xhr.status < 300)) {
var len = xhr.response.size || xhr.response.byteLength;
reportDownloadProgress(url, len, len, true);
resolve(xhr.response);
} else {
taskFinished(TASK_DOWNLOADING, 'HTTP error ' + (xhr.status || 404) + ' ' + xhr.statusText + ' on file ' + url);
reject({
status: xhr.status,
statusText: xhr.statusText
});
}
};
xhr.onprogress = function(p) {
if (p.lengthComputable) reportDownloadProgress(url, p.loaded, p.total);
};
xhr.onerror = function(e) {
var isFileProtocol = url.indexOf('file://') == 0 || location.protocol.indexOf('file') != -1;
if (isFileProtocol) taskFinished(TASK_DOWNLOADING, 'HTTP error ' + (xhr.status || 404) + ' ' + xhr.statusText + ' on file ' + url +'<br>Try using a web server to avoid loading via a "file://" URL.'); // Convert the most common source of errors to a more friendly message format.
else taskFinished(TASK_DOWNLOADING, 'HTTP error ' + (xhr.status || 404) + ' ' + xhr.statusText + ' on file ' + url);
reject({
status: xhr.status || 404,
statusText: xhr.statusText
});
};
xhr.onreadystatechange = function() {
if (xhr.readyState >= xhr.HEADERS_RECEIVED) {
if (url.endsWith('gz') && (xhr.status == 0 || xhr.status == 200)) {
if (xhr.getResponseHeader('Content-Encoding') != 'gzip') {
// A fallback is to set serveCompressedAssets = false to serve uncompressed assets instead, but that is not really recommended for production use, since gzip compression shrinks
// download sizes so dramatically that omitting it for production is not a good idea.
taskFinished(TASK_DOWNLOADING, 'Downloaded a compressed file ' + url + ' without the necessary HTTP response header "Content-Encoding: gzip" specified!<br>Please configure gzip compression on this asset on the web server to serve gzipped assets!');
xhr.onload = xhr.onprogress = xhr.onerror = xhr.onreadystatechange = null; // Abandon tracking events from this XHR further.
xhr.abort();
return reject({
status: 406,
statusText: 'Not Acceptable'
});
}
// After enabling Content-Encoding: gzip, make sure that the appropriate MIME type is being used for the asset, i.e. the MIME
// type should be that of the uncompressed asset, and not the MIME type of the compression method that was used.
if (xhr.getResponseHeader('Content-Type').toLowerCase().indexOf('zip') != -1) {
function expectedMimeType(url) {
if (url.indexOf('.wasm') != -1) return 'application/wasm';
if (url.indexOf('.js') != -1) return 'application/javascript';
return 'application/octet-stream';
}
taskFinished(TASK_DOWNLOADING, 'Downloaded a compressed file ' + url + ' with incorrect HTTP response header "Content-Type: ' + xhr.getResponseHeader('Content-Type') + '"!<br>Please set the MIME type of the asset to "' + expectedMimeType(url) + '".');
xhr.onload = xhr.onprogress = xhr.onerror = xhr.onreadystatechange = null; // Abandon tracking events from this XHR further.
xhr.abort();
return reject({
status: 406,
statusText: 'Not Acceptable'
});
}
}
}
}
xhr.send(null);
});
}
function deleteIndexedDBStorage(dbName, onsuccess, onerror, onblocked) {
var idb = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
if (Module['dbInstance']) Module['dbInstance'].close();
if (!dbName) dbName = Module['UE4_indexedDBName'];
var req = idb.deleteDatabase(dbName);
req.onsuccess = function() { console.log('Deleted IndexedDB storage ' + dbName + '!'); reportDataBytesStoredInIndexedDB(null); if (onsuccess) onsuccess(); }
req.onerror = function(e) { console.error('Failed to delete IndexedDB storage ' + dbName + '!'); console.error(e); if (onerror) onerror(e); return false; }
req.onblocked = function(e) { console.error('Failed to delete IndexedDB storage ' + dbName + ', DB was blocked!'); console.error(e); if (onblocked) onblocked(e); return false; }
}
var enableReadFromIndexedDB = (location.search.indexOf('noidbread') == -1);
var enableWriteToIndexedDB = enableReadFromIndexedDB && (location.search.indexOf('noidbwrite') == -1);
if (!enableReadFromIndexedDB) showWarningRibbon('Running with IndexedDB access disabled.');
else if (!enableWriteToIndexedDB) showWarningRibbon('Running in read-only IndexedDB access mode.');
function storeToIndexedDB(db, key, value) {
return new Promise(function(resolve, reject) {
if (!enableWriteToIndexedDB) return reject('storeToIndexedDB: IndexedDB writes disabled by "?noidbwrite" option');
function fail(e) {
console.error('Failed to store file ' + key + ' to IndexedDB storage! error:');
console.error(e);
if (!Module['idberrorShown']) {
showWarningRibbon('Failed to store file ' + key + ' to IndexedDB, error: ' + e);
Module['idberrorShown'] = true;
}
return reject(e);
}
if (!db) return fail('IndexedDB not available!');
if (location.protocol.indexOf('file') != -1) return reject('Loading via file://, skipping caching to IndexedDB');
try {
var transaction = db.transaction(['FILES'], 'readwrite');
var packages = transaction.objectStore('FILES');
var putRequest = packages.put(value, "file/" + Module.key + '/' + key);
putRequest.onsuccess = function(event) {
if (value.byteLength || value.length) reportDataBytesStoredInIndexedDB(value.size || value.byteLength || value.length);
resolve(key);
};
putRequest.onerror = function(error) {
fail(error);
return false; /* Don't propagate the error to window.onerror handler. */
};
} catch(e) {
fail(e);
}
});
}
function fetchFromIndexedDB(db, key) {
return new Promise(function(resolve, reject) {
if (!enableReadFromIndexedDB) return reject('fetchFromIndexedDB: IndexedDB reads disabled by "?noidbread" option');
function fail(e) {
console.error('Failed to read file ' + key + ' from IndexedDB storage! error:');
console.error(e);
if (!Module['idberrorShown']) {
showWarningRibbon('Failed to read file ' + key + ' from IndexedDB, error: ' + e);
Module['idberrorShown'] = true;
}
return reject(e);
}
if (!db) return fail('IndexedDB not available!');
try {
var transaction = db.transaction(['FILES'], 'readonly');
var packages = transaction.objectStore('FILES');
var getRequest = packages.get("file/" + Module.key + '/' + key);
getRequest.onsuccess = function(event) {
if (event.target.result) {
var len = event.target.result.size || event.target.result.byteLength || event.target.result.length;
if (len) reportDataBytesStoredInIndexedDB(len);
resolve(event.target.result);
} else {
// Succeeded to load, but the load came back with the value of undefined, treat that as an error since we never store undefined in db.
reject();
}
};
getRequest.onerror = function(error) { fail(error); return false; /* Don't propagate the error to window.onerror handler. */ };
} catch(e) {
fail(e);
}
});
}
function fetchOrDownloadAndStore(db, url, responseType) {
return new Promise(function(resolve, reject) {
fetchFromIndexedDB(db, url)
.then(function(data) { return resolve(data); })
.catch(function(error) {
return download(url, responseType)
.then(function(data) {
// Treat IDB store as separate operation that's not part of the Promise chain.
/*return*/ storeToIndexedDB(db, url, data)
.then(function() { return resolve(data); })
.catch(function(error) {
console.error('Failed to store download to IndexedDB! ' + error);
return resolve(data); // succeeded download, but failed to store - ignore failure in that case and just proceed to run by calling the success handler.
})
})
.catch(function(error) { return reject(error); })
});
});
}
function openIndexedDB(dbName, dbVersion) {
return new Promise(function(resolve, reject) {
if (!enableReadFromIndexedDB) return reject('openIndexedDB: IndexedDB disabled by "?noidbread" option');
try {
var idb = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
var openRequest = idb.open(dbName, dbVersion);
} catch(e) { return reject(e); }
openRequest.onupgradeneeded = function(event) {
var db = event.target.result;
if (db.objectStoreNames.contains('FILES')) db.deleteObjectStore('FILES');
db.createObjectStore('FILES');
};
openRequest.onsuccess = function(event) {
resolve(event.target.result);
};
openRequest.onerror = function(error) { reject(error); return false; /* Don't propagate the error to window.onerror handler. */ };
});
}
Module['instantiateWasm'] = function(info, receiveInstance) {
Module['wasmDownloadAction'].then(function(downloadResults) {
taskProgress(TASK_COMPILING);
var wasmInstantiate = WebAssembly.instantiate(downloadResults.wasmModule || new Uint8Array(downloadResults.wasmBytes), info);
return wasmInstantiate.then(function(output) {
var instance = output.instance || output;
var module = output.module;
taskFinished(TASK_COMPILING);
Module['wasmInstantiateActionResolve'](instance);
receiveInstance(instance);
// After a successful instantiation, attempt to save the compiled Wasm Module object to IndexedDB.
if (!downloadResults.fromIndexedDB) {
storeToIndexedDB(downloadResults.db, 'wasmModule', module).catch(function() {
// If the browser did not support storing Wasm Modules to IndexedDB, try to store the Wasm instance instead.
return storeToIndexedDB(downloadResults.db, 'wasmBytes', downloadResults.wasmBytes);
});
}
});
}).catch(function(error) {
$ ('#mainarea').empty();
$ ('#mainarea').append('<div class="alert alert-danger centered-axis-xy" style ="min-height: 10pt" role="alert">WebAssembly instantiation failed: <br> ' + error + '</div></div>');
});
return {};
}
// Given a blob, asynchronously reads the byte contents of that blob to an arraybuffer and returns it as a Promise.
function readBlobToArrayBuffer(blob) {
return new Promise(function(resolve, reject) {
var fileReader = new FileReader();
fileReader.onload = function() { resolve(this.result); }
fileReader.onerror = function(e) { reject(e); }
fileReader.readAsArrayBuffer(blob);
});
}
function compileShadersFromJson(jsonData) {
var shaderPrograms = [];
if (jsonData instanceof ArrayBuffer) jsonData = new TextDecoder('utf-8').decode(new DataView(jsonData));
var programsDict = JSON.parse(jsonData);
for(var i in programsDict) {
shaderPrograms.push(programsDict[i]);
}
var gl = Module['preinitializedWebGLContext'];
Module['precompiledShaders'] = [];
Module['precompiledPrograms'] = [];
Module['glIDCounter'] = 1;
Module['precompiledUniforms'] = [null];
var promise = new Promise(function(resolve, reject) {
var nextProgramToBuild = 0;
function buildProgram() {
if (nextProgramToBuild >= shaderPrograms.length) {
taskFinished(TASK_SHADERS);
return resolve();
}
var p = shaderPrograms[nextProgramToBuild++];
taskProgress(TASK_SHADERS, {current: nextProgramToBuild, total: shaderPrograms.length });
var program = gl.createProgram();
function lineNumberize(str) {
str = str.split('\n');
for(var i = 0; i < str.length; ++i) str[i] = (i<9?' ':'') + (i<99?' ':'') + (i+1) + ': ' + str[i];
return str.join('\n');
}
var vs = gl.createShader(gl.VERTEX_SHADER);
gl.shaderSource(vs, p.vs);
gl.compileShader(vs);
var success = gl.getShaderParameter(vs, gl.COMPILE_STATUS);
var compileLog = gl.getShaderInfoLog(vs);
if (compileLog) compileLog = compileLog.trim();
if (compileLog) console.error('Compiling vertex shader: ' + lineNumberize(p.vs));
if (!success) console.error('Vertex shader compilation failed!');
if (compileLog) console.error('Compilation log: ' + compileLog);
if (!success) return reject('Vertex shader compilation failed: ' + compileLog);
gl.attachShader(program, vs);
Module['precompiledShaders'].push({
vs: p.vs,
shader: vs,
program: program
});
var fs = gl.createShader(gl.FRAGMENT_SHADER);
gl.shaderSource(fs, p.fs);
gl.compileShader(fs);
var success = gl.getShaderParameter(fs, gl.COMPILE_STATUS);
var compileLog = gl.getShaderInfoLog(fs);
if (compileLog) compileLog = compileLog.trim();
if (compileLog) console.error('Compiling fragment shader: ' + lineNumberize(p.fs));
if (!success) console.error('Fragment shader compilation failed!');
if (compileLog) console.error('Compilation log: ' + compileLog);
if (!success) return reject('Fragment shader compilation failed: ' + compileLog);
gl.attachShader(program, fs);
Module['precompiledShaders'].push({
fs: p.fs,
shader: fs,
program: program
});
for(var name in p.attribs) {
gl.bindAttribLocation(program, p.attribs[name], name);
}
gl.linkProgram(program);
var success = gl.getProgramParameter(program, gl.LINK_STATUS);
var linkLog = gl.getProgramInfoLog(program);
if (linkLog) linkLog = linkLog.trim();
if (linkLog) console.error('Linking shader program, vs: \n' + lineNumberize(p.vs) + ', \n fs:\n' + lineNumberize(p.fs));
if (!success) console.error('Shader program linking failed!');
if (linkLog) console.error('Link log: ' + linkLog);
if (!success) return reject('Shader linking failed: ' + linkLog);
var ptable = {
uniforms: {},
maxUniformLength: 0,
maxAttributeLength: -1,
maxUniformBlockNameLength: -1
};
var GLctx = gl;
var utable = ptable.uniforms;
var numUniforms = GLctx.getProgramParameter(program, GLctx.ACTIVE_UNIFORMS);
for (var i = 0; i < numUniforms; ++i) {
var u = GLctx.getActiveUniform(program, i);
var name = u.name;
ptable.maxUniformLength = Math.max(ptable.maxUniformLength, name.length + 1);
if (name.indexOf("]", name.length - 1) !== -1) {
var ls = name.lastIndexOf("[");
name = name.slice(0, ls);
}
var loc = GLctx.getUniformLocation(program, name);
var id = Module['glIDCounter']++;
utable[name] = [ u.size, id ];
Module['precompiledUniforms'].push(loc);
if (Module['precompiledUniforms'].length != Module['glIDCounter']) throw 'uniforms array not in sync! ' + Module['precompiledUniforms'].length + ', ' + Module['glIDCounter'];
for (var j = 1; j < u.size; ++j) {
var n = name + "[" + j + "]";
loc = GLctx.getUniformLocation(program, n);
id = Module['glIDCounter']++;
Module['precompiledUniforms'].push(loc);
if (Module['precompiledUniforms'].length != Module['glIDCounter']) throw 'uniforms array not in sync! ' + Module['precompiledUniforms'].length + ', ' + Module['glIDCounter'];
}
}
var e = gl.getError();
if (e) {
console.error('Precompiling shaders got GL error: ' + e);
return reject('Precompiling shaders got GL error: ' + e);
}
Module['precompiledPrograms'].push({
program: program,
programInfos: ptable,
vs: p.vs,
fs: p.fs
});
setTimeout(buildProgram, 0);
}
setTimeout(buildProgram, 0);
})
return promise;
}
$(document).ready(function() {
if (runningAsmJs && !explicitlyLoadedAsmJs) {
showWarningRibbon('Your browser does not support WebAssembly, so running the asm.js fallback of this page. This can impact performance.<br>Try updating to latest <a href="https://www.mozilla.org/en-US/firefox/all/">64-bit Firefox</a> for a browser that supports WebAssembly.<br>Current user agent: ' + navigator.userAgent);
}
if (!Module['buffer']) {
showErrorDialog('Failed to allocate ' + MB(MIN_MEMORY) + ' of linear memory for the ' + (runningAsmJs?'asm.js':'WebAssembly') + ' heap!');
return;
}
// check for webgl and cache it for later (UE_BrowserWebGLVersion() reads this)
Module['WEBGL_VERSION'] = detectWebGL();
console.log(getGpuInfo());
if (!Module['WEBGL_VERSION'] || Module['WEBGL_VERSION'] < requiredWebGLVersion) {
showErrorDialog('Your browser does not support WebGL ' + requiredWebGLVersion + '<br>Error reason: ' + (Module['webGLErrorReason'] || 'Unknown') + '. Try updating your browser and/or graphics card drivers.<br>Current renderer: ' + getGpuInfo());
return;
}
function shouldBrowserSupportWebGL2() {
var match = window.navigator.userAgent.match(/Firefox\/([0-9]+)\./);
if (match) return parseInt(match[1]) >= 51;
}
if (Module['WEBGL_VERSION'] < 2 && !explicitlyUseWebGL1) {
if (shouldBrowserSupportWebGL2()) {
showWarningRibbon('Your GPU does not support WebGL 2. This affects graphics performance and quality. Please try updating your graphics driver and/or browser to latest version.<br>Error reason: ' + (Module['webGLErrorReason'] || 'Unknown') + '<br>Current renderer: ' + getGpuInfo());
} else {
showWarningRibbon('The current browser is too old and does not support WebGL 2. This affects graphics performance and quality. Please try updating your browser.<br>Error reason: ' + (Module['webGLErrorReason'] || 'Unknown') + '<br>Current renderer: ' + getGpuInfo());
}
}
if (!heuristicIs64Bit('browser')) {
if (heuristicIs64Bit('os')) {
showWarningRibbon('It looks like you are running a 32-bit browser on a 64-bit operating system. This can dramatically affect performance. Try updating to <a href="https://www.mozilla.org/en-US/firefox/all/">64-bit Firefox</a> for an optimized experience.');
} else {
showWarningRibbon('It looks like your computer hardware is 32-bit. This can dramatically affect performance.');
}
}
// The following WebGL 1.0 extensions are available in core WebGL 2.0 specification, so they are no longer shown in the extensions list.
var webGLExtensionsInCoreWebGL2 = ['ANGLE_instanced_arrays','EXT_blend_minmax','EXT_color_buffer_half_float','EXT_frag_depth','EXT_sRGB','EXT_shader_texture_lod','OES_element_index_uint','OES_standard_derivatives','OES_texture_float','OES_texture_half_float','OES_texture_half_float_linear','OES_vertex_array_object','WEBGL_color_buffer_float','WEBGL_depth_texture','WEBGL_draw_buffers'];
var supportedWebGLExtensions = Module['preinitializedWebGLContext'].getSupportedExtensions();
if (Module['WEBGL_VERSION'] >= 2) supportedWebGLExtensions = supportedWebGLExtensions.concat(webGLExtensionsInCoreWebGL2);
// The following WebGL extensions are required by UE4/this project, and it cannot run without.
var requiredWebGLExtensions = []; // TODO: List WebGL extensions here that the demo needs and can't run without.
for(var i in requiredWebGLExtensions) {
if (supportedWebGLExtensions.indexOf(requiredWebGLExtensions[i]) == -1) {
showErrorDialog('Your browser does not support WebGL extension ' + requiredWebGLExtensions[i] + ', which is required to run this page!');
}
}
// The following WebGL extensions would be preferred to exist for best features/performance, but are not strictly needed and UE4 can fall back if not available.
var preferredToHaveWebGLExtensions = [// The following are core in WebGL 2:
'ANGLE_instanced_arrays', // UE4 uses instanced rendering where possible, but can fallback to noninstanced.
'EXT_color_buffer_half_float',
'EXT_sRGB',
'EXT_shader_texture_lod', // textureLod() is needed for correct reflections, without this reflection shaders are missing and render out black.
'OES_standard_derivatives',
'OES_texture_half_float',
'OES_texture_half_float_linear',
'OES_vertex_array_object',
'WEBGL_color_buffer_float',
'WEBGL_depth_texture',
'WEBGL_draw_buffers',
// These are still extensions in WebGL 2:
'OES_texture_float',
'WEBGL_compressed_texture_s3tc',
'EXT_texture_filter_anisotropic'
];
var unsupportedWebGLExtensions = [];
for(var i in preferredToHaveWebGLExtensions) {
if (supportedWebGLExtensions.indexOf(preferredToHaveWebGLExtensions[i]) == -1) {
unsupportedWebGLExtensions.push(preferredToHaveWebGLExtensions[i]);
}
}
if (unsupportedWebGLExtensions.length > 1) {
showWarningRibbon('Your browser or graphics card does not support the following WebGL extensions: ' + unsupportedWebGLExtensions.join(', ') + '. This can impact UE4 graphics performance and quality.');
} else if (unsupportedWebGLExtensions.length == 1) {
showWarningRibbon('Your browser or graphics card does not support the WebGL extension ' + unsupportedWebGLExtensions[0] + '. This can impact UE4 graphics performance and quality.');
}
function noAsmJsFallbackHostedError() {
if (location.search.indexOf('asmjs') != -1) showErrorDialog('There is no asm.js version deployed of this page.'); // Explicitly wanted to run asm.js version, but it did not exist.
else showErrorDialog('Your browser does not support WebAssembly (and there is no asm.js fallback deployed of this page). Please try with Firefox 52 or newer.<br>Current user agent: ' + navigator.userAgent); // Automatically tried to fall back to asm.js since browser didn't have wasm, but no asm.js variant existed.
}
// No WebAssembly support?
if ((!runningAsmJs || !supportsAsmJsAsFallback) && typeof WebAssembly === 'undefined') {
showErrorDialog('Your browser does not support WebAssembly. Please try with Firefox 52 or newer.<br>Current user agent: ' + navigator.userAgent);
return;
}
function withIndexedDB(db) {
Module['dbInstance'] = db;
if (!runningAsmJs) {
var mainCompiledCode = fetchFromIndexedDB(db, 'wasmModule').then(function(wasmModule) {
return { db: db, wasmModule: wasmModule, fromIndexedDB: true };
}).catch(function() {
return fetchFromIndexedDB(db, 'wasmBytes').then(function(wasmBytes) {
return { db: db, wasmBytes: wasmBytes, fromIndexedDB: true };
});
}).catch(function() {
return download(Module.locateFile('%CONFIG%.wasm'), 'arraybuffer').then(function(wasmBytes) {
return { db: db, wasmBytes: wasmBytes, fromIndexedDB: false };
});
});
Module['wasmDownloadAction'] = mainCompiledCode;
var compiledCodeInstantiateAction = new Promise(function(resolve, reject) {
Module['wasmInstantiateActionResolve'] = resolve;
Module['wasmInstantiateActionReject'] = reject;
});
var mainJsDownload = fetchOrDownloadAndStore(db, Module.locateFile('%CONFIG%.js')).then(addScriptToDom);
if (runningAsmJs) mainJsDownload = mainJsDownload.catch(noAsmJsFallbackHostedError);
} else {
var mainCompiledCode = fetchOrDownloadAndStore(db, Module.locateFile('%CONFIG%.asm.js'), 'arraybuffer').then(function(data) {
taskProgress(TASK_COMPILING);
return addScriptToDom(data).then(function() {
taskFinished(TASK_COMPILING);
}).catch(function(e) {
taskFinished(TASK_COMPILING, e);
});
}).catch(function(e) {
noAsmJsFallbackHostedError();
});
var compiledCodeInstantiateAction = true; // There is no need to manually instantiate asm.js, so instead of having a Promise() to resolve that, pass through true as a no-op.
var asmJsRuntimeDownload = fetchOrDownloadAndStore(db, Module.locateFile('%CONFIG%_asm.js')).catch(noAsmJsFallbackHostedError);
var mainJsDownload = Promise.all([asmJsRuntimeDownload, mainCompiledCode]).then(function(results) { addScriptToDom(results[0]); });
}
var dataJsDownload = fetchOrDownloadAndStore(db, Module.locateFile('%GAME%.data.js'));
var utilityJsDownload = fetchOrDownloadAndStore(db, Module.locateFile('Utility.js')).then(addScriptToDom);
var dataDownload =
/* // The following code would download and store the .data file as a Blob, which should be more efficient than loading an ArrayBuffer. However that seems to be buggy, so avoid it for now.
fetchOrDownloadAndStore(db, Module.locateFile('%GAME%.data')).then(function(dataBlob) {
return readBlobToArrayBuffer(dataBlob).then(function(dataArrayBuffer) {
Module['preloadedPackages'] = {};
Module['preloadedPackages'][Module.locateFile('%GAME%.data')] = dataArrayBuffer;
return dataJsDownload.then(addScriptToDom);
})
});
*/
// Instead as a fallback, download as ArrayBuffer. (TODO: Figure out the bugs with the above, and switch to using that one instead)
fetchOrDownloadAndStore(db, Module.locateFile('%GAME%.data'), 'arraybuffer').then(function(dataArrayBuffer) {
Module['preloadedPackages'] = {};
Module['preloadedPackages'][Module.locateFile('%GAME%.data')] = dataArrayBuffer;
return dataJsDownload.then(addScriptToDom);
});
const precompileShaders = false; // Currently not enabled.
if (precompileShaders) {
var compileShaders = fetchOrDownloadAndStore(db, Module.locateFile('shaders.json'), 'arraybuffer')
.then(function(json) {
return compileShadersFromJson(json)
.catch(function(error) {
taskFinished(TASK_SHADERS, error + '<br>Current renderer: ' + getGpuInfo());
throw 'Shader compilation failed';
});
});
} else {
var compileShaders = true; // Not precompiling shaders, no-op Promise action.
}
Promise.all([mainCompiledCode, mainJsDownload, dataJsDownload, utilityJsDownload, dataDownload, compiledCodeInstantiateAction, compileShaders]).then(function() {
if (!precompileShaders) {
Module['precompiledShaders'] = Module['precompiledPrograms'] = Module['preinitializedWebGLContext'] = Module['glIDCounter'] = Module['precompiledUniforms'] = null;
}
taskProgress(TASK_MAIN);
setTimeout(function() {
removeRunDependency('wait-for-compiled-code'); // Now we are ready to call main()
}, 100);
});
};
openIndexedDB(Module['UE4_indexedDBName'], Module['UE4_indexedDBVersion'] || 1).then(withIndexedDB).catch(function(e) {
console.error('Failed to openIndexedDB, proceeding without reading or storing contents to IndexedDB! Error: ');
console.error(e);
withIndexedDB(null);
});
});
</script>
</body>
</html>