diff options
| author | realtradam <[email protected]> | 2023-03-04 19:53:46 -0500 |
|---|---|---|
| committer | realtradam <[email protected]> | 2023-03-04 19:53:46 -0500 |
| commit | e507454912f69b202c0a49d772696eabcccaa024 (patch) | |
| tree | e2f51bce8eee08d6c96b7abb7f74063b159210e7 | |
| parent | 50d4ca3c7df7ca7d67a4435ea726a6c68375a814 (diff) | |
| download | rodeo_sample_game-e507454912f69b202c0a49d772696eabcccaa024.tar.gz rodeo_sample_game-e507454912f69b202c0a49d772696eabcccaa024.zip | |
add emscripten
| -rw-r--r-- | CMakeLists.txt | 46 | ||||
| -rwxr-xr-x | build | 3 | ||||
| -rwxr-xr-x | configure | 3 | ||||
| m--------- | external/RodeoEngine | 0 | ||||
| -rwxr-xr-x | run | 2 | ||||
| -rwxr-xr-x | serve | 3 | ||||
| -rw-r--r-- | src/main.c | 135 |
7 files changed, 123 insertions, 69 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index c885377..5a81e2e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,15 +1,28 @@ cmake_minimum_required(VERSION 3.25.1) -set(CMAKE_BUILD_TYPE Debug) - project(space_squad) +if (${CMAKE_SYSTEM_NAME} MATCHES "Emscripten") + set(CMAKE_EXECUTABLE_SUFFIX ".html") +endif() + +set(CMAKE_BUILD_TYPE Debug) + file(GLOB SOURCES "src/main.c" ) add_executable(${PROJECT_NAME} ${SOURCES}) +if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Emscripten") +target_compile_options(${PROJECT_NAME} PRIVATE +-Wall +-Wextra +-Wpedantic +#-Werror +) +endif() + find_package(Git QUIET) if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git") # Update submodules as needed @@ -27,6 +40,8 @@ endif() add_subdirectory(external/RodeoEngine) +add_dependencies(${PROJECT_NAME} RodeoEngine) + target_include_directories(${PROJECT_NAME} PUBLIC external/RodeoEngine/include ) @@ -34,3 +49,30 @@ target_include_directories(${PROJECT_NAME} target_link_libraries(${PROJECT_NAME} RodeoEngine ) + +add_custom_command(TARGET ${PROJECT_NAME} PRE_BUILD + DEPENDS RodeoEngine + COMMAND ${CMAKE_COMMAND} -E copy_directory + ${CMAKE_SOURCE_DIR}/external/RodeoEngine/build_dir/shaders $<TARGET_FILE_DIR:${PROJECT_NAME}>/shaders + ) + +if (${CMAKE_SYSTEM_NAME} MATCHES "Emscripten") + set_target_properties(space_squad PROPERTIES LINK_FLAGS "-s USE_SDL=2 -s USE_SDL_IMAGE=2 -s ALLOW_MEMORY_GROWTH") + + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} \ + -s MAX_WEBGL_VERSION=2 \ + -s WASM=1 \ + -s NO_EXIT_RUNTIME=1 \ + -s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1 \ + -s OFFSCREENCANVAS_SUPPORT=1 \ + -s ALLOW_MEMORY_GROWTH=1\ + --preload-file shaders") + + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \ + -fno-exceptions \ + -fno-rtti \ + -s USE_SDL=2") + #-s USE_SDL_IMAGE=2 \ + +endif () + @@ -1,2 +1,3 @@ #! /bin/sh -cd build_dir ; make +cd build_dir/tux ; make +#cd build_dir/web ; emmake make @@ -1,3 +1,4 @@ #! /bin/sh -cmake -S . -B build_dir +cmake -S . -B build_dir/tux +#emcmake cmake -S . -B build_dir/web diff --git a/external/RodeoEngine b/external/RodeoEngine -Subproject b172c2a6b22796dc16c059979d2ec6108b0402e +Subproject 4bd628fc4a9a8244c70fc241f9e6576e4af2d35 @@ -1,4 +1,4 @@ #! /bin/sh #gdb ./build_dir/space_squad -./build_dir/space_squad +(cd ./build_dir/tux/ ; ./space_squad) @@ -0,0 +1,3 @@ +#! /bin/sh + +ruby -run -ehttpd ./build_dir/web -p8000 @@ -1,5 +1,3 @@ -#include <stdio.h> -#include <stdbool.h> #include "rodeo.h" @@ -47,75 +45,84 @@ const Rodeo__color_rgba_t pink_clear = 0.5f }; -int -main() +void +main_loop(void) { - Rodeo__init_window(&state, 480, 640, "Rodeo Window"); + Rodeo__begin(state); - while(!Rodeo__should_quit(state)) - { - Rodeo__begin(state); + //printf("%s\n", Rodeo__get_renderer_name_as_string()); - Rodeo__draw_rectangle( - state, - 100, 100, - 50, 50, - red - ); - Rodeo__draw_rectangle( - state, - 100, 160, - 50, 50, - green - ); - Rodeo__draw_rectangle( - state, - 160, 100, - 50, 50, - blue - ); - Rodeo__draw_rectangle( - state, - 160, 160, - 50, 50, - pink - ); + Rodeo__draw_rectangle( + state, + 100, 100, + 50, 50, + red + ); + Rodeo__draw_rectangle( + state, + 100, 160, + 50, 50, + green + ); + Rodeo__draw_rectangle( + state, + 160, 100, + 50, 50, + blue + ); + Rodeo__draw_rectangle( + state, + 160, 160, + 50, 50, + pink + ); - Rodeo__draw_rectangle( - state, - 300, 300, - 50, 50, - red_clear - ); - Rodeo__draw_rectangle( - state, - 310, 310, - 50, 50, - green_clear - ); - Rodeo__draw_rectangle( - state, - 320, 320, - 50, 50, - blue_clear - ); - Rodeo__draw_rectangle( - state, - 330, 330, - 50, 50, - pink_clear - ); + Rodeo__draw_rectangle( + state, + 300, 300, + 50, 50, + red_clear + ); + Rodeo__draw_rectangle( + state, + 310, 310, + 50, 50, + green_clear + ); + Rodeo__draw_rectangle( + state, + 320, 320, + 50, 50, + blue_clear + ); + Rodeo__draw_rectangle( + state, + 330, 330, + 50, 50, + pink_clear + ); + Rodeo__draw_debug_text( + 1, + 1, + " using %s renderer ", + Rodeo__get_renderer_name_as_string() + ); + + Rodeo__end(state); +} - Rodeo__draw_debug_text( - 1, - 1, - " using %s renderer ", - Rodeo__get_renderer_name_as_string() - ); +int +main() +{ + printf("Init window...\n"); + Rodeo__init_window(&state, 480, 640, "Rodeo Window"); + printf("done creating window\n"); - Rodeo__end(state); - } + Rodeo__execute_main_loop( + state, + main_loop + ); Rodeo__deinit_window(state); Rodeo__quit(); |
