Web build
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -9,6 +9,8 @@ tiled/PixelDefense.tiled-session
|
|||||||
venv/
|
venv/
|
||||||
scripts/__pycache__/
|
scripts/__pycache__/
|
||||||
|
|
||||||
|
PixelDefense.zip
|
||||||
|
|
||||||
imgui.ini
|
imgui.ini
|
||||||
settings.ini
|
settings.ini
|
||||||
game_data.ini
|
game_data.ini
|
||||||
|
|||||||
@@ -50,7 +50,10 @@ add_executable(PixelDefense
|
|||||||
|
|
||||||
target_link_libraries(PixelDefense LINK_PRIVATE Breeze)
|
target_link_libraries(PixelDefense LINK_PRIVATE Breeze)
|
||||||
if (EMSCRIPTEN)
|
if (EMSCRIPTEN)
|
||||||
|
#set_target_properties(PixelDefense
|
||||||
|
# PROPERTIES SUFFIX ".html"
|
||||||
|
# LINK_FLAGS "-lidbfs.js --shell-file ../index.html -sEXPORTED_FUNCTIONS=_loopPause,_loopResume,_main -sEXTRA_EXPORTED_RUNTIME_METHODS=ccall -sFORCE_FILESYSTEM=1 -sWASM=1 -sSTACK_OVERFLOW_CHECK=2 -sALLOW_MEMORY_GROWTH -sSTACK_SIZE=10MB -sASSERTIONS=2 -sMIN_WEBGL_VERSION=1 --preload-file ../assets -g2 -gseparate-dwarf -gsource-map -sUSE_GLFW=3")
|
||||||
set_target_properties(PixelDefense
|
set_target_properties(PixelDefense
|
||||||
PROPERTIES SUFFIX ".html"
|
PROPERTIES SUFFIX ".html"
|
||||||
LINK_FLAGS "-lidbfs.js -sEXPORTED_FUNCTIONS=_loopPause,_loopResume,_main -sEXTRA_EXPORTED_RUNTIME_METHODS=ccall -sFORCE_FILESYSTEM=1 -sWASM=1 -sSTACK_OVERFLOW_CHECK=2 -sALLOW_MEMORY_GROWTH -sSTACK_SIZE=10MB -sASSERTIONS=2 -sMIN_WEBGL_VERSION=1 --preload-file ../assets -g2 -gseparate-dwarf -gsource-map -sUSE_GLFW=3")
|
LINK_FLAGS "-lidbfs.js -O3 --shell-file ../index.html -sEXPORTED_FUNCTIONS=_loopPause,_loopResume,_main -sEXTRA_EXPORTED_RUNTIME_METHODS=ccall -sFORCE_FILESYSTEM=1 -sWASM=1 -sALLOW_MEMORY_GROWTH -sSTACK_SIZE=10MB -sASSERTIONS=0 -sMIN_WEBGL_VERSION=1 --preload-file ../assets -sUSE_GLFW=3")
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
15
build_web.sh
Executable file
15
build_web.sh
Executable file
@@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
#rm -rf build_web
|
||||||
|
#mkdir build_web
|
||||||
|
pushd build_web || exit
|
||||||
|
|
||||||
|
emcmake cmake .. -DPLATFORM=Web
|
||||||
|
emmake make
|
||||||
|
|
||||||
|
mv PixelDefense.html index.html
|
||||||
|
|
||||||
|
rm -f ../PixelDefense.zip
|
||||||
|
zip ../PixelDefense.zip index.html PixelDefense.*
|
||||||
|
|
||||||
|
popd || exit
|
||||||
@@ -64,7 +64,7 @@ bool bzMain(BzAppDesc *appDesc, int argc, const char **argv) {
|
|||||||
|
|
||||||
appDesc->userData = NULL;
|
appDesc->userData = NULL;
|
||||||
|
|
||||||
//SetConfigFlags(FLAG_WINDOW_RESIZABLE);
|
SetConfigFlags(FLAG_WINDOW_RESIZABLE);
|
||||||
#ifdef EMSCRIPTEN
|
#ifdef EMSCRIPTEN
|
||||||
EM_ASM(
|
EM_ASM(
|
||||||
FS.mkdir('/game');
|
FS.mkdir('/game');
|
||||||
|
|||||||
63
index.html
Normal file
63
index.html
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<title>PixelDefense</title>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
|
<style>
|
||||||
|
/*
|
||||||
|
#canvas {
|
||||||
|
position: absolute;
|
||||||
|
top: 0px;
|
||||||
|
left: 0px;
|
||||||
|
margin: 0px;
|
||||||
|
border: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<!-- Create the canvas that the C code will draw into -->
|
||||||
|
<div>
|
||||||
|
<canvas id="canvas" oncontextmenu="event.preventDefault()" style="position: absolute; background-color: #000;"></canvas>
|
||||||
|
<div class="emscripten" style="position: absolute; right: 0; bottom: 0;">
|
||||||
|
<input type="checkbox" id="resize" checked style="display: none;">
|
||||||
|
<input type="checkbox" id="pointerLock" style="display: none;">
|
||||||
|
<button type="button" onclick="Module.requestFullscreen(document.getElementById('pointerLock').checked,
|
||||||
|
document.getElementById('resize').checked)">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="M120-120v-240h80v104l124-124 56 56-124 124h104v80H120Zm480 0v-80h104L580-324l56-56 124 124v-104h80v240H600ZM324-580 200-704v104h-80v-240h240v80H256l124 124-56 56Zm312 0-56-56 124-124H600v-80h240v240h-80v-104L636-580Z"/></svg>
|
||||||
|
</button>
|
||||||
|
<!--
|
||||||
|
<input type="checkbox" id="pointerLock" checked>Lock/hide mouse pointer
|
||||||
|
|
||||||
|
<input type="button" value="Fullscreen" onclick="Module.requestFullscreen(document.getElementById('pointerLock').checked,
|
||||||
|
document.getElementById('resize').checked)">
|
||||||
|
-->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Allow the C code to access the canvas element -->
|
||||||
|
<script type='text/javascript'>
|
||||||
|
//const canvas = document.getElementById('canvas');
|
||||||
|
// For some reason WebGL default is true :/
|
||||||
|
//const gl = canvas.getContext("webgl", { premultipliedAlpha: false });
|
||||||
|
var Module = {
|
||||||
|
canvas: (function() { return document.getElementById('canvas'); })()
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<!-- Add the javascript glue code generated by Emscripten -->
|
||||||
|
<!-- <script src="PixelDefense.js"></script> -->
|
||||||
|
{{{ SCRIPT }}}
|
||||||
|
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user