From 3d0d6764a7047765bf897e9c59b950bf87a53704 Mon Sep 17 00:00:00 2001 From: Vadim Grigoruk Date: Tue, 25 Sep 2018 11:47:18 +0300 Subject: [PATCH] windows build for sokol --- 3rd-party | 2 +- CMakeLists.txt | 32 +++++++++++++++++++------------- examples/sokol/sokol.c | 16 ++++++++++++++++ 3 files changed, 36 insertions(+), 14 deletions(-) diff --git a/3rd-party b/3rd-party index 215169c..77c1800 160000 --- a/3rd-party +++ b/3rd-party @@ -1 +1 @@ -Subproject commit 215169c035212fe09b1f31006c25fd180da98323 +Subproject commit 77c1800a010722018a3b9c41882bc75a86327cb0 diff --git a/CMakeLists.txt b/CMakeLists.txt index bbafa7f..b751b5f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -236,21 +236,25 @@ set(SOKOL_SRC ${EXAMPLE_DIR}/sokol/main.c ) -if(APPLE) - add_definitions(-DSOKOL_METAL) -elseif(WIN32) - add_definitions(-DSOKOL_D3D11) -elseif(LINUX) - add_definitions(-DSOKOL_GLCORE33) -endif() - if(APPLE) set(SOKOL_SRC ${SOKOL_SRC} ${EXAMPLE_DIR}/sokol/sokol.m) else() set(SOKOL_SRC ${SOKOL_SRC} ${EXAMPLE_DIR}/sokol/sokol.c) endif() -add_executable(sokol-renderer ${SOKOL_SRC}) +if(APPLE) + set_source_files_properties(${SOKOL_SRC} PROPERTIES COMPILE_FLAGS -DSOKOL_METAL) +elseif(WIN32) + set_source_files_properties(${SOKOL_SRC} PROPERTIES COMPILE_FLAGS "-DSOKOL_D3D11 -DSOKOL_D3D11_SHADER_COMPILER") +elseif(LINUX) + set_source_files_properties(${SOKOL_SRC} PROPERTIES COMPILE_FLAGS -DSOKOL_GLCORE33) +endif() + +if(WIN32) + add_executable(sokol-renderer WIN32 ${SOKOL_SRC}) +else() + add_executable(sokol-renderer ${SOKOL_SRC}) +endif() if(APPLE) set_property (TARGET sokol-renderer APPEND_STRING PROPERTY @@ -263,6 +267,12 @@ if(APPLE) "-framework MetalKit" "-framework AudioToolbox" ) +elseif(WIN32) + target_link_libraries(sokol-renderer D3D11) + + if(MINGW) + target_link_libraries(sokol-renderer D3dcompiler_47 mingw32) + endif() elseif(LINUX) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread") target_link_libraries(sokol-renderer X11 GL m dl asound) @@ -272,10 +282,6 @@ target_include_directories(sokol-renderer PRIVATE include) target_include_directories(sokol-renderer PRIVATE 3rd-party/sokol) target_include_directories(sokol-renderer PRIVATE src) -if(MINGW) - target_link_libraries(sokol-renderer mingw32) -endif() - add_dependencies(sokol-renderer tic80core) target_link_libraries(sokol-renderer tic80core) diff --git a/examples/sokol/sokol.c b/examples/sokol/sokol.c index 8530ff0..2b425e3 100644 --- a/examples/sokol/sokol.c +++ b/examples/sokol/sokol.c @@ -1,5 +1,21 @@ #define SOKOL_IMPL +#if defined(WIN32) + +#ifndef WM_MOUSEHWHEEL +#define WM_MOUSEHWHEEL 0x020E +#endif + +#ifndef AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM +#define AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM 0x80000000 +#endif + +#ifndef AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY +#define AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY 0x08000000 +#endif + +#endif + #include "sokol_app.h" #include "sokol_gfx.h" #include "sokol_time.h"