From c4bf1a06ce887fe6eafad80c1a2fda4be52388e7 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Mon, 11 Dec 2017 22:43:48 -0800 Subject: Added CMake files for Unity plugin & Emulator --- unityplugin/GhostCubeScene/CMakeLists.txt | 69 +++++++++++++++++++++++ unityplugin/GhostCubeScene/src/GhostCubeScene.cpp | 10 ++-- 2 files changed, 74 insertions(+), 5 deletions(-) create mode 100644 unityplugin/GhostCubeScene/CMakeLists.txt (limited to 'unityplugin/GhostCubeScene') diff --git a/unityplugin/GhostCubeScene/CMakeLists.txt b/unityplugin/GhostCubeScene/CMakeLists.txt new file mode 100644 index 0000000..4f4aaf9 --- /dev/null +++ b/unityplugin/GhostCubeScene/CMakeLists.txt @@ -0,0 +1,69 @@ +cmake_minimum_required (VERSION 3.3) + +project(GhostCubeScene CXX) + +set(SOURCE + src/GhostCubeScene.cpp +) + +set(INCLUDE + src/GhostCubeScene.h +) + +if(PLATFORM_WIN32 OR PLATFORM_UNIVERSAL_WINDOWS) + list(APPEND SOURCE src/GhostCubeSceneResTrsnHelper.cpp) + list(APPEND INCLUDE src/GhostCubeSceneResTrsnHelper.h) +elseif(PLATFORM_ANDROID) + list(APPEND SOURCE src/Android/AndroidMain.cpp) +endif() + +if(PLATFORM_WIN32) + add_executable(GhostCubeScene WIN32 ${SOURCE} ${INCLUDE}) + set_target_properties(GhostCubeScene PROPERTIES + VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/build/assets" + ) + + add_custom_command(TARGET GhostCubeScene POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "\"$\"" + "\"$\"") + +#elseif(APPLE) + #add_executable(GhostCubeScene MACOSX_BUNDLE Main.cpp) +#elseif(UNIX) + #add_executable(GhostCubeScene Main.cpp) +else() + message(FATAL_ERROR "Unknown platform") +endif() + +target_include_directories(GhostCubeScene +PRIVATE + ../GhostCubePlugin/PluginSource/src/Unity +) + +target_link_libraries(GhostCubeScene +PRIVATE + BuildSettings + UnityEmulator + TargetPlatform +) + +if(MSVC) + # Disable MSVC-specific warnings + # - w4201: nonstandard extension used: nameless struct/unio + target_compile_options(GhostCubeScene PRIVATE /wd4201) + # Enable link-time code generation for release builds (I was not able to + # find any way to set these settings through interface library BuildSettings) + set_target_properties(GhostCubeScene PROPERTIES + LINK_FLAGS_RELEASE /LTCG + LINK_FLAGS_MINSIZEREL /LTCG + LINK_FLAGS_RELWITHDEBINFO /LTCG + ) +endif() + +source_group("src" FILES ${SOURCE}) +source_group("include" FILES ${INCLUDE}) + +set_target_properties(GhostCubeScene PROPERTIES + FOLDER Unity +) diff --git a/unityplugin/GhostCubeScene/src/GhostCubeScene.cpp b/unityplugin/GhostCubeScene/src/GhostCubeScene.cpp index 2fb3a97..dd3483f 100644 --- a/unityplugin/GhostCubeScene/src/GhostCubeScene.cpp +++ b/unityplugin/GhostCubeScene/src/GhostCubeScene.cpp @@ -177,11 +177,11 @@ void GhostCubeScene::Render(UnityRenderingEvent RenderEventFunc, double CurrTime float aspectRatio = 1.0f; float4x4 ReflectionCameraProj = Projection(PI_F / 4.f, aspectRatio, NearPlane, FarPlane, IsDX); auto wvp = CubeWorldView * ReflectionCameraProj; - float ReverseZ = IsDX ? -1.f : +1.f; - SetMatrixFromUnity(wvp._m00, ReverseZ * wvp._m01, wvp._m02, wvp._m03, - wvp._m10, ReverseZ * wvp._m11, wvp._m12, wvp._m13, - wvp._m20, ReverseZ * wvp._m21, wvp._m22, wvp._m23, - wvp._m30, ReverseZ * wvp._m31, wvp._m32, wvp._m33); + float fReverseZ = IsDX ? -1.f : +1.f; + SetMatrixFromUnity(wvp._m00, fReverseZ * wvp._m01, wvp._m02, wvp._m03, + wvp._m10, fReverseZ * wvp._m11, wvp._m12, wvp._m13, + wvp._m20, fReverseZ * wvp._m21, wvp._m22, wvp._m23, + wvp._m30, fReverseZ * wvp._m31, wvp._m32, wvp._m33); SetTexturesFromUnity(m_pRenderTarget->GetNativeHandle(), m_pDepthBuffer->GetNativeHandle()); -- cgit v1.2.3