emscripten support
parent
04e257ec61
commit
644fd23a0d
|
@ -12,7 +12,6 @@ GPATH
|
||||||
GRTAGS
|
GRTAGS
|
||||||
GTAGS
|
GTAGS
|
||||||
/run_release.bat
|
/run_release.bat
|
||||||
/package.bat
|
|
||||||
pkg
|
pkg
|
||||||
pkg.zip
|
pkg.zip
|
||||||
eco2d.zip
|
eco2d.zip
|
|
@ -13,6 +13,13 @@ if(MSVC)
|
||||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if (EMSCRIPTEN)
|
||||||
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s USE_GLFW=3 -s ASSERTIONS=1 -s WASM=1 -s INITIAL_MEMORY=268435456 -s FORCE_FILESYSTEM=1 --preload-file ${CMAKE_SOURCE_DIR}/art@art/")
|
||||||
|
set(CMAKE_EXECUTABLE_SUFFIX ".html") # This line is used to set your executable to build with the emscripten html template so that you can directly open it.
|
||||||
|
set(CMAKE_COMPILE_WARNING_AS_ERROR OFF)
|
||||||
|
set(CMAKE_CXX_)
|
||||||
|
endif ()
|
||||||
|
|
||||||
include_directories(code/common code/vendors code/vendors/flecs)
|
include_directories(code/common code/vendors code/vendors/flecs)
|
||||||
|
|
||||||
include(cmake/FindRaylib.cmake)
|
include(cmake/FindRaylib.cmake)
|
||||||
|
|
|
@ -3,6 +3,8 @@ function(link_system_libs target_name)
|
||||||
target_link_libraries(${target_name} winmm)
|
target_link_libraries(${target_name} winmm)
|
||||||
elseif (APPLE)
|
elseif (APPLE)
|
||||||
target_link_libraries(${target_name} pthread m dl)
|
target_link_libraries(${target_name} pthread m dl)
|
||||||
|
elseif (EMSCRIPTEN)
|
||||||
|
target_link_libraries(${target_name} pthread m dl)
|
||||||
elseif (UNIX)
|
elseif (UNIX)
|
||||||
target_link_libraries(${target_name} pthread m dl atomic)
|
target_link_libraries(${target_name} pthread m dl atomic)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include "profiler.h"
|
#include "profiler.h"
|
||||||
|
|
||||||
#include "flecs/flecs_os_api_stdcpp.h"
|
#include "flecs/flecs_os_api_stdcpp.h"
|
||||||
|
#include "flecs/flecs.h"
|
||||||
|
|
||||||
#include "modules/components.h"
|
#include "modules/components.h"
|
||||||
#include "modules/systems.h"
|
#include "modules/systems.h"
|
||||||
|
@ -114,8 +115,10 @@ size_t game_world_view_count(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void flecs_dash_init() {
|
void flecs_dash_init() {
|
||||||
|
#if !defined(ZPL_SYSTEM_EMSCRIPTEN)
|
||||||
ecs_singleton_set(world_ecs(), EcsRest, {0});
|
ecs_singleton_set(world_ecs(), EcsRest, {0});
|
||||||
ECS_IMPORT(world_ecs(), FlecsMonitor);
|
ECS_IMPORT(world_ecs(), FlecsMonitor);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
float game_time() {
|
float game_time() {
|
||||||
|
|
|
@ -14,6 +14,11 @@
|
||||||
#include "modules/components.h"
|
#include "modules/components.h"
|
||||||
#include "modules/systems.h"
|
#include "modules/systems.h"
|
||||||
|
|
||||||
|
#if defined(PLATFORM_WEB)
|
||||||
|
#include <emscripten/emscripten.h>
|
||||||
|
void UpdateDrawFrame(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
#define DEFAULT_WORLD_SEED 302097
|
#define DEFAULT_WORLD_SEED 302097
|
||||||
#define DEFAULT_CHUNK_SIZE 16 /* amount of blocks within a chunk (single axis) */
|
#define DEFAULT_CHUNK_SIZE 16 /* amount of blocks within a chunk (single axis) */
|
||||||
#define DEFAULT_WORLD_SIZE 32 /* amount of chunks within a world (single axis) */
|
#define DEFAULT_WORLD_SIZE 32 /* amount of chunks within a world (single axis) */
|
||||||
|
@ -73,6 +78,7 @@ int main(int argc, char** argv) {
|
||||||
sighandler_register();
|
sighandler_register();
|
||||||
game_init(host, port, play_mode, num_viewers, seed, chunk_size, world_size, is_dash_enabled);
|
game_init(host, port, play_mode, num_viewers, seed, chunk_size, world_size, is_dash_enabled);
|
||||||
|
|
||||||
|
#if !defined(PLATFORM_WEB)
|
||||||
while (game_is_running()) {
|
while (game_is_running()) {
|
||||||
profile (PROF_MAIN_LOOP) {
|
profile (PROF_MAIN_LOOP) {
|
||||||
game_input();
|
game_input();
|
||||||
|
@ -82,6 +88,9 @@ int main(int argc, char** argv) {
|
||||||
|
|
||||||
profiler_collate();
|
profiler_collate();
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
emscripten_set_main_loop(UpdateDrawFrame, 0, 1);
|
||||||
|
#endif
|
||||||
|
|
||||||
game_shutdown();
|
game_shutdown();
|
||||||
sighandler_unregister();
|
sighandler_unregister();
|
||||||
|
@ -90,3 +99,11 @@ int main(int argc, char** argv) {
|
||||||
zpl_opts_free(&opts);
|
zpl_opts_free(&opts);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(EMSCRIPTEN)
|
||||||
|
void UpdateDrawFrame(void) {
|
||||||
|
game_input();
|
||||||
|
game_update();
|
||||||
|
game_render();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
|
@ -7,3 +7,4 @@ file(GLOB SRCS *.h
|
||||||
)
|
)
|
||||||
|
|
||||||
add_library(flecs-bundle STATIC ${SRCS})
|
add_library(flecs-bundle STATIC ${SRCS})
|
||||||
|
target_compile_options(flecs-bundle PRIVATE "-Wno-enum-constexpr-conversion")
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,18 @@
|
||||||
|
@echo off
|
||||||
|
|
||||||
|
cmake --build build_rel --parallel 32 --config Release
|
||||||
|
if not %ERRORLEVEL% == 0 exit /B 1
|
||||||
|
@rd /S /Q pkg
|
||||||
|
mkdir pkg
|
||||||
|
copy build_rel\eco2d.exe pkg
|
||||||
|
rem tools\upx -9 pkg\eco2d.exe
|
||||||
|
robocopy art pkg\art /E
|
||||||
|
@del pkg\art\*.ecotex
|
||||||
|
|
||||||
|
IF NOT "%1"=="SKIP_DEPLOY" (
|
||||||
|
pushd pkg
|
||||||
|
..\tools\7za.exe a -r ..\eco2d.zip *.*
|
||||||
|
popd
|
||||||
|
|
||||||
|
butler push eco2d.zip zaklaus/eco2d:win64-latest
|
||||||
|
)
|
Loading…
Reference in New Issue