summaryrefslogtreecommitdiffstats
path: root/unityplugin/GhostCubeScene
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2017-12-12 06:43:48 +0000
committerEgor Yusov <egor.yusov@gmail.com>2017-12-12 06:43:48 +0000
commitc4bf1a06ce887fe6eafad80c1a2fda4be52388e7 (patch)
tree68e209415527f553c2b1f8dd1adf4c6afb57e700 /unityplugin/GhostCubeScene
parentUpdated Visual Studio cmake config (diff)
downloadDiligentEngine-c4bf1a06ce887fe6eafad80c1a2fda4be52388e7.tar.gz
DiligentEngine-c4bf1a06ce887fe6eafad80c1a2fda4be52388e7.zip
Added CMake files for Unity plugin & Emulator
Diffstat (limited to 'unityplugin/GhostCubeScene')
-rw-r--r--unityplugin/GhostCubeScene/CMakeLists.txt69
-rw-r--r--unityplugin/GhostCubeScene/src/GhostCubeScene.cpp10
2 files changed, 74 insertions, 5 deletions
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
+ "\"$<TARGET_FILE:GhostCubePlugin-shared>\""
+ "\"$<TARGET_FILE_DIR:GhostCubeScene>\"")
+
+#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());