Add Emscripten support
This commit is contained in:
@@ -9,33 +9,35 @@
|
||||
|
||||
extern "C" const char *hxRunLibrary();
|
||||
extern "C" void hxcpp_set_top_of_stack();
|
||||
|
||||
::foreach ndlls::
|
||||
::if (registerStatics)::
|
||||
extern "C" int ::name::_register_prims();
|
||||
::end::
|
||||
::end::
|
||||
|
||||
extern "C" int main(int argc, char *argv[])
|
||||
{
|
||||
//printf("Starting ...\n" );
|
||||
hxcpp_set_top_of_stack();
|
||||
|
||||
::foreach ndlls::
|
||||
::if (registerStatics)::
|
||||
::name::_register_prims();
|
||||
::end::
|
||||
::end::
|
||||
extern "C" int zlib_register_prims();
|
||||
::foreach ndlls::::if (registerStatics)::extern "C" int ::name::_register_prims();::end::
|
||||
::end::
|
||||
|
||||
|
||||
extern "C" int main(int argc, char *argv[]) {
|
||||
|
||||
//printf("Starting ...\n" );
|
||||
hxcpp_set_top_of_stack ();
|
||||
|
||||
zlib_register_prims ();
|
||||
|
||||
::foreach ndlls::::if (registerStatics)::::name::_register_prims();::end::
|
||||
::end::
|
||||
|
||||
//printf("Running\n");
|
||||
|
||||
|
||||
const char *err = NULL;
|
||||
err = hxRunLibrary();
|
||||
err = hxRunLibrary ();
|
||||
|
||||
if (err) {
|
||||
|
||||
printf(" Error %s\n", err );
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
//printf("Done!\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,7 +2,6 @@
|
||||
-cp ::BUILD_DIR::/emscripten/haxe
|
||||
-cpp ::CPP_DIR::
|
||||
--macro keep("::APP_MAIN::")
|
||||
-lib openfl-native
|
||||
-D emscripten
|
||||
-D webgl
|
||||
-debug
|
||||
@@ -1,47 +1,66 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en"::if (WIN_WIDTH == 0)::::if (WIN_HEIGHT == 0):: style="height: 100%;"::end::::end::>
|
||||
<html lang="en">
|
||||
<head>
|
||||
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="chrome=1, IE=edge">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
|
||||
<title>::APP_TITLE::</title>
|
||||
|
||||
<meta id="viewport" name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
|
||||
::if linkedLibraries::::foreach (linkedLibraries)::
|
||||
<script type="text/javascript" src="::__current__::"></script>::end::::end::
|
||||
|
||||
<script>
|
||||
window.addEventListener ("touchmove", function (event) { event.preventDefault (); }, false);
|
||||
if (typeof window.devicePixelRatio != 'undefined' && window.devicePixelRatio > 2) {
|
||||
var meta = document.getElementById ("viewport");
|
||||
meta.setAttribute ('content', 'width=device-width, initial-scale=' + (2 / window.devicePixelRatio) + ', user-scalable=no');
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
html,body { margin: 0; padding: 0; height: 100%; overflow: hidden; }
|
||||
#content { background: #000000; width: 100%; height: 100%; }
|
||||
::foreach assets::::if (type == "font")::
|
||||
@font-face {
|
||||
font-family: '::id::';
|
||||
src: url('::targetPath::.eot');
|
||||
src: url('::targetPath::.eot?#iefix') format('embedded-opentype'),
|
||||
url('::targetPath::.svg#my-font-family') format('svg'),
|
||||
url('::targetPath::.woff') format('woff'),
|
||||
url('::targetPath::.ttf') format('truetype');
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}::end::::end::
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body style="padding: 0; margin: 0; background-color: #FFFFFF;::if (WIN_WIDTH == 0)::::if (WIN_HEIGHT == 0):: height: 100%;::end::::end::">
|
||||
<body>
|
||||
::foreach assets::::if (type == "font")::
|
||||
<span style="font-family: ::id::"> </span>::end::::end::
|
||||
|
||||
<!-- <div id="haxe:trace" style="position: absolute; z-index: 2147483647;::if !debug:: display: none;::end::"></div> -->
|
||||
<!-- <div id="haxe:jeash" style="background-color: #::WIN_FLASHBACKGROUND::; width: ::if (WIN_WIDTH == 0)::100%::else::::WIN_WIDTH::px::end::; height: ::if (WIN_HEIGHT == 0)::100%::else::::WIN_HEIGHT::px::end::" data-framerate="::WIN_FPS::"></div> -->
|
||||
|
||||
<div id="canvas-container" style="background-color: #::WIN_FLASHBACKGROUND::;::if (WIN_WIDTH == 0):: width: 100%;::end::::if (WIN_HEIGHT == 0):: height: 100%;::end:: overflow:hidden;">
|
||||
<div id="content">
|
||||
<canvas id="canvas"::if (WIN_WIDTH != 0):: width="::WIN_WIDTH::px"::end::::if (WIN_HEIGHT != 0):: height="::WIN_HEIGHT::px"::end::></canvas>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
var Module = {};
|
||||
Module.canvas = document.getElementById("canvas");
|
||||
::if DEBUG::Module.setStatus = function (msg) { console.log (msg); };::else::Module.setStatus = function(_) {};::end::
|
||||
Module.canvas = document.getElementById ("canvas");
|
||||
//::if DEBUG::Module.setStatus = function (msg) { console.log (msg); };::else::Module.setStatus = function(_) {};::end::
|
||||
Module.setStatus = function (msg) { console.log (msg); };
|
||||
::if (WIN_WIDTH == 0)::::if (WIN_HEIGHT == 0)::
|
||||
var container = document.getElementById("canvas-container");
|
||||
var container = document.getElementById ("content");
|
||||
Module.canvas.width = container.clientWidth;
|
||||
Module.canvas.height = container.clientHeight;
|
||||
|
||||
window.document.addEventListener("touchmove", function (e) {
|
||||
|
||||
e.preventDefault ();
|
||||
|
||||
}, false);
|
||||
|
||||
window.addEventListener ("resize", function (e) {
|
||||
|
||||
if (Browser) {
|
||||
|
||||
Browser.setCanvasSize (container.clientWidth, container.clientHeight);
|
||||
|
||||
} else {
|
||||
|
||||
Module.canvas.width = container.clientWidth;
|
||||
Module.canvas.height = container.clientHeight;
|
||||
|
||||
}
|
||||
Module.canvas.width = container.clientWidth;
|
||||
Module.canvas.height = container.clientHeight;
|
||||
|
||||
}, true);::end::::end::
|
||||
|
||||
@@ -49,7 +68,6 @@
|
||||
|
||||
::if DEBUG::<script type="text/javascript" src="./webgl-debug.js"></script>::end::
|
||||
|
||||
<script>function winParameters () { return ::WIN_PARAMETERS::; }</script>
|
||||
<script type="text/javascript" src="./::APP_FILE::.js"></script>
|
||||
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user