From 20939a1bab4813ab42e217278b92603969341c52 Mon Sep 17 00:00:00 2001 From: nesbox Date: Thu, 20 Sep 2018 12:39:34 +0300 Subject: [PATCH] sokol test --- CMakeLists.txt | 40 ++++++++++++++++++++++++++++++++++++++++ sokol/main.c | 38 ++++++++++++++++++++++++++++++++++++++ sokol/sokol.m | 7 +++++++ 3 files changed, 85 insertions(+) create mode 100644 sokol/main.c create mode 100644 sokol/sokol.m diff --git a/CMakeLists.txt b/CMakeLists.txt index 7daf625..a4a0444 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -224,6 +224,46 @@ if(NOT EMSCRIPTEN) target_link_libraries(sdl-renderer tic80core SDL2-static SDL2main) endif() +################################ +# Sokol renderer example +################################ + +set(SOKOL_DIR sokol) + +set(SOKOL_SRC + ${SOKOL_DIR}/main.c +) + +if(APPLE) + set(SOKOL_SRC ${SOKOL_SRC} ${SOKOL_DIR}/sokol.m) +endif() + +add_executable(sokol ${SOKOL_SRC}) + +if(APPLE) + set_property (TARGET sokol APPEND_STRING PROPERTY + COMPILE_FLAGS "-fobjc-arc") + + target_link_libraries(sokol + "-framework Cocoa" + "-framework QuartzCore" + "-framework Metal" + "-framework MetalKit" + "-framework AudioToolbox" + ) +endif() + +target_include_directories(sokol PRIVATE include) +target_include_directories(sokol PRIVATE ../sokol) +target_include_directories(sokol PRIVATE src) + +if(MINGW) + target_link_libraries(sokol mingw32) +endif() + +add_dependencies(sokol tic80core) +target_link_libraries(sokol tic80core) + ################################ # SDL GPU ################################ diff --git a/sokol/main.c b/sokol/main.c new file mode 100644 index 0000000..6d50eed --- /dev/null +++ b/sokol/main.c @@ -0,0 +1,38 @@ +#include "sokol_app.h" +#include "sokol_gfx.h" +#include "sokol_time.h" +#include "sokol_audio.h" + +static void app_init(void) +{ + +} + +static void app_frame(void) +{ + +} + +static void app_input(const sapp_event* event) +{ + +} + +static void app_cleanup(void) +{ + +} + +sapp_desc sokol_main(int argc, char* argv[]) { + // args_init(argc, argv); + return (sapp_desc) { + .init_cb = app_init, + .frame_cb = app_frame, + .event_cb = app_input, + .cleanup_cb = app_cleanup, + .width = 3 * 256, + .height = 3 * 144, + .window_title = "TIC-80", + .ios_keyboard_resizes_canvas = true + }; +} \ No newline at end of file diff --git a/sokol/sokol.m b/sokol/sokol.m new file mode 100644 index 0000000..df78733 --- /dev/null +++ b/sokol/sokol.m @@ -0,0 +1,7 @@ +#define SOKOL_IMPL +#define SOKOL_METAL + +#include "sokol_app.h" +#include "sokol_gfx.h" +#include "sokol_time.h" +#include "sokol_audio.h"