changes to build system, emscipten progress (can render solid color, yippie!)
This commit is contained in:
parent
dd4fc45be3
commit
f25e27b102
@ -148,6 +148,7 @@ function(give_options_without_warnings target)
|
|||||||
-fno-signed-zeros
|
-fno-signed-zeros
|
||||||
-fno-trapping-math
|
-fno-trapping-math
|
||||||
-freciprocal-math
|
-freciprocal-math
|
||||||
|
# TODO: require packaging for web case
|
||||||
$<$<BOOL:${EMSCRIPTEN}>:-sUSE_SDL=2>)
|
$<$<BOOL:${EMSCRIPTEN}>:-sUSE_SDL=2>)
|
||||||
|
|
||||||
set(BUILD_FLAGS_RELEASE
|
set(BUILD_FLAGS_RELEASE
|
||||||
@ -169,7 +170,8 @@ function(give_options_without_warnings target)
|
|||||||
set(LINK_FLAGS
|
set(LINK_FLAGS
|
||||||
-Bsymbolic-functions
|
-Bsymbolic-functions
|
||||||
|
|
||||||
$<$<BOOL:${EMSCRIPTEN}>:-sLEGACY_GL_EMULATION -sGL_FFP_ONLY -sGL_UNSAFE_OPTS>
|
$<$<BOOL:${EMSCRIPTEN}>:-sLEGACY_GL_EMULATION -sGL_FFP_ONLY -sGL_UNSAFE_OPTS=1>
|
||||||
|
$<$<BOOL:${EMSCRIPTEN}>:--preload-file ${TWN_OUT_DIR}/data@data -sALLOW_MEMORY_GROWTH>
|
||||||
$<$<NOT:$<BOOL:${EMSCRIPTEN}>>:-Wl,--as-needed>
|
$<$<NOT:$<BOOL:${EMSCRIPTEN}>>:-Wl,--as-needed>
|
||||||
$<$<BOOL:${LINUX}>:-Wl,--hash-style=gnu>)
|
$<$<BOOL:${LINUX}>:-Wl,--hash-style=gnu>)
|
||||||
|
|
||||||
@ -198,7 +200,6 @@ function(give_options_without_warnings target)
|
|||||||
target_link_options(${target} PUBLIC
|
target_link_options(${target} PUBLIC
|
||||||
${BUILD_FLAGS}
|
${BUILD_FLAGS}
|
||||||
${LINK_FLAGS}
|
${LINK_FLAGS}
|
||||||
# -Wl,--no-undefined # TODO: use later for implementing no-libc
|
|
||||||
$<$<CONFIG:Release>:${LINK_FLAGS_RELEASE}>
|
$<$<CONFIG:Release>:${LINK_FLAGS_RELEASE}>
|
||||||
$<$<CONFIG:Debug>:${BUILD_FLAGS_DEBUG}>)
|
$<$<CONFIG:Debug>:${BUILD_FLAGS_DEBUG}>)
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ if(NOT CMAKE_BUILD_TYPE)
|
|||||||
set(CMAKE_BUILD_TYPE Debug)
|
set(CMAKE_BUILD_TYPE Debug)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_subdirectory($ENV{TWNROOT} $ENV{TWNROOT}/build)
|
add_subdirectory($ENV{TWNROOT} ${CMAKE_BINARY_DIR}/twn)
|
||||||
|
|
||||||
set(SOURCE_FILES
|
set(SOURCE_FILES
|
||||||
game.c
|
game.c
|
||||||
|
@ -6,7 +6,7 @@ if(NOT CMAKE_BUILD_TYPE)
|
|||||||
set(CMAKE_BUILD_TYPE Debug)
|
set(CMAKE_BUILD_TYPE Debug)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_subdirectory($ENV{TWNROOT} $ENV{TWNROOT}/build)
|
add_subdirectory($ENV{TWNROOT} ${CMAKE_BINARY_DIR}/twn)
|
||||||
|
|
||||||
set(SOURCE_FILES
|
set(SOURCE_FILES
|
||||||
game.c
|
game.c
|
||||||
|
@ -6,7 +6,7 @@ if(NOT CMAKE_BUILD_TYPE)
|
|||||||
set(CMAKE_BUILD_TYPE Debug)
|
set(CMAKE_BUILD_TYPE Debug)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_subdirectory($ENV{TWNROOT} $ENV{TWNROOT}/build)
|
add_subdirectory($ENV{TWNROOT} ${CMAKE_BINARY_DIR}/twn)
|
||||||
|
|
||||||
set(SOURCE_FILES
|
set(SOURCE_FILES
|
||||||
game.c
|
game.c
|
||||||
|
@ -5,7 +5,7 @@ if(NOT CMAKE_BUILD_TYPE)
|
|||||||
set(CMAKE_BUILD_TYPE Debug)
|
set(CMAKE_BUILD_TYPE Debug)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_subdirectory($ENV{TWNROOT} $ENV{TWNROOT}/build)
|
add_subdirectory($ENV{TWNROOT} ${CMAKE_BINARY_DIR}/twn)
|
||||||
|
|
||||||
set(SOURCE_FILES
|
set(SOURCE_FILES
|
||||||
game.c
|
game.c
|
||||||
@ -13,4 +13,4 @@ set(SOURCE_FILES
|
|||||||
)
|
)
|
||||||
|
|
||||||
cmake_path(GET CMAKE_SOURCE_DIR STEM LAST_ONLY GAME_PROJECT_NAME)
|
cmake_path(GET CMAKE_SOURCE_DIR STEM LAST_ONLY GAME_PROJECT_NAME)
|
||||||
use_townengine(${GAME_PROJECT_NAME} "${SOURCE_FILES}" ${CMAKE_CURRENT_SOURCE_DIR})
|
use_townengine("${SOURCE_FILES}" ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
@ -14,6 +14,7 @@ dev_id = "you"
|
|||||||
# Game runtime details
|
# Game runtime details
|
||||||
[game]
|
[game]
|
||||||
resolution = [ 640, 480 ]
|
resolution = [ 640, 480 ]
|
||||||
|
background_color = [ 255, 125, 0, 255 ]
|
||||||
#debug = true
|
#debug = true
|
||||||
|
|
||||||
# Engine tweaks. You probably don't need to change these
|
# Engine tweaks. You probably don't need to change these
|
||||||
|
@ -7,7 +7,7 @@ if(NOT CMAKE_BUILD_TYPE)
|
|||||||
set(CMAKE_BUILD_TYPE Debug)
|
set(CMAKE_BUILD_TYPE Debug)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_subdirectory($ENV{TWNROOT} $ENV{TWNROOT}/build)
|
add_subdirectory($ENV{TWNROOT} ${CMAKE_BINARY_DIR}/twn)
|
||||||
|
|
||||||
set(FLAGS
|
set(FLAGS
|
||||||
$<$<NOT:$<BOOL:${TWN_FEATURE_DYNLIB_GAME}>>:--no-dynlib-game>
|
$<$<NOT:$<BOOL:${TWN_FEATURE_DYNLIB_GAME}>>:--no-dynlib-game>
|
||||||
@ -34,7 +34,7 @@ add_compile_definitions(LUA_32BITS=1)
|
|||||||
|
|
||||||
set(SOURCE_FILES
|
set(SOURCE_FILES
|
||||||
game.c
|
game.c
|
||||||
state.h
|
minilua.c
|
||||||
)
|
)
|
||||||
|
|
||||||
use_townengine("${SOURCE_FILES}" ${TWN_OUT_DIR})
|
use_townengine("${SOURCE_FILES}" ${TWN_OUT_DIR})
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#include "twn_game_api.h"
|
#include "twn_game_api.h"
|
||||||
|
|
||||||
/* TODO: actually move it back it its own file, it doesn't give any compilation benefits */
|
/* TODO: actually move it back it its own file, it doesn't give any compilation benefits */
|
||||||
#define LUA_IMPL
|
|
||||||
#include "minilua.h"
|
#include "minilua.h"
|
||||||
|
|
||||||
#include "state.h"
|
#include "state.h"
|
||||||
|
2
apps/twnlua/minilua.c
Normal file
2
apps/twnlua/minilua.c
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
#define LUA_IMPL
|
||||||
|
#include "minilua.h"
|
@ -24,9 +24,9 @@
|
|||||||
|
|
||||||
static void pack_contents_modified(char const *path, enum FilewatchAction action);
|
static void pack_contents_modified(char const *path, enum FilewatchAction action);
|
||||||
|
|
||||||
|
#ifndef EMSCRIPTEN
|
||||||
static SDL_sem *opengl_load_semaphore;
|
static SDL_sem *opengl_load_semaphore;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* note: it drives most of IO implicitly, such as audio callbacks */
|
/* note: it drives most of IO implicitly, such as audio callbacks */
|
||||||
static void poll_events(void) {
|
static void poll_events(void) {
|
||||||
@ -425,6 +425,7 @@ static bool initialize(void) {
|
|||||||
toml_datum_t datum_debug = toml_bool_in(game, "debug");
|
toml_datum_t datum_debug = toml_bool_in(game, "debug");
|
||||||
ctx.game.debug = datum_debug.ok ? datum_debug.u.b : true;
|
ctx.game.debug = datum_debug.ok ? datum_debug.u.b : true;
|
||||||
|
|
||||||
|
#ifndef EMSCRIPTEN
|
||||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 1);
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 1);
|
||||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 5);
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 5);
|
||||||
|
|
||||||
@ -441,6 +442,11 @@ static bool initialize(void) {
|
|||||||
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
||||||
SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1);
|
SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1);
|
||||||
|
|
||||||
|
#else
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
|
||||||
|
#endif
|
||||||
|
|
||||||
toml_datum_t datum_title = toml_string_in(about, "title");
|
toml_datum_t datum_title = toml_string_in(about, "title");
|
||||||
if (!datum_title.ok)
|
if (!datum_title.ok)
|
||||||
datum_title.u.s = SDL_strdup("townengine project");
|
datum_title.u.s = SDL_strdup("townengine project");
|
||||||
@ -624,9 +630,11 @@ static bool initialize(void) {
|
|||||||
profile_end("game object load");
|
profile_end("game object load");
|
||||||
|
|
||||||
/* delayed as further as possible so that more work is done before we have to wait */
|
/* delayed as further as possible so that more work is done before we have to wait */
|
||||||
|
#ifndef EMSCRIPTEN
|
||||||
SDL_SemWait(opengl_load_semaphore);
|
SDL_SemWait(opengl_load_semaphore);
|
||||||
SDL_DestroySemaphore(opengl_load_semaphore);
|
SDL_DestroySemaphore(opengl_load_semaphore);
|
||||||
profile_end("opengl loading");
|
profile_end("opengl loading");
|
||||||
|
#endif
|
||||||
|
|
||||||
SDL_SetHint(SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR, "0");
|
SDL_SetHint(SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR, "0");
|
||||||
SDL_SetHint(SDL_HINT_WINDOWS_NO_CLOSE_ON_ALT_F4, "1");
|
SDL_SetHint(SDL_HINT_WINDOWS_NO_CLOSE_ON_ALT_F4, "1");
|
||||||
@ -763,6 +771,7 @@ int enter_loop(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
profile_end("SDL initialization");
|
profile_end("SDL initialization");
|
||||||
|
|
||||||
|
#ifndef EMSCRIPTEN
|
||||||
profile_start("opengl loading");
|
profile_start("opengl loading");
|
||||||
opengl_load_semaphore = SDL_CreateSemaphore(0);
|
opengl_load_semaphore = SDL_CreateSemaphore(0);
|
||||||
SDL_Thread *opengl_load_thread = SDL_CreateThread(opengl_load_thread_fn, "opengl loader", opengl_load_semaphore);
|
SDL_Thread *opengl_load_thread = SDL_CreateThread(opengl_load_thread_fn, "opengl loader", opengl_load_semaphore);
|
||||||
@ -773,6 +782,7 @@ int enter_loop(int argc, char **argv) {
|
|||||||
|
|
||||||
SDL_DetachThread(opengl_load_thread);
|
SDL_DetachThread(opengl_load_thread);
|
||||||
opengl_load_thread = NULL;
|
opengl_load_thread = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
ctx.argc = argc;
|
ctx.argc = argc;
|
||||||
ctx.argv = argv;
|
ctx.argv = argv;
|
||||||
|
@ -50,6 +50,7 @@ bool workers_init(size_t worker_count) {
|
|||||||
if (worker_count > MAX_WORKERS)
|
if (worker_count > MAX_WORKERS)
|
||||||
worker_count = MAX_WORKERS;
|
worker_count = MAX_WORKERS;
|
||||||
|
|
||||||
|
#ifndef EMSCRIPTEN
|
||||||
/* spawn a bunch of detached threads without references to them */
|
/* spawn a bunch of detached threads without references to them */
|
||||||
for (size_t i = 0; i < worker_count; ++i) {
|
for (size_t i = 0; i < worker_count; ++i) {
|
||||||
SDL_Thread *thread = SDL_CreateThread(worker_thread, "worker", NULL);
|
SDL_Thread *thread = SDL_CreateThread(worker_thread, "worker", NULL);
|
||||||
@ -61,11 +62,13 @@ bool workers_init(size_t worker_count) {
|
|||||||
workers_job_semaphore = SDL_CreateSemaphore(0);
|
workers_job_semaphore = SDL_CreateSemaphore(0);
|
||||||
workers_exit_semaphore = SDL_CreateSemaphore(0);
|
workers_exit_semaphore = SDL_CreateSemaphore(0);
|
||||||
workers_mutex = SDL_CreateMutex();
|
workers_mutex = SDL_CreateMutex();
|
||||||
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void workers_deinit(void) {
|
void workers_deinit(void) {
|
||||||
|
#ifndef EMSCRIPTEN
|
||||||
SDL_LockMutex(workers_mutex);
|
SDL_LockMutex(workers_mutex);
|
||||||
workers_should_exit = true;
|
workers_should_exit = true;
|
||||||
SDL_UnlockMutex(workers_mutex);
|
SDL_UnlockMutex(workers_mutex);
|
||||||
@ -77,5 +80,6 @@ void workers_deinit(void) {
|
|||||||
SDL_DestroyMutex(workers_mutex);
|
SDL_DestroyMutex(workers_mutex);
|
||||||
SDL_DestroySemaphore(workers_job_semaphore);
|
SDL_DestroySemaphore(workers_job_semaphore);
|
||||||
SDL_DestroySemaphore(workers_exit_semaphore);
|
SDL_DestroySemaphore(workers_exit_semaphore);
|
||||||
|
#endif
|
||||||
workers_pool_size = 0;
|
workers_pool_size = 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user