diff --git a/project/src/graphics/opengl/OpenGL.h b/project/src/graphics/opengl/OpenGL.h index 9b4c350e2..a8659af41 100644 --- a/project/src/graphics/opengl/OpenGL.h +++ b/project/src/graphics/opengl/OpenGL.h @@ -13,9 +13,9 @@ #elif defined (EMSCRIPTEN) #define LIME_GLES -#define LIME_GLES3_API -#include -#include +// #define LIME_GLES3_API +#include +#include #elif defined (TIZEN) diff --git a/src/haxe/io/Bytes.hx b/src/haxe/io/Bytes.hx index 5385c6f83..fe48a362d 100644 --- a/src/haxe/io/Bytes.hx +++ b/src/haxe/io/Bytes.hx @@ -55,7 +55,7 @@ class Bytes return untyped $sget(b, pos); #elseif flash return b[pos]; - #elseif cpp + #elseif (cpp || emscripten) return untyped b[pos]; #elseif java return untyped b[pos] & 0xFF; @@ -72,7 +72,7 @@ class Bytes untyped $sset(b, pos, v); #elseif flash b[pos] = v; - #elseif cpp + #elseif (cpp || emscripten) untyped b[pos] = v; #elseif java b[pos] = cast v; @@ -104,7 +104,7 @@ class Bytes cs.system.Array.Copy(src.b, srcpos, b, pos, len); #elseif python python.Syntax.code("self.b[{0}:{0}+{1}] = src.b[srcpos:srcpos+{1}]", pos, len); - #elseif cpp + #elseif (cpp || emscripten) b.blit(pos, src.b, srcpos, len); #else var b1 = b; @@ -136,7 +136,7 @@ class Bytes pos += len & ~3; for (i in 0...len & 3) set(pos++, value); - #elseif cpp + #elseif (cpp || emscripten) untyped __global__.__hxcpp_memory_memset(b, pos, len, value); #else for (i in 0...len) @@ -206,7 +206,7 @@ class Bytes return length - other.length; // #elseif cs // TODO: memcmp if unsafe flag is on - #elseif cpp + #elseif (cpp || emscripten) return b.memcmp(other.b); #else var b1 = b; @@ -232,7 +232,7 @@ class Bytes #elseif flash b.position = pos; return b.readDouble(); - #elseif cpp + #elseif (cpp || emscripten) if (pos < 0 || pos + 8 > length) throw Error.OutsideBounds; return untyped __global__.__hxcpp_memory_get_double(b, pos); #else @@ -254,7 +254,7 @@ class Bytes #elseif flash b.position = pos; return b.readFloat(); - #elseif cpp + #elseif (cpp || emscripten) if (pos < 0 || pos + 4 > length) throw Error.OutsideBounds; return untyped __global__.__hxcpp_memory_get_float(b, pos); #else @@ -278,7 +278,7 @@ class Bytes #elseif flash b.position = pos; b.writeDouble(v); - #elseif cpp + #elseif (cpp || emscripten) if (pos < 0 || pos + 8 > length) throw Error.OutsideBounds; untyped __global__.__hxcpp_memory_set_double(b, pos, v); #else @@ -304,7 +304,7 @@ class Bytes #elseif flash b.position = pos; b.writeFloat(v); - #elseif cpp + #elseif (cpp || emscripten) if (pos < 0 || pos + 4 > length) throw Error.OutsideBounds; untyped __global__.__hxcpp_memory_set_float(b, pos, v); #else @@ -398,7 +398,7 @@ class Bytes #elseif flash b.position = pos; return b.readUTFBytes(len); - #elseif cpp + #elseif (cpp || emscripten) var result:String = ""; untyped __global__.__hxcpp_string_of_bytes(b, result, pos, len); return result; @@ -510,7 +510,7 @@ class Bytes var b = new flash.utils.ByteArray(); b.length = length; return new Bytes(length, b); - #elseif cpp + #elseif (cpp || emscripten) var a = new BytesData(); if (length > 0) cpp.NativeArray.setSize(a, length); return new Bytes(length, a); @@ -540,7 +540,7 @@ class Bytes var b = new flash.utils.ByteArray(); b.writeUTFBytes(s); return new Bytes(b.length, b); - #elseif cpp + #elseif (cpp || emscripten) var a = new BytesData(); untyped __global__.__hxcpp_bytes_of_string(a, s); return new Bytes(a.length, a); @@ -638,7 +638,7 @@ class Bytes return untyped __dollar__sget(b, pos); #elseif flash return b[pos]; - #elseif cpp + #elseif (cpp || emscripten) return untyped b.unsafeGet(pos); #elseif java return untyped b[pos] & 0xFF; diff --git a/src/lime/system/ThreadPool.hx b/src/lime/system/ThreadPool.hx index 479ad17b5..83d824b55 100644 --- a/src/lime/system/ThreadPool.hx +++ b/src/lime/system/ThreadPool.hx @@ -7,7 +7,7 @@ import lime.app.Event; #if haxe4 import sys.thread.Deque; import sys.thread.Thread; -#elseif cpp +#elseif (cpp || emscripten) import cpp.vm.Deque; import cpp.vm.Thread; #elseif neko @@ -30,7 +30,7 @@ class ThreadPool public var onProgress = new EventVoid>(); public var onRun = new EventVoid>(); - #if (cpp || neko) + #if (cpp || neko || emscripten) @:noCompletion private var __synchronous:Bool; @:noCompletion private var __workCompleted:Int; @:noCompletion private var __workIncoming = new Deque(); @@ -45,7 +45,7 @@ class ThreadPool currentThreads = 0; - #if (cpp || neko) + #if (cpp || neko || emscripten) __workQueued = 0; __workCompleted = 0; #end @@ -67,7 +67,7 @@ class ThreadPool // } public function queue(state:Dynamic = null):Void { - #if (cpp || neko) + #if (cpp || neko || emscripten) // TODO: Better way to handle this? if (Application.current != null && Application.current.window != null && !__synchronous) @@ -98,7 +98,7 @@ class ThreadPool public function sendComplete(state:Dynamic = null):Void { - #if (cpp || neko) + #if (cpp || neko || emscripten) if (!__synchronous) { __workResult.add(new ThreadPoolMessage(COMPLETE, state)); @@ -111,7 +111,7 @@ class ThreadPool public function sendError(state:Dynamic = null):Void { - #if (cpp || neko) + #if (cpp || neko || emscripten) if (!__synchronous) { __workResult.add(new ThreadPoolMessage(ERROR, state)); @@ -124,7 +124,7 @@ class ThreadPool public function sendProgress(state:Dynamic = null):Void { - #if (cpp || neko) + #if (cpp || neko || emscripten) if (!__synchronous) { __workResult.add(new ThreadPoolMessage(PROGRESS, state)); @@ -137,7 +137,7 @@ class ThreadPool @:noCompletion private function runWork(state:Dynamic = null):Void { - #if (cpp || neko) + #if (cpp || neko || emscripten) if (!__synchronous) { __workResult.add(new ThreadPoolMessage(WORK, state)); @@ -150,7 +150,7 @@ class ThreadPool doWork.dispatch(state); } - #if (cpp || neko) + #if (cpp || neko || emscripten) @:noCompletion private function __doWork():Void { while (true) diff --git a/templates/emscripten/template/index.html b/templates/emscripten/template/index.html index a97b19e73..3465820a1 100644 --- a/templates/emscripten/template/index.html +++ b/templates/emscripten/template/index.html @@ -1,17 +1,17 @@ - + - + ::APP_TITLE:: - + - + ::if linkedLibraries::::foreach (linkedLibraries):: ::end::::end:: - + - + - + ::foreach assets::::if (type == "font"):: ::end::::end:: - +
- + - + ::if DEBUG::::end:: - + - + \ No newline at end of file diff --git a/tools/platforms/EmscriptenPlatform.hx b/tools/platforms/EmscriptenPlatform.hx index 6760d8838..f585ee55b 100644 --- a/tools/platforms/EmscriptenPlatform.hx +++ b/tools/platforms/EmscriptenPlatform.hx @@ -127,10 +127,11 @@ class EmscriptenPlatform extends PlatformTarget if (noOutput) return; CPPHelper.compile(project, targetDirectory + "/obj", ["-Demscripten", "-Dwebgl", "-Dstatic_link"]); + // CPPHelper.compile(project, targetDirectory + "/obj", ["-Demscripten", "-Dwebgl", "-Dstatic_link"], "BuildMain.xml"); project.path(sdkPath); - System.runCommand("", "emcc", [targetDirectory + "/obj/Main.cpp", "-o", targetDirectory + "/obj/Main.o"], true, false, true); + System.runCommand("", "emcc", ["-c", targetDirectory + "/obj/Main.cpp", "-o", targetDirectory + "/obj/Main.o"], true, false, true); args = ["Main.o"]; @@ -159,11 +160,8 @@ class EmscriptenPlatform extends PlatformTarget "-o", "ApplicationMain.o" ]); - System.runCommand(targetDirectory + "/obj", "emcc", args, true, false, true); - args = ["ApplicationMain.o"]; - - if (project.targetFlags.exists("webassembly") || project.targetFlags.exists("wasm")) + if (project.targetFlags.exists("webassembly") || project.targetFlags.exists("wasm") || !project.targetFlags.exists("asmjs")) { args.push("-s"); args.push("WASM=1"); @@ -404,7 +402,8 @@ class EmscriptenPlatform extends PlatformTarget ProjectHelper.recursiveSmartCopyTemplate(project, "emscripten/template", destination, context); ProjectHelper.recursiveSmartCopyTemplate(project, "haxe", targetDirectory + "/haxe", context); ProjectHelper.recursiveSmartCopyTemplate(project, "emscripten/hxml", targetDirectory + "/haxe", context); - ProjectHelper.recursiveSmartCopyTemplate(project, "emscripten/cpp", targetDirectory + "/obj", context); + // ProjectHelper.recursiveSmartCopyTemplate(project, "emscripten/cpp", targetDirectory + "/obj", context); + ProjectHelper.recursiveSmartCopyTemplate(project, "cpp/static", targetDirectory + "/obj", context); for (asset in project.assets) {