From 9ccee73baca0fd7ecb95c90cb983133b737c6c55 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Tue, 20 Oct 2015 20:46:28 -0700 Subject: Release v1.0.0 --- .../Windows/AndroidPlatform-Debug.vgdbsettings | 76 ++++++ .../Windows/AndroidPlatform-Release.vgdbsettings | 76 ++++++ .../Android/build/Windows/AndroidPlatform.vcxproj | 54 ++++ .../build/Windows/AndroidPlatform.vcxproj.filters | 46 ++++ Platforms/Android/build/Windows/jni/Android.mk | 26 ++ Platforms/Android/build/Windows/jni/Application.mk | 7 + Platforms/Android/include/AndroidDebug.h | 32 +++ Platforms/Android/include/AndroidFileSystem.h | 66 +++++ .../Android/include/AndroidPlatformDefinitions.h | 30 +++ Platforms/Android/include/AndroidPlatformMisc.h | 43 +++ Platforms/Android/src/AndroidDebug.cpp | 47 ++++ Platforms/Android/src/AndroidFileSystem.cpp | 180 +++++++++++++ .../build/Windows/BasicPlatform-Debug.vgdbsettings | 76 ++++++ .../Windows/BasicPlatform-Release.vgdbsettings | 76 ++++++ Platforms/Basic/build/Windows/BasicPlatform.props | 10 + .../Basic/build/Windows/BasicPlatform.vcxproj | 173 +++++++++++++ .../build/Windows/BasicPlatform.vcxproj.filters | 24 ++ Platforms/Basic/build/Windows/EngineRoot.props | 14 + Platforms/Basic/build/Windows/jni/Android.mk | 26 ++ Platforms/Basic/build/Windows/jni/Application.mk | 7 + .../BasicPlatform.Shared.vcxitems | 32 +++ .../BasicPlatform.Shared.vcxitems.filters | 36 +++ .../BasicPlatform.Windows.vcxproj | 207 +++++++++++++++ .../BasicPlatform.Windows.vcxproj.filters | 5 + .../BasicPlatform.WindowsPhone.vcxproj | 146 +++++++++++ .../BasicPlatform.WindowsPhone.vcxproj.filters | 5 + .../Basic/build/WindowsStore/EngineRoot.props | 14 + Platforms/Basic/include/BasicAtomics.h | 65 +++++ Platforms/Basic/include/BasicFileSystem.h | 103 ++++++++ Platforms/Basic/include/BasicPlatformDebug.h | 40 +++ Platforms/Basic/include/BasicPlatformMisc.h | 40 +++ Platforms/Basic/include/pch.h | 27 ++ Platforms/Basic/src/BasicFileSystem.cpp | 124 +++++++++ Platforms/Basic/src/pch.cpp | 24 ++ Platforms/Windows/build/Windows/EngineRoot.props | 14 + .../Windows/build/Windows/WindowsPlatform.props | 10 + .../Windows/build/Windows/WindowsPlatform.vcxproj | 164 ++++++++++++ .../build/Windows/WindowsPlatform.vcxproj.filters | 41 +++ Platforms/Windows/include/WindowsDebug.h | 32 +++ Platforms/Windows/include/WindowsFileSystem.h | 65 +++++ .../Windows/include/WindowsPlatformDefinitions.h | 25 ++ Platforms/Windows/include/WindowsPlatformMisc.h | 43 +++ Platforms/Windows/include/pch.h | 29 +++ Platforms/Windows/src/WindowsDebug.cpp | 88 +++++++ Platforms/Windows/src/WindowsFileSystem.cpp | 287 +++++++++++++++++++++ Platforms/Windows/src/pch.cpp | 24 ++ .../build/WindowsStore/EngineRoot.props | 14 + .../WindowsStorePlatform.Shared.vcxitems | 32 +++ .../WindowsStorePlatform.Shared.vcxitems.filters | 36 +++ .../WindowsStorePlatform.Windows.vcxproj | 212 +++++++++++++++ .../WindowsStorePlatform.Windows.vcxproj.filters | 5 + .../WindowsStorePlatform.WindowsPhone.vcxproj | 148 +++++++++++ ...ndowsStorePlatform.WindowsPhone.vcxproj.filters | 5 + Platforms/WindowsStore/include/WindowsStoreDebug.h | 32 +++ .../WindowsStore/include/WindowsStoreFileSystem.h | 72 ++++++ .../include/WindowsStorePlatformDefinitions.h | 25 ++ Platforms/WindowsStore/include/pch.h | 29 +++ Platforms/WindowsStore/src/WindowsStoreDebug.cpp | 84 ++++++ .../WindowsStore/src/WindowsStoreFileSystem.cpp | 273 ++++++++++++++++++++ Platforms/WindowsStore/src/pch.cpp | 24 ++ Platforms/interface/Atomics.h | 32 +++ Platforms/interface/FileSystem.h | 45 ++++ Platforms/interface/PlatformDebug.h | 39 +++ Platforms/interface/PlatformDefinitions.h | 42 +++ Platforms/interface/PlatformMisc.h | 39 +++ .../WindowsStore/PlatformInterface.Shared.vcxitems | 26 ++ .../PlatformInterface.Shared.vcxitems.filters | 10 + 67 files changed, 4003 insertions(+) create mode 100644 Platforms/Android/build/Windows/AndroidPlatform-Debug.vgdbsettings create mode 100644 Platforms/Android/build/Windows/AndroidPlatform-Release.vgdbsettings create mode 100644 Platforms/Android/build/Windows/AndroidPlatform.vcxproj create mode 100644 Platforms/Android/build/Windows/AndroidPlatform.vcxproj.filters create mode 100644 Platforms/Android/build/Windows/jni/Android.mk create mode 100644 Platforms/Android/build/Windows/jni/Application.mk create mode 100644 Platforms/Android/include/AndroidDebug.h create mode 100644 Platforms/Android/include/AndroidFileSystem.h create mode 100644 Platforms/Android/include/AndroidPlatformDefinitions.h create mode 100644 Platforms/Android/include/AndroidPlatformMisc.h create mode 100644 Platforms/Android/src/AndroidDebug.cpp create mode 100644 Platforms/Android/src/AndroidFileSystem.cpp create mode 100644 Platforms/Basic/build/Windows/BasicPlatform-Debug.vgdbsettings create mode 100644 Platforms/Basic/build/Windows/BasicPlatform-Release.vgdbsettings create mode 100644 Platforms/Basic/build/Windows/BasicPlatform.props create mode 100644 Platforms/Basic/build/Windows/BasicPlatform.vcxproj create mode 100644 Platforms/Basic/build/Windows/BasicPlatform.vcxproj.filters create mode 100644 Platforms/Basic/build/Windows/EngineRoot.props create mode 100644 Platforms/Basic/build/Windows/jni/Android.mk create mode 100644 Platforms/Basic/build/Windows/jni/Application.mk create mode 100644 Platforms/Basic/build/WindowsStore/BasicPlatform.Shared/BasicPlatform.Shared.vcxitems create mode 100644 Platforms/Basic/build/WindowsStore/BasicPlatform.Shared/BasicPlatform.Shared.vcxitems.filters create mode 100644 Platforms/Basic/build/WindowsStore/BasicPlatform.Windows/BasicPlatform.Windows.vcxproj create mode 100644 Platforms/Basic/build/WindowsStore/BasicPlatform.Windows/BasicPlatform.Windows.vcxproj.filters create mode 100644 Platforms/Basic/build/WindowsStore/BasicPlatform.WindowsPhone/BasicPlatform.WindowsPhone.vcxproj create mode 100644 Platforms/Basic/build/WindowsStore/BasicPlatform.WindowsPhone/BasicPlatform.WindowsPhone.vcxproj.filters create mode 100644 Platforms/Basic/build/WindowsStore/EngineRoot.props create mode 100644 Platforms/Basic/include/BasicAtomics.h create mode 100644 Platforms/Basic/include/BasicFileSystem.h create mode 100644 Platforms/Basic/include/BasicPlatformDebug.h create mode 100644 Platforms/Basic/include/BasicPlatformMisc.h create mode 100644 Platforms/Basic/include/pch.h create mode 100644 Platforms/Basic/src/BasicFileSystem.cpp create mode 100644 Platforms/Basic/src/pch.cpp create mode 100644 Platforms/Windows/build/Windows/EngineRoot.props create mode 100644 Platforms/Windows/build/Windows/WindowsPlatform.props create mode 100644 Platforms/Windows/build/Windows/WindowsPlatform.vcxproj create mode 100644 Platforms/Windows/build/Windows/WindowsPlatform.vcxproj.filters create mode 100644 Platforms/Windows/include/WindowsDebug.h create mode 100644 Platforms/Windows/include/WindowsFileSystem.h create mode 100644 Platforms/Windows/include/WindowsPlatformDefinitions.h create mode 100644 Platforms/Windows/include/WindowsPlatformMisc.h create mode 100644 Platforms/Windows/include/pch.h create mode 100644 Platforms/Windows/src/WindowsDebug.cpp create mode 100644 Platforms/Windows/src/WindowsFileSystem.cpp create mode 100644 Platforms/Windows/src/pch.cpp create mode 100644 Platforms/WindowsStore/build/WindowsStore/EngineRoot.props create mode 100644 Platforms/WindowsStore/build/WindowsStore/WindowsStorePlatform.Shared/WindowsStorePlatform.Shared.vcxitems create mode 100644 Platforms/WindowsStore/build/WindowsStore/WindowsStorePlatform.Shared/WindowsStorePlatform.Shared.vcxitems.filters create mode 100644 Platforms/WindowsStore/build/WindowsStore/WindowsStorePlatform.Windows/WindowsStorePlatform.Windows.vcxproj create mode 100644 Platforms/WindowsStore/build/WindowsStore/WindowsStorePlatform.Windows/WindowsStorePlatform.Windows.vcxproj.filters create mode 100644 Platforms/WindowsStore/build/WindowsStore/WindowsStorePlatform.WindowsPhone/WindowsStorePlatform.WindowsPhone.vcxproj create mode 100644 Platforms/WindowsStore/build/WindowsStore/WindowsStorePlatform.WindowsPhone/WindowsStorePlatform.WindowsPhone.vcxproj.filters create mode 100644 Platforms/WindowsStore/include/WindowsStoreDebug.h create mode 100644 Platforms/WindowsStore/include/WindowsStoreFileSystem.h create mode 100644 Platforms/WindowsStore/include/WindowsStorePlatformDefinitions.h create mode 100644 Platforms/WindowsStore/include/pch.h create mode 100644 Platforms/WindowsStore/src/WindowsStoreDebug.cpp create mode 100644 Platforms/WindowsStore/src/WindowsStoreFileSystem.cpp create mode 100644 Platforms/WindowsStore/src/pch.cpp create mode 100644 Platforms/interface/Atomics.h create mode 100644 Platforms/interface/FileSystem.h create mode 100644 Platforms/interface/PlatformDebug.h create mode 100644 Platforms/interface/PlatformDefinitions.h create mode 100644 Platforms/interface/PlatformMisc.h create mode 100644 Platforms/interface/build/WindowsStore/PlatformInterface.Shared.vcxitems create mode 100644 Platforms/interface/build/WindowsStore/PlatformInterface.Shared.vcxitems.filters (limited to 'Platforms') diff --git a/Platforms/Android/build/Windows/AndroidPlatform-Debug.vgdbsettings b/Platforms/Android/build/Windows/AndroidPlatform-Debug.vgdbsettings new file mode 100644 index 00000000..3f5b24b1 --- /dev/null +++ b/Platforms/Android/build/Windows/AndroidPlatform-Debug.vgdbsettings @@ -0,0 +1,76 @@ + + + Debug + + + + MinGWWindowsSlash + + $(ProjectDir) + + + android-19 + true + true + bin;obj + false + false + + + + + + false + false + true + false + false + false + false + true + false + KillApp + + false + false + false + false + false + false + false + false + + false + false + main + true + + + false + false + 5039 + 5039 + 10000 + 0 + false + Ask + true + true + + + + + + + + + + + Default + + + + true + + + \ No newline at end of file diff --git a/Platforms/Android/build/Windows/AndroidPlatform-Release.vgdbsettings b/Platforms/Android/build/Windows/AndroidPlatform-Release.vgdbsettings new file mode 100644 index 00000000..669691f2 --- /dev/null +++ b/Platforms/Android/build/Windows/AndroidPlatform-Release.vgdbsettings @@ -0,0 +1,76 @@ + + + Release + + + + MinGWWindowsSlash + + $(ProjectDir) + + + android-19 + false + true + bin;obj + false + false + + + + + + false + false + true + false + false + false + false + true + false + KillApp + + false + false + false + false + false + false + false + false + + false + false + main + true + + + false + false + 5039 + 5039 + 10000 + 0 + false + Ask + true + true + + + + + + + + + + + Default + + + + true + + + \ No newline at end of file diff --git a/Platforms/Android/build/Windows/AndroidPlatform.vcxproj b/Platforms/Android/build/Windows/AndroidPlatform.vcxproj new file mode 100644 index 00000000..43e5b9b8 --- /dev/null +++ b/Platforms/Android/build/Windows/AndroidPlatform.vcxproj @@ -0,0 +1,54 @@ + + + + + Debug + ARM + + + Release + ARM + + + + {E333476E-15E3-4D43-A4CF-8748058B3BE9} + AndroidPlatform + + + + v120 + Makefile + + + v120 + Makefile + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Platforms/Android/build/Windows/AndroidPlatform.vcxproj.filters b/Platforms/Android/build/Windows/AndroidPlatform.vcxproj.filters new file mode 100644 index 00000000..e9a68010 --- /dev/null +++ b/Platforms/Android/build/Windows/AndroidPlatform.vcxproj.filters @@ -0,0 +1,46 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {5af229be-bfa0-48dc-9c77-f42bceac4839} + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + + + jni + + + jni + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/Platforms/Android/build/Windows/jni/Android.mk b/Platforms/Android/build/Windows/jni/Android.mk new file mode 100644 index 00000000..79916efd --- /dev/null +++ b/Platforms/Android/build/Windows/jni/Android.mk @@ -0,0 +1,26 @@ +# Android NDK project makefile autogenerated by Premake + +# Preamble +DEPENDENCY_PATH := $(call my-dir) +LOCAL_PATH := $(abspath $(DEPENDENCY_PATH)) +include $(CLEAR_VARS) + + +# Project configuration +LOCAL_MODULE := AndroidPlatform +LOCAL_CFLAGS := -std=c++11 +LOCAL_CPP_FEATURES := exceptions +LOCAL_STATIC_LIBRARIES += ndk_helper native_app_glue + +# Include paths +SOLUTION_ROOT := $(LOCAL_PATH)/../../../../.. +LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../include $(LOCAL_PATH)/../../../../interface $(LOCAL_PATH)/../../../../interface $(SOLUTION_ROOT)/Common/include $(SOLUTION_ROOT)/Common/interface + +# Source files +#VisualGDBAndroid: AutoUpdateSourcesInNextLine +LOCAL_SRC_FILES := ../../../src/AndroidDebug.cpp ../../../src/AndroidFileSystem.cpp + +include $(BUILD_STATIC_LIBRARY) + +$(call import-module,android/ndk_helper) +$(call import-module,android/native_app_glue) diff --git a/Platforms/Android/build/Windows/jni/Application.mk b/Platforms/Android/build/Windows/jni/Application.mk new file mode 100644 index 00000000..4715824e --- /dev/null +++ b/Platforms/Android/build/Windows/jni/Application.mk @@ -0,0 +1,7 @@ +# Generated by VisualGDB + +DEPENDENCY_PATH := $(call my-dir) +LOCAL_PATH := $(abspath $(DEPENDENCY_PATH)) +include $(LOCAL_PATH)/../../../../../Common/make/AppCommon.mk + +APP_MODULES := AndroidPlatform \ No newline at end of file diff --git a/Platforms/Android/include/AndroidDebug.h b/Platforms/Android/include/AndroidDebug.h new file mode 100644 index 00000000..f222aad0 --- /dev/null +++ b/Platforms/Android/include/AndroidDebug.h @@ -0,0 +1,32 @@ +/* Copyright 2015 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +#include "..\Basic\include\BasicPlatformDebug.h" + +struct AndroidDebug : public BasicPlatformDebug +{ + static void AssertionFailed( const Diligent::Char *Message, const char *Function, const char *File, int Line ); + static void OutputDebugMessage( DebugMessageSeverity Severity, const Diligent::Char *Message ); +}; diff --git a/Platforms/Android/include/AndroidFileSystem.h b/Platforms/Android/include/AndroidFileSystem.h new file mode 100644 index 00000000..6edb760d --- /dev/null +++ b/Platforms/Android/include/AndroidFileSystem.h @@ -0,0 +1,66 @@ +/* Copyright 2015 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +#include "..\Basic\include\BasicFileSystem.h" + +#include +#include + +class AndroidFile : public BasicFile +{ +public: + AndroidFile( const FileOpenAttribs &OpenAttribs ); + ~AndroidFile(); + + void Read( Diligent::IDataBlob *pData ); + + bool Read( void* Data, size_t BufferSize ); + + bool Write( const void *Data, size_t BufferSize ); + + size_t GetSize(); + + size_t GetPos(); + + void SetPos(size_t Offset, FilePosOrigin Origin); + +private: + //FILE *m_pFile; +}; + +struct AndroidFileSystem : public BasicFileSystem +{ +public: + static AndroidFile* OpenFile( const FileOpenAttribs &OpenAttribs ); + static inline Diligent::Char GetSlashSymbol(){ return '/'; } + + static bool FileExists( const Diligent::Char *strFilePath ); + static bool PathExists( const Diligent::Char *strPath ); + + static bool CreateDirectory( const Diligent::Char *strPath ); + static void ClearDirectory( const Diligent::Char *strPath ); + static void DeleteFile( const Diligent::Char *strPath ); + static std::vector> Search(const Diligent::Char *SearchPattern); +}; diff --git a/Platforms/Android/include/AndroidPlatformDefinitions.h b/Platforms/Android/include/AndroidPlatformDefinitions.h new file mode 100644 index 00000000..0f297c20 --- /dev/null +++ b/Platforms/Android/include/AndroidPlatformDefinitions.h @@ -0,0 +1,30 @@ +/* Copyright 2015 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +#include + +template +char (*__countof_helper(_CountofType (&_Array)[_SizeOfArray]))[_SizeOfArray]; +#define _countof(_Array) (sizeof(*__countof_helper(_Array)) + 0) diff --git a/Platforms/Android/include/AndroidPlatformMisc.h b/Platforms/Android/include/AndroidPlatformMisc.h new file mode 100644 index 00000000..69277b7b --- /dev/null +++ b/Platforms/Android/include/AndroidPlatformMisc.h @@ -0,0 +1,43 @@ +/* Copyright 2015 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +#include "..\Basic\include\BasicPlatformMisc.h" +#include "DebugUtilities.h" + +struct AndroidMisc : public BasicPlatformMisc +{ + static Diligent::Uint32 GetMSB(Diligent::Uint32 Val) + { + if( Val == 0 )return 32; + + // Returns the number of leading 0-bits in x, starting at the + // most significant bit position. If x is 0, the result is undefined. + auto LeadingZeros = __builtin_clz(Val); + auto MSB = 31 - LeadingZeros; + VERIFY_EXPR(MSB == BasicPlatformMisc::GetMSB(Val)); + + return MSB; + } +}; diff --git a/Platforms/Android/src/AndroidDebug.cpp b/Platforms/Android/src/AndroidDebug.cpp new file mode 100644 index 00000000..31fd3cde --- /dev/null +++ b/Platforms/Android/src/AndroidDebug.cpp @@ -0,0 +1,47 @@ +/* Copyright 2015 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "AndroidDebug.h" +#include "FormatMessage.h" +#include "FileSystem.h" +#include +#include + +void AndroidDebug :: AssertionFailed( const Diligent::Char *Message, const char *Function, const char *File, int Line ) +{ + std::string FileName; + FileSystem::SplitFilePath( File, nullptr, &FileName ); + std::stringstream msgss; + Diligent::FormatMsg( msgss, "\nDebug assertion failed in ", Function, "(), file ", FileName, ", line ", Line, ":\n", Message); + auto FullMsg = msgss.str(); + OutputDebugMessage( DebugMessageSeverity::Error, FullMsg.c_str() ); + + raise( SIGTRAP ); +}; + + +void AndroidDebug::OutputDebugMessage( DebugMessageSeverity Severity, const Diligent::Char *Message ) +{ + static const android_LogPriority Priorities[] = { ANDROID_LOG_INFO, ANDROID_LOG_WARN, ANDROID_LOG_ERROR, ANDROID_LOG_FATAL }; + __android_log_print( Priorities[static_cast(Severity)], "Graphics Engine", "%s", Message ); +} diff --git a/Platforms/Android/src/AndroidFileSystem.cpp b/Platforms/Android/src/AndroidFileSystem.cpp new file mode 100644 index 00000000..d6c4419b --- /dev/null +++ b/Platforms/Android/src/AndroidFileSystem.cpp @@ -0,0 +1,180 @@ +/* Copyright 2015 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "AndroidFileSystem.h" +#include "Errors.h" +#include "DebugUtilities.h" +#include + +using namespace ndk_helper; + +AndroidFile::AndroidFile( const FileOpenAttribs &OpenAttribs ) : + BasicFile(OpenAttribs, AndroidFileSystem::GetSlashSymbol())/*, + m_pFile(nullptr)*/ +{ + //auto OpenModeStr = GetOpenModeStr(); + // + //m_pFile = fopen( FileName, OpenModeStr.c_str()); + //if( m_pFile != nullptr ) + //{ + // break; + //} + //else + //{ + // std::stringstream ErrSS; + // ErrSS<< "Failed to open file" << std::endl << FileName; + // LOG_ERROR_AND_THROW(ErrSS.str().c_str()); + //} + + // Workaround: + // Try to read data from the file to make sure it exists + auto FullPath = m_OpenAttribs.strFilePath; + std::vector Data; + if( !JNIHelper::GetInstance()->ReadFile( FullPath, &Data ) ) + { + LOG_ERROR_AND_THROW( "Failed to open file ", FullPath ); + } +} + +AndroidFile::~AndroidFile() +{ + //if( m_pFile ) + //{ + // fclose( m_pFile ); + // m_pFile = nullptr; + //} +} + +void AndroidFile::Read( Diligent::IDataBlob *pData ) +{ + auto FullPath = m_OpenAttribs.strFilePath; + std::vector Data; + bool b = JNIHelper::GetInstance()->ReadFile( FullPath, &Data ); + if( b ) + { + pData->Resize( Data.size() ); + memcpy( pData->GetDataPtr(), Data.data(), Data.size() ); + } + else + { + LOG_ERROR_MESSAGE( "Unable to open file ", m_OpenAttribs.strFilePath, "\nFull path: ", FullPath ); + } +} + +size_t AndroidFile::GetSize() +{ + UNSUPPORTED( "Not implemented" ); + + return 0; +} + +bool AndroidFile::Read( void *Data, size_t BufferSize ) +{ + UNSUPPORTED( "Not implemented" ); + + //VERIFY( m_pFile, "File not opened" ); + //auto OrigPos = ftell( m_pFile ); + //fseek( m_pFile, 0, SEEK_END ); + //auto FileSize = ftell( m_pFile ); + //fseek( m_pFile, 0, SEEK_SET ); + //Data.resize( FileSize ); + //auto ItemsRead = fread( Data.data(), FileSize, 1, m_pFile ); + //fseek( m_pFile, OrigPos, SEEK_SET ); + //return ItemsRead == 1; + return false; +} + +bool AndroidFile::Write( const void *Data, size_t BufferSize ) +{ + UNSUPPORTED( "Not implemented" ); + + return false; +} + +size_t AndroidFile::GetPos() +{ + UNSUPPORTED( "Not implemented" ); + + return 0; +} + +void AndroidFile::SetPos(size_t Offset, FilePosOrigin Origin) +{ + UNSUPPORTED( "Not implemented" ); +} + + +AndroidFile* AndroidFileSystem::OpenFile( const FileOpenAttribs &OpenAttribs ) +{ + AndroidFile *pFile = nullptr; + try + { + pFile = new AndroidFile( OpenAttribs ); + } + catch( const std::runtime_error &err ) + { + + } + + return pFile; +} + + +bool AndroidFileSystem::FileExists( const Diligent::Char *strFilePath ) +{ + FileOpenAttribs OpenAttribs; + OpenAttribs.strFilePath = strFilePath; + BasicFile DummyFile( OpenAttribs, AndroidFileSystem::GetSlashSymbol() ); + const auto& Path = DummyFile.GetPath(); + std::vector Data; + bool b = JNIHelper::GetInstance()->ReadFile( Path.c_str(), &Data ); + return b; +} + +bool AndroidFileSystem::PathExists( const Diligent::Char *strPath ) +{ + UNSUPPORTED( "Not implemented" ); + return false; +} + +bool AndroidFileSystem::CreateDirectory( const Diligent::Char *strPath ) +{ + UNSUPPORTED( "Not implemented" ); + return false; +} + +void AndroidFileSystem::ClearDirectory( const Diligent::Char *strPath ) +{ + UNSUPPORTED( "Not implemented" ); +} + +void AndroidFileSystem::DeleteFile( const Diligent::Char *strPath ) +{ + UNSUPPORTED( "Not implemented" ); +} + +std::vector> AndroidFileSystem::Search(const Diligent::Char *SearchPattern) +{ + UNSUPPORTED( "Not implemented" ); + return std::vector>(); +} diff --git a/Platforms/Basic/build/Windows/BasicPlatform-Debug.vgdbsettings b/Platforms/Basic/build/Windows/BasicPlatform-Debug.vgdbsettings new file mode 100644 index 00000000..3f5b24b1 --- /dev/null +++ b/Platforms/Basic/build/Windows/BasicPlatform-Debug.vgdbsettings @@ -0,0 +1,76 @@ + + + Debug + + + + MinGWWindowsSlash + + $(ProjectDir) + + + android-19 + true + true + bin;obj + false + false + + + + + + false + false + true + false + false + false + false + true + false + KillApp + + false + false + false + false + false + false + false + false + + false + false + main + true + + + false + false + 5039 + 5039 + 10000 + 0 + false + Ask + true + true + + + + + + + + + + + Default + + + + true + + + \ No newline at end of file diff --git a/Platforms/Basic/build/Windows/BasicPlatform-Release.vgdbsettings b/Platforms/Basic/build/Windows/BasicPlatform-Release.vgdbsettings new file mode 100644 index 00000000..669691f2 --- /dev/null +++ b/Platforms/Basic/build/Windows/BasicPlatform-Release.vgdbsettings @@ -0,0 +1,76 @@ + + + Release + + + + MinGWWindowsSlash + + $(ProjectDir) + + + android-19 + false + true + bin;obj + false + false + + + + + + false + false + true + false + false + false + false + true + false + KillApp + + false + false + false + false + false + false + false + false + + false + false + main + true + + + false + false + 5039 + 5039 + 10000 + 0 + false + Ask + true + true + + + + + + + + + + + Default + + + + true + + + \ No newline at end of file diff --git a/Platforms/Basic/build/Windows/BasicPlatform.props b/Platforms/Basic/build/Windows/BasicPlatform.props new file mode 100644 index 00000000..a8cf5f7f --- /dev/null +++ b/Platforms/Basic/build/Windows/BasicPlatform.props @@ -0,0 +1,10 @@ + + + + + + $(EngineRoot)\Platforms\Basic\include;$(EngineRoot)\Platforms\interface;$(EngineRoot)\Common\interface;$(EngineRoot)\Common\include;$(VC_IncludePath);$(WindowsSDK_IncludePath) + + + + \ No newline at end of file diff --git a/Platforms/Basic/build/Windows/BasicPlatform.vcxproj b/Platforms/Basic/build/Windows/BasicPlatform.vcxproj new file mode 100644 index 00000000..034f6fa0 --- /dev/null +++ b/Platforms/Basic/build/Windows/BasicPlatform.vcxproj @@ -0,0 +1,173 @@ + + + + + Debug + ARM + + + Debug + Win32 + + + Debug + x64 + + + Release + ARM + + + Release + Win32 + + + Release + x64 + + + + {8ADA5F93-7A38-4AD8-B8F5-1FFD4D4F630C} + PlatformCommon + + + + StaticLibrary + true + v140 + MultiByte + + + StaticLibrary + true + v140 + MultiByte + + + StaticLibrary + false + v140 + true + MultiByte + + + StaticLibrary + false + v140 + true + MultiByte + + + v120 + Makefile + + + v120 + Makefile + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Level3 + Disabled + true + + + true + + + + + Level3 + Disabled + true + + + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + true + + + + + Level3 + MaxSpeed + true + true + true + + + true + true + true + + + + + + + + + true + true + true + true + + + + + + \ No newline at end of file diff --git a/Platforms/Basic/build/Windows/BasicPlatform.vcxproj.filters b/Platforms/Basic/build/Windows/BasicPlatform.vcxproj.filters new file mode 100644 index 00000000..bce03812 --- /dev/null +++ b/Platforms/Basic/build/Windows/BasicPlatform.vcxproj.filters @@ -0,0 +1,24 @@ + + + + + {fbef7424-2a7d-4879-b301-6b7e61c3571d} + + + {fcd7c682-f6f2-45ed-9bd8-dabd9bf9db06} + + + + + jni + + + jni + + + + + android_src + + + \ No newline at end of file diff --git a/Platforms/Basic/build/Windows/EngineRoot.props b/Platforms/Basic/build/Windows/EngineRoot.props new file mode 100644 index 00000000..c2337431 --- /dev/null +++ b/Platforms/Basic/build/Windows/EngineRoot.props @@ -0,0 +1,14 @@ + + + + + ..\..\..\.. + + + + + + $(EngineRoot) + + + \ No newline at end of file diff --git a/Platforms/Basic/build/Windows/jni/Android.mk b/Platforms/Basic/build/Windows/jni/Android.mk new file mode 100644 index 00000000..2eb21c09 --- /dev/null +++ b/Platforms/Basic/build/Windows/jni/Android.mk @@ -0,0 +1,26 @@ +# Android NDK project makefile autogenerated by Premake + +# Preamble +DEPENDENCY_PATH := $(call my-dir) +LOCAL_PATH := $(abspath $(DEPENDENCY_PATH)) +include $(CLEAR_VARS) + + +# Project configuration +LOCAL_MODULE := BasicPlatform +LOCAL_CFLAGS := -std=c++11 +LOCAL_CPP_FEATURES := exceptions +LOCAL_STATIC_LIBRARIES += ndk_helper native_app_glue + +# Include paths +SOLUTION_ROOT := $(LOCAL_PATH)/../../../../.. +LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../include $(LOCAL_PATH)/../../../../interface $(SOLUTION_ROOT)/Common/include $(SOLUTION_ROOT)/Common/interface + +# Source files +#VisualGDBAndroid: AutoUpdateSourcesInNextLine +LOCAL_SRC_FILES := ../../../src/BasicFileSystem.cpp + +include $(BUILD_STATIC_LIBRARY) + +$(call import-module,android/ndk_helper) +$(call import-module,android/native_app_glue) diff --git a/Platforms/Basic/build/Windows/jni/Application.mk b/Platforms/Basic/build/Windows/jni/Application.mk new file mode 100644 index 00000000..6e6b4a7e --- /dev/null +++ b/Platforms/Basic/build/Windows/jni/Application.mk @@ -0,0 +1,7 @@ +# Generated by VisualGDB + +DEPENDENCY_PATH := $(call my-dir) +LOCAL_PATH := $(abspath $(DEPENDENCY_PATH)) +include $(LOCAL_PATH)/../../../../../Common/make/AppCommon.mk + +APP_MODULES := BasicPlatform \ No newline at end of file diff --git a/Platforms/Basic/build/WindowsStore/BasicPlatform.Shared/BasicPlatform.Shared.vcxitems b/Platforms/Basic/build/WindowsStore/BasicPlatform.Shared/BasicPlatform.Shared.vcxitems new file mode 100644 index 00000000..195ea80f --- /dev/null +++ b/Platforms/Basic/build/WindowsStore/BasicPlatform.Shared/BasicPlatform.Shared.vcxitems @@ -0,0 +1,32 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + {c50f6528-6a12-49a9-bec0-e07cf153fca8} + BasicPlatform + BasicPlatform.Shared + 248F659F-DAC5-46E8-AC09-60EC9FC95053 + + + + %(AdditionalIncludeDirectories);$(MSBuildThisFileDirectory) + + + + + + + + + Create + + + + + + + + + + \ No newline at end of file diff --git a/Platforms/Basic/build/WindowsStore/BasicPlatform.Shared/BasicPlatform.Shared.vcxitems.filters b/Platforms/Basic/build/WindowsStore/BasicPlatform.Shared/BasicPlatform.Shared.vcxitems.filters new file mode 100644 index 00000000..38335184 --- /dev/null +++ b/Platforms/Basic/build/WindowsStore/BasicPlatform.Shared/BasicPlatform.Shared.vcxitems.filters @@ -0,0 +1,36 @@ + + + + + {6cd2ad8c-c15c-4156-aa37-d00759bc0611} + + + {b0ccce69-d437-4e82-ae8e-a33f1581f7ed} + + + + + src + + + src + + + + + include + + + include + + + include + + + include + + + include + + + \ No newline at end of file diff --git a/Platforms/Basic/build/WindowsStore/BasicPlatform.Windows/BasicPlatform.Windows.vcxproj b/Platforms/Basic/build/WindowsStore/BasicPlatform.Windows/BasicPlatform.Windows.vcxproj new file mode 100644 index 00000000..a1afa627 --- /dev/null +++ b/Platforms/Basic/build/WindowsStore/BasicPlatform.Windows/BasicPlatform.Windows.vcxproj @@ -0,0 +1,207 @@ + + + + + Debug + ARM + + + Debug + Win32 + + + Debug + x64 + + + Release + ARM + + + Release + Win32 + + + Release + x64 + + + + {3f28c683-66ad-42ca-a264-b18d0743f518} + BasicPlatform + en-US + 12.0 + true + Windows Store + 8.1 + CodeSharingStaticLibrary + + + + StaticLibrary + true + v120 + + + StaticLibrary + true + v120 + + + StaticLibrary + true + v120 + + + StaticLibrary + false + true + v120 + + + StaticLibrary + false + true + v120 + + + StaticLibrary + false + true + v120 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + false + + + false + + + false + + + false + + + false + + + false + + + + Use + false + true + + + Console + false + false + + + + + Use + false + true + + + Console + false + false + + + + + Use + false + true + + + Console + false + false + + + + + Use + false + true + + + Console + false + false + + + + + Use + false + true + + + Console + false + false + + + + + Use + false + true + + + Console + false + false + + + + + + \ No newline at end of file diff --git a/Platforms/Basic/build/WindowsStore/BasicPlatform.Windows/BasicPlatform.Windows.vcxproj.filters b/Platforms/Basic/build/WindowsStore/BasicPlatform.Windows/BasicPlatform.Windows.vcxproj.filters new file mode 100644 index 00000000..a7761ab0 --- /dev/null +++ b/Platforms/Basic/build/WindowsStore/BasicPlatform.Windows/BasicPlatform.Windows.vcxproj.filters @@ -0,0 +1,5 @@ + + + + + diff --git a/Platforms/Basic/build/WindowsStore/BasicPlatform.WindowsPhone/BasicPlatform.WindowsPhone.vcxproj b/Platforms/Basic/build/WindowsStore/BasicPlatform.WindowsPhone/BasicPlatform.WindowsPhone.vcxproj new file mode 100644 index 00000000..083b6ab1 --- /dev/null +++ b/Platforms/Basic/build/WindowsStore/BasicPlatform.WindowsPhone/BasicPlatform.WindowsPhone.vcxproj @@ -0,0 +1,146 @@ + + + + + Debug + ARM + + + Debug + Win32 + + + Release + ARM + + + Release + Win32 + + + + {6b4cf863-1024-45e2-ba7e-263de516468b} + BasicPlatform + en-US + 12.0 + true + Windows Phone + 8.1 + CodeSharingStaticLibrary + + + + StaticLibrary + true + v120_wp81 + + + StaticLibrary + true + v120_wp81 + + + StaticLibrary + false + true + v120_wp81 + + + StaticLibrary + false + true + v120_wp81 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + false + + + false + + + false + + + false + + + + Use + false + true + + + Console + false + false + + + + + Use + false + true + + + Console + false + false + + + + + Use + false + true + + + Console + false + false + + + + + Use + false + true + + + Console + false + false + + + + + + \ No newline at end of file diff --git a/Platforms/Basic/build/WindowsStore/BasicPlatform.WindowsPhone/BasicPlatform.WindowsPhone.vcxproj.filters b/Platforms/Basic/build/WindowsStore/BasicPlatform.WindowsPhone/BasicPlatform.WindowsPhone.vcxproj.filters new file mode 100644 index 00000000..a7761ab0 --- /dev/null +++ b/Platforms/Basic/build/WindowsStore/BasicPlatform.WindowsPhone/BasicPlatform.WindowsPhone.vcxproj.filters @@ -0,0 +1,5 @@ + + + + + diff --git a/Platforms/Basic/build/WindowsStore/EngineRoot.props b/Platforms/Basic/build/WindowsStore/EngineRoot.props new file mode 100644 index 00000000..7020603b --- /dev/null +++ b/Platforms/Basic/build/WindowsStore/EngineRoot.props @@ -0,0 +1,14 @@ + + + + + ..\..\..\..\.. + + + + + + $(EngineRoot) + + + \ No newline at end of file diff --git a/Platforms/Basic/include/BasicAtomics.h b/Platforms/Basic/include/BasicAtomics.h new file mode 100644 index 00000000..492851a5 --- /dev/null +++ b/Platforms/Basic/include/BasicAtomics.h @@ -0,0 +1,65 @@ +/* Copyright 2015 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +#include + +struct BasicAtomics +{ + typedef long Long; + typedef std::atomic AtomicLong; + typedef std::atomic AtomicInt64; + + // The function returns the resulting INCREMENTED value. + template + static inline Type AtomicIncrement(std::atomic &Val) + { + return ++Val; + } + + // The function returns the resulting DECREMENTED value. + template + static inline Type AtomicDecrement(std::atomic &Val) + { + return --Val; + } + + // The function compares the Destination value with the Comparand value. If the Destination value is equal + // to the Comparand value, the Exchange value is stored in the address specified by Destination. + // Otherwise, no operation is performed. + // The function returns the initial value of the Destination parameter + template + static inline Type AtomicCompareExchange( std::atomic &Destination, Type Exchange, Type Comparand) + { + Destination.compare_exchange_strong(Comparand, Exchange); + return Comparand; + } + + template + static inline Type AtomicAdd( std::atomic &Destination, Type Val) + { + return std::atomic_fetch_add(&Destination, Val); + } + +}; diff --git a/Platforms/Basic/include/BasicFileSystem.h b/Platforms/Basic/include/BasicFileSystem.h new file mode 100644 index 00000000..8d083aea --- /dev/null +++ b/Platforms/Basic/include/BasicFileSystem.h @@ -0,0 +1,103 @@ +/* Copyright 2015 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +#include +#include "BasicTypes.h" +#include "DataBlob.h" + +enum class EFileAccessMode +{ + Read, + Overwrite, + Append +}; + +enum class FilePosOrigin +{ + Start, + Curr, + End +}; + + +struct FileOpenAttribs +{ + const Diligent::Char *strFilePath; + EFileAccessMode AccessMode; + FileOpenAttribs(const Diligent::Char *Path = nullptr, + EFileAccessMode Access = EFileAccessMode::Read) : + strFilePath( Path ), + AccessMode( Access ) + {} +}; + +class BasicFile +{ +public: + BasicFile( const FileOpenAttribs &OpenAttribs, Diligent::Char SlashSymbol ); + virtual ~BasicFile(); + + size_t GetSize(); + + const Diligent::String& GetPath(){ return m_Path; } + +protected: + Diligent::String GetOpenModeStr(); + + FileOpenAttribs m_OpenAttribs; + Diligent::String m_Path; +}; + +struct FindFileData +{ + virtual const Diligent::Char* Name()const = 0; + virtual bool IsDirectory()const = 0; + + virtual ~FindFileData(){} +}; + +struct BasicFileSystem +{ +public: + static BasicFile* OpenFile( FileOpenAttribs &OpenAttribs ); + static void ReleaseFile( BasicFile* ); + + static std::string GetFullPath( const Diligent::Char *strFilePath ); + + static bool FileExists( const Diligent::Char *strFilePath ); + + static void SetWorkingDirectory( const Diligent::Char *strWorkingDir ){ m_strWorkingDirectory = strWorkingDir; } + static const Diligent::String &GetWorkingDirectory(){ return m_strWorkingDirectory; } + + static Diligent::Char GetSlashSymbol(); + static void CorrectSlashes(Diligent::String &Path, Diligent::Char SlashSymbol); + + static void SplitFilePath(const Diligent::String& FullName, + Diligent::String *Path, + Diligent::String *Name); + +protected: + static Diligent::String m_strWorkingDirectory; +}; diff --git a/Platforms/Basic/include/BasicPlatformDebug.h b/Platforms/Basic/include/BasicPlatformDebug.h new file mode 100644 index 00000000..e08433f8 --- /dev/null +++ b/Platforms/Basic/include/BasicPlatformDebug.h @@ -0,0 +1,40 @@ +/* Copyright 2015 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +#include "BasicTypes.h" + +struct BasicPlatformDebug +{ + enum class DebugMessageSeverity + { + Info, + Warning, + Error, + FatalError + }; + + static void AssertionFailed( const Diligent::Char* /*Message*/, const char* /*Function*/, const char* /*File*/, int /*Line*/ ){} + static void OutputDebugMessage( DebugMessageSeverity /*Severity*/, const Diligent::Char* /*Message */){} +}; diff --git a/Platforms/Basic/include/BasicPlatformMisc.h b/Platforms/Basic/include/BasicPlatformMisc.h new file mode 100644 index 00000000..39c0b105 --- /dev/null +++ b/Platforms/Basic/include/BasicPlatformMisc.h @@ -0,0 +1,40 @@ +/* Copyright 2015 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +#include "BasicTypes.h" + +struct BasicPlatformMisc +{ + static Diligent::Uint32 GetMSB(Diligent::Uint32 Val) + { + if( Val == 0 )return 32; + + Diligent::Uint32 MSB = 31; + while( !(Val & (1 << MSB)) ) + --MSB; + + return MSB; + } +}; diff --git a/Platforms/Basic/include/pch.h b/Platforms/Basic/include/pch.h new file mode 100644 index 00000000..53b5f663 --- /dev/null +++ b/Platforms/Basic/include/pch.h @@ -0,0 +1,27 @@ +/* Copyright 2015 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +#include "BasicAtomics.h" +#include "BasicFileSystem.h" \ No newline at end of file diff --git a/Platforms/Basic/src/BasicFileSystem.cpp b/Platforms/Basic/src/BasicFileSystem.cpp new file mode 100644 index 00000000..4bc5536b --- /dev/null +++ b/Platforms/Basic/src/BasicFileSystem.cpp @@ -0,0 +1,124 @@ +/* Copyright 2015 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "pch.h" +#include "BasicFileSystem.h" +#include "DebugUtilities.h" +#include + +Diligent::String BasicFileSystem::m_strWorkingDirectory; + +BasicFile::BasicFile( const FileOpenAttribs &OpenAttribs, Diligent::Char SlashSymbol ) : + m_OpenAttribs(OpenAttribs), + m_Path( BasicFileSystem::GetFullPath(OpenAttribs.strFilePath) ) +{ + BasicFileSystem::CorrectSlashes(m_Path, SlashSymbol); + + m_OpenAttribs.strFilePath = m_Path.c_str(); +} + +BasicFile::~BasicFile() +{ +} + +Diligent::String BasicFile::GetOpenModeStr() +{ + std::string OpenModeStr; + switch(m_OpenAttribs.AccessMode) + { + case EFileAccessMode::Read: OpenModeStr += 'r'; break; + case EFileAccessMode::Overwrite: OpenModeStr += 'w'; break; + case EFileAccessMode::Append: OpenModeStr += 'a'; break; + default: break; + } + + // Always open file in binary mode. Text mode is platform-specific + OpenModeStr += 'b'; + + return OpenModeStr; +} + + +std::string BasicFileSystem::GetFullPath( const Diligent::Char *strFilePath ) +{ + std::string FullPath = m_strWorkingDirectory; + auto len = FullPath.length(); + if( len>0 && FullPath[len - 1] != '\\' ) + { + FullPath += '\\'; + } + FullPath += strFilePath; + return FullPath; +} + +BasicFile* BasicFileSystem::OpenFile( FileOpenAttribs &OpenAttribs ) +{ + return nullptr; +} + +void BasicFileSystem::ReleaseFile( BasicFile * pFile) +{ + if( pFile ) + delete pFile; +} + +bool BasicFileSystem::FileExists( const Diligent::Char *strFilePath ) +{ + return false; +} + +Diligent::Char BasicFileSystem::GetSlashSymbol() +{ + UNSUPPORTED( "Unsupported" ); + return 0; +} + +void BasicFileSystem::CorrectSlashes( Diligent::String &Path, Diligent::Char SlashSymbol ) +{ + VERIFY( SlashSymbol == '\\' || SlashSymbol == '/', + "Incorrect slash symbol" ); + Diligent::Char RevSlashSym = (SlashSymbol == '\\') ? '/' : '\\'; + std::replace( Path.begin(), Path.end(), RevSlashSym, SlashSymbol); +} + +void BasicFileSystem::SplitFilePath(const Diligent::String& FullName, + Diligent::String *Path, + Diligent::String *Name) +{ + auto LastSlashPos = FullName.find_last_of( "/\\" ); + if( Path ) + { + if( LastSlashPos != Diligent::String::npos ) + *Path = FullName.substr( 0, LastSlashPos ); + else + *Path = ""; + } + + if( Name ) + { + if( LastSlashPos != Diligent::String::npos ) + *Name = FullName.substr( LastSlashPos+1 ); + else + *Path = FullName; + } +} diff --git a/Platforms/Basic/src/pch.cpp b/Platforms/Basic/src/pch.cpp new file mode 100644 index 00000000..809315e1 --- /dev/null +++ b/Platforms/Basic/src/pch.cpp @@ -0,0 +1,24 @@ +/* Copyright 2015 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "pch.h" diff --git a/Platforms/Windows/build/Windows/EngineRoot.props b/Platforms/Windows/build/Windows/EngineRoot.props new file mode 100644 index 00000000..c2337431 --- /dev/null +++ b/Platforms/Windows/build/Windows/EngineRoot.props @@ -0,0 +1,14 @@ + + + + + ..\..\..\.. + + + + + + $(EngineRoot) + + + \ No newline at end of file diff --git a/Platforms/Windows/build/Windows/WindowsPlatform.props b/Platforms/Windows/build/Windows/WindowsPlatform.props new file mode 100644 index 00000000..2287b6b6 --- /dev/null +++ b/Platforms/Windows/build/Windows/WindowsPlatform.props @@ -0,0 +1,10 @@ + + + + + + $(EngineRoot)\Platforms\interface;$(EngineRoot)\Common\interface;$(EngineRoot)\Common\include;$(VC_IncludePath);$(WindowsSDK_IncludePath) + + + + \ No newline at end of file diff --git a/Platforms/Windows/build/Windows/WindowsPlatform.vcxproj b/Platforms/Windows/build/Windows/WindowsPlatform.vcxproj new file mode 100644 index 00000000..16cf586b --- /dev/null +++ b/Platforms/Windows/build/Windows/WindowsPlatform.vcxproj @@ -0,0 +1,164 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + + + + + Create + Create + Create + Create + + + + + + {58F32677-436B-412A-BBF8-2B1310D82CD8} + WindowsPlatform + + + + StaticLibrary + true + v140 + MultiByte + + + StaticLibrary + true + v140 + MultiByte + + + StaticLibrary + false + v140 + true + MultiByte + + + StaticLibrary + false + v140 + true + MultiByte + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $(EngineRoot)\Platforms\Windows\include;$(IncludePath) + + + $(EngineRoot)\Platforms\Windows\include;$(IncludePath) + + + $(EngineRoot)\Platforms\Windows\include;$(IncludePath) + + + $(EngineRoot)\Platforms\Windows\include;$(IncludePath) + + + + Level3 + Disabled + true + WIN32;%(PreprocessorDefinitions) + + + true + + + + + Level3 + Disabled + true + WIN32;%(PreprocessorDefinitions) + + + true + + + + + Level3 + MaxSpeed + true + true + true + WIN32;%(PreprocessorDefinitions) + + + true + true + true + + + + + Level3 + MaxSpeed + true + true + true + WIN32;%(PreprocessorDefinitions) + + + true + true + true + + + + + + \ No newline at end of file diff --git a/Platforms/Windows/build/Windows/WindowsPlatform.vcxproj.filters b/Platforms/Windows/build/Windows/WindowsPlatform.vcxproj.filters new file mode 100644 index 00000000..0ff7b20a --- /dev/null +++ b/Platforms/Windows/build/Windows/WindowsPlatform.vcxproj.filters @@ -0,0 +1,41 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/Platforms/Windows/include/WindowsDebug.h b/Platforms/Windows/include/WindowsDebug.h new file mode 100644 index 00000000..d29a4d5b --- /dev/null +++ b/Platforms/Windows/include/WindowsDebug.h @@ -0,0 +1,32 @@ +/* Copyright 2015 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +#include "..\Basic\include\BasicPlatformDebug.h" + +struct WindowsDebug : public BasicPlatformDebug +{ + static void AssertionFailed( const Diligent::Char *Message, const char *Function, const char *File, int Line ); + static void OutputDebugMessage( DebugMessageSeverity Severity, const Diligent::Char *Message ); +}; diff --git a/Platforms/Windows/include/WindowsFileSystem.h b/Platforms/Windows/include/WindowsFileSystem.h new file mode 100644 index 00000000..3dd4c00d --- /dev/null +++ b/Platforms/Windows/include/WindowsFileSystem.h @@ -0,0 +1,65 @@ +/* Copyright 2015 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +#include "..\Basic\include\BasicFileSystem.h" +#include + +class WindowsFile : public BasicFile +{ +public: + WindowsFile( const FileOpenAttribs &OpenAttribs ); + ~WindowsFile(); + + void Read( Diligent::IDataBlob *pData ); + + bool Read( void *Data, size_t BufferSize ); + + bool Write( const void *Data, size_t BufferSize ); + + size_t GetSize(); + + size_t GetPos(); + + void SetPos(size_t Offset, FilePosOrigin Origin); + +private: + FILE *m_pFile; +}; + + +struct WindowsFileSystem : public BasicFileSystem +{ +public: + static WindowsFile* OpenFile( const FileOpenAttribs &OpenAttribs ); + static inline Diligent::Char GetSlashSymbol(){ return '\\'; } + + static bool FileExists( const Diligent::Char *strFilePath ); + static bool PathExists( const Diligent::Char *strPath ); + + static bool CreateDirectory( const Diligent::Char *strPath ); + static void ClearDirectory( const Diligent::Char *strPath ); + static void DeleteFile( const Diligent::Char *strPath ); + static std::vector> Search(const Diligent::Char *SearchPattern); +}; diff --git a/Platforms/Windows/include/WindowsPlatformDefinitions.h b/Platforms/Windows/include/WindowsPlatformDefinitions.h new file mode 100644 index 00000000..7f6a56e3 --- /dev/null +++ b/Platforms/Windows/include/WindowsPlatformDefinitions.h @@ -0,0 +1,25 @@ +/* Copyright 2015 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + diff --git a/Platforms/Windows/include/WindowsPlatformMisc.h b/Platforms/Windows/include/WindowsPlatformMisc.h new file mode 100644 index 00000000..1da47345 --- /dev/null +++ b/Platforms/Windows/include/WindowsPlatformMisc.h @@ -0,0 +1,43 @@ +/* Copyright 2015 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +#include "..\Basic\include\BasicPlatformMisc.h" +#include "DebugUtilities.h" + +#include + +struct WindowsMisc : public BasicPlatformMisc +{ + static Diligent::Uint32 GetMSB(Diligent::Uint32 Val) + { + if( Val == 0 )return 32; + + unsigned long MSB = 32; + _BitScanReverse(&MSB, Val); + VERIFY_EXPR(MSB == BasicPlatformMisc::GetMSB(Val)); + + return MSB; + } +}; diff --git a/Platforms/Windows/include/pch.h b/Platforms/Windows/include/pch.h new file mode 100644 index 00000000..3234e05f --- /dev/null +++ b/Platforms/Windows/include/pch.h @@ -0,0 +1,29 @@ +/* Copyright 2015 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +// Do not include here as this will +// mess up names in file system implementation! +#include "PlatformDefinitions.h" +#include "DebugUtilities.h" diff --git a/Platforms/Windows/src/WindowsDebug.cpp b/Platforms/Windows/src/WindowsDebug.cpp new file mode 100644 index 00000000..61ccb18a --- /dev/null +++ b/Platforms/Windows/src/WindowsDebug.cpp @@ -0,0 +1,88 @@ +/* Copyright 2015 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "pch.h" + +#include "WindowsDebug.h" +#include "FormatMessage.h" +#include "FileSystem.h" +#include +#include +#include + +using namespace Diligent; + +void WindowsDebug :: AssertionFailed( const Diligent::Char *Message, const char *Function, const char *File, int Line ) +{ + std::string FileName; + FileSystem::SplitFilePath( File, nullptr, &FileName ); + std::stringstream msgss; + Diligent::FormatMsg( msgss, "Debug assertion failed in ", Function, "(), file ", FileName, ", line ", Line, ":\n"); + auto Msg = msgss.str(); + String DebugOutput = Msg + Message; + OutputDebugMessage( DebugMessageSeverity::Error, DebugOutput.c_str()); + + String MBText = Msg + "\n" + Message; + int nCode = MessageBoxA(NULL, + MBText.c_str(), + "Runtime assertion failed", + MB_TASKMODAL|MB_ICONHAND|MB_ABORTRETRYIGNORE|MB_SETFOREGROUND); + + // Abort: abort the program + if (nCode == IDABORT) + { + // raise abort signal + raise(SIGABRT); + + // We usually won't get here, but it's possible that + // SIGABRT was ignored. So exit the program anyway. + exit(3); + } + + // Retry: call the debugger + if (nCode == IDRETRY) + { + DebugBreak(); + // return to user code + return; + } + + // Ignore: continue execution + if (nCode == IDIGNORE) + return; +}; + +void WindowsDebug::OutputDebugMessage( DebugMessageSeverity Severity, const Diligent::Char *Message ) +{ + static Char* strSeverities[] = { "Info: ", "Warning: ", "ERROR: ", "CRITICAL ERROR: " }; + auto* MessageSevery = strSeverities[ static_cast(Severity) ]; + String str = MessageSevery; + str += Message; + str += '\n'; + OutputDebugStringA( str.c_str() ); + + if( Severity == DebugMessageSeverity::Error || Severity == DebugMessageSeverity::FatalError ) + std::cerr< because Diligent::INTERFACE_ID will confilct with windows InterfaceID +//using namespace Diligent; + +// Windows.h defines CreateDirectory and DeleteFile as macros. +// So we need to do some tricks to avoid name mess. +bool CreateDirectoryImpl( const Diligent::Char *strPath ); +bool WindowsFileSystem::CreateDirectory( const Diligent::Char *strPath ) +{ + return CreateDirectoryImpl(strPath); +} + +void DeleteFileImpl( const Diligent::Char *strPath ); +void WindowsFileSystem::DeleteFile( const Diligent::Char *strPath ) +{ + DeleteFileImpl(strPath); +} + +#include +#include "Shlwapi.h" +#pragma comment(lib, "Shlwapi.lib") + +using namespace Diligent; + +WindowsFile::WindowsFile( const FileOpenAttribs &OpenAttribs ) : + BasicFile(OpenAttribs, WindowsFileSystem::GetSlashSymbol()), + m_pFile(nullptr) +{ + auto OpenModeStr = GetOpenModeStr(); + + for( ;; ) + { + errno_t err = fopen_s( &m_pFile, m_OpenAttribs.strFilePath, OpenModeStr.c_str() ); + if( err == 0 ) + { + break; + } + else if( err == ENFILE || // Too many files open in system + err == EMFILE ) // Too many open files + { + // No more file descriptors are available: we have to wait + //g_SystemMetricsStream << "Failed to open file " << FileName; + //g_SystemMetricsStream << "\nWaiting 50 ms...\n"; + Sleep(50); + continue; + } + else + { + char errstr[128]; + strerror_s( errstr, _countof( errstr ), err ); + LOG_ERROR_AND_THROW( "Failed to open file ", m_OpenAttribs.strFilePath, + "\nThe following error occured: ", errstr ); + } + } +} + +WindowsFile::~WindowsFile() +{ + if( m_pFile ) + { + fclose( m_pFile ); + m_pFile = nullptr; + } +} + +void WindowsFile::Read( Diligent::IDataBlob *pData ) +{ + auto FileSize = GetSize(); + pData->Resize(FileSize); + auto Res = Read( pData->GetDataPtr(), pData->GetSize() ); + VERIFY( Res, "Failed to read ", FileSize, " bytes from file" ); +} + +bool WindowsFile::Read( void *Data, size_t BufferSize ) +{ + VERIFY( m_pFile, "File is not opened" ); + if( !m_pFile ) + return 0; + auto BytesRead = fread( Data, 1, BufferSize, m_pFile ); + + return BytesRead == BufferSize; +} + +bool WindowsFile::Write( const void *Data, size_t BufferSize ) +{ + VERIFY( m_pFile, "File is not opened" ); + if( !m_pFile ) + return 0; + auto BytesWritten = fwrite( Data, 1, BufferSize, m_pFile ); + + return BytesWritten == BufferSize; +} + +size_t WindowsFile::GetSize() +{ + auto OrigPos = ftell( m_pFile ); + fseek( m_pFile, 0, SEEK_END ); + auto FileSize = ftell( m_pFile ); + + fseek( m_pFile, OrigPos, SEEK_SET ); + return FileSize; +} + +size_t WindowsFile::GetPos() +{ + VERIFY( m_pFile, "File is not opened" ); + if( !m_pFile ) + return 0; + + return ftell(m_pFile); +} + +void WindowsFile::SetPos(size_t Offset, FilePosOrigin Origin) +{ + VERIFY( m_pFile, "File is not opened" ); + if( !m_pFile ) + return; + + int orig = SEEK_SET; + switch( Origin ) + { + case FilePosOrigin::Start: orig = SEEK_SET; break; + case FilePosOrigin::Curr: orig = SEEK_CUR; break; + case FilePosOrigin::End: orig = SEEK_END; break; + default: UNEXPECTED("Unknown origin"); + } + + fseek(m_pFile, static_cast(Offset), orig); +} + +WindowsFile* WindowsFileSystem::OpenFile( const FileOpenAttribs &OpenAttribs ) +{ + WindowsFile *pFile = nullptr; + try + { + pFile = new WindowsFile( OpenAttribs ); + } + catch( const std::runtime_error &/*err*/ ) + { + + } + + return pFile; +} + +bool WindowsFileSystem::FileExists( const Char *strFilePath ) +{ + FileOpenAttribs OpenAttribs; + OpenAttribs.strFilePath = strFilePath; + BasicFile DummyFile( OpenAttribs, WindowsFileSystem::GetSlashSymbol() ); + const auto& Path = DummyFile.GetPath(); + FILE *pFile = nullptr; + auto err = fopen_s( &pFile, Path.c_str(), "r" ); + bool Exists = (err == 0); + if( Exists && pFile ) + fclose( pFile ); + return Exists; +} + +bool CreateDirectoryImpl( const Char *strPath ) +{ + // Test all parent directories + std::string DirectoryPath = strPath; + std::string::size_type SlashPos = std::wstring::npos; + do + { + SlashPos = DirectoryPath.find( '\\', (SlashPos != std::string::npos) ? SlashPos+1 : 0); + std::string ParentDir = (SlashPos != std::wstring::npos) ? DirectoryPath.substr(0, SlashPos) : DirectoryPath; + if( !WindowsFileSystem::PathExists(ParentDir.c_str()) ) + { + // If there is no directory, create it + if( !::CreateDirectoryA(ParentDir.c_str(), NULL) ) + return false; + } + } + while( SlashPos != std::string::npos ); + + return true; +} + +void WindowsFileSystem::ClearDirectory( const Char *strPath ) +{ + WIN32_FIND_DATA ffd; + HANDLE hFind = INVALID_HANDLE_VALUE; + + // Find the first file in the directory. + std::string Directory ( strPath ); + if( Directory.length() > 0 && Directory.back() != GetSlashSymbol() ) + Directory.push_back( GetSlashSymbol() ); + + auto SearchPattern = Directory + "*"; + hFind = FindFirstFileA( SearchPattern.c_str(), &ffd); + + if (INVALID_HANDLE_VALUE == hFind) + { + LOG_ERROR_AND_THROW("FindFirstFile"); + } + + // List all the files in the directory + do + { + if( !(ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ) + { + auto FileName = Directory + ffd.cFileName; + DeleteFileImpl( FileName.c_str() ); + } + } + while( FindNextFile(hFind, &ffd) != 0 ); +} + + +void DeleteFileImpl( const Char *strPath ) +{ + DeleteFileA(strPath); +} + +bool WindowsFileSystem::PathExists( const Char *strPath ) +{ + return PathFileExistsA(strPath) != FALSE; +} + +struct WndFindFileData : public FindFileData +{ + virtual const Char* Name()const override{return ffd.cFileName;} + virtual bool IsDirectory()const override{return (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;} + + WIN32_FIND_DATA ffd; + + WndFindFileData(const WIN32_FIND_DATA& _ffd) : ffd(_ffd){} +}; + +std::vector> WindowsFileSystem::Search(const Char *SearchPattern) +{ + std::vector> SearchRes; + + WIN32_FIND_DATA ffd; + // Find the first file in the directory. + auto hFind = FindFirstFileA( SearchPattern, &ffd); + + if (INVALID_HANDLE_VALUE == hFind) + { + return SearchRes; + } + + // List all the files in the directory + do + { + SearchRes.emplace_back( new WndFindFileData(ffd) ); + } + while( FindNextFile(hFind, &ffd) != 0 ); + + auto dwError = GetLastError(); + if (dwError != ERROR_NO_MORE_FILES) + { + //ErrorHandler(TEXT("FindFirstFile")); + } + + FindClose(hFind); + + return SearchRes; +} diff --git a/Platforms/Windows/src/pch.cpp b/Platforms/Windows/src/pch.cpp new file mode 100644 index 00000000..809315e1 --- /dev/null +++ b/Platforms/Windows/src/pch.cpp @@ -0,0 +1,24 @@ +/* Copyright 2015 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "pch.h" diff --git a/Platforms/WindowsStore/build/WindowsStore/EngineRoot.props b/Platforms/WindowsStore/build/WindowsStore/EngineRoot.props new file mode 100644 index 00000000..7020603b --- /dev/null +++ b/Platforms/WindowsStore/build/WindowsStore/EngineRoot.props @@ -0,0 +1,14 @@ + + + + + ..\..\..\..\.. + + + + + + $(EngineRoot) + + + \ No newline at end of file diff --git a/Platforms/WindowsStore/build/WindowsStore/WindowsStorePlatform.Shared/WindowsStorePlatform.Shared.vcxitems b/Platforms/WindowsStore/build/WindowsStore/WindowsStorePlatform.Shared/WindowsStorePlatform.Shared.vcxitems new file mode 100644 index 00000000..3038876f --- /dev/null +++ b/Platforms/WindowsStore/build/WindowsStore/WindowsStorePlatform.Shared/WindowsStorePlatform.Shared.vcxitems @@ -0,0 +1,32 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + {65c1955f-c69e-4185-8b89-864725706a36} + WindowsStoreAppPlatform + WindowsStorePlatform.Shared + 248F659F-DAC5-46E8-AC09-60EC9FC95053 + + + + %(AdditionalIncludeDirectories);$(MSBuildThisFileDirectory) + + + + + + + + + + + + + + Create + + + + + \ No newline at end of file diff --git a/Platforms/WindowsStore/build/WindowsStore/WindowsStorePlatform.Shared/WindowsStorePlatform.Shared.vcxitems.filters b/Platforms/WindowsStore/build/WindowsStore/WindowsStorePlatform.Shared/WindowsStorePlatform.Shared.vcxitems.filters new file mode 100644 index 00000000..ba33e21f --- /dev/null +++ b/Platforms/WindowsStore/build/WindowsStore/WindowsStorePlatform.Shared/WindowsStorePlatform.Shared.vcxitems.filters @@ -0,0 +1,36 @@ + + + + + {670fa2df-d6dd-43d2-b203-5e9e31068bd1} + + + {6be7cc95-dbc1-4438-a844-0a3178a336bb} + + + + + include + + + include + + + include + + + include + + + + + src + + + src + + + src + + + \ No newline at end of file diff --git a/Platforms/WindowsStore/build/WindowsStore/WindowsStorePlatform.Windows/WindowsStorePlatform.Windows.vcxproj b/Platforms/WindowsStore/build/WindowsStore/WindowsStorePlatform.Windows/WindowsStorePlatform.Windows.vcxproj new file mode 100644 index 00000000..b40cebe7 --- /dev/null +++ b/Platforms/WindowsStore/build/WindowsStore/WindowsStorePlatform.Windows/WindowsStorePlatform.Windows.vcxproj @@ -0,0 +1,212 @@ + + + + + Debug + ARM + + + Debug + Win32 + + + Debug + x64 + + + Release + ARM + + + Release + Win32 + + + Release + x64 + + + + {eba5d25b-265d-4936-92c3-6ee01bf1b6d7} + WindowsStoreAppPlatform + en-US + 12.0 + true + Windows Store + 8.1 + CodeSharingStaticLibrary + WindowsStorePlatform.Windows + + + + StaticLibrary + true + v120 + + + StaticLibrary + true + v120 + + + StaticLibrary + true + v120 + + + StaticLibrary + false + true + v120 + + + StaticLibrary + false + true + v120 + + + StaticLibrary + false + true + v120 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + false + $(EngineRoot)\Platforms\WindowsStore\include;$(IncludePath) + + + false + $(EngineRoot)\Platforms\WindowsStore\include;$(IncludePath) + + + false + $(EngineRoot)\Platforms\WindowsStore\include;$(IncludePath) + + + false + $(EngineRoot)\Platforms\WindowsStore\include;$(IncludePath) + + + false + $(EngineRoot)\Platforms\WindowsStore\include;$(IncludePath) + + + false + $(EngineRoot)\Platforms\WindowsStore\include;$(IncludePath) + + + + Use + false + true + + + Console + false + false + + + + + Use + false + true + + + Console + false + false + + + + + Use + false + true + + + Console + false + false + + + + + Use + false + true + + + Console + false + false + + + + + Use + false + true + + + Console + false + false + + + + + Use + false + true + + + Console + false + false + + + + + + \ No newline at end of file diff --git a/Platforms/WindowsStore/build/WindowsStore/WindowsStorePlatform.Windows/WindowsStorePlatform.Windows.vcxproj.filters b/Platforms/WindowsStore/build/WindowsStore/WindowsStorePlatform.Windows/WindowsStorePlatform.Windows.vcxproj.filters new file mode 100644 index 00000000..a7761ab0 --- /dev/null +++ b/Platforms/WindowsStore/build/WindowsStore/WindowsStorePlatform.Windows/WindowsStorePlatform.Windows.vcxproj.filters @@ -0,0 +1,5 @@ + + + + + diff --git a/Platforms/WindowsStore/build/WindowsStore/WindowsStorePlatform.WindowsPhone/WindowsStorePlatform.WindowsPhone.vcxproj b/Platforms/WindowsStore/build/WindowsStore/WindowsStorePlatform.WindowsPhone/WindowsStorePlatform.WindowsPhone.vcxproj new file mode 100644 index 00000000..f21c0f8a --- /dev/null +++ b/Platforms/WindowsStore/build/WindowsStore/WindowsStorePlatform.WindowsPhone/WindowsStorePlatform.WindowsPhone.vcxproj @@ -0,0 +1,148 @@ + + + + + Debug + ARM + + + Debug + Win32 + + + Release + ARM + + + Release + Win32 + + + + {e518043b-b99a-414f-a276-d93b0f263df2} + WindowsStoreAppPlatform + en-US + 12.0 + true + Windows Phone + 8.1 + CodeSharingStaticLibrary + + + + StaticLibrary + true + v120_wp81 + + + StaticLibrary + true + v120_wp81 + + + StaticLibrary + false + true + v120_wp81 + + + StaticLibrary + false + true + v120_wp81 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + false + $(EngineRoot)\Platforms\WindowsStore\include;$(IncludePath) + + + false + $(EngineRoot)\Platforms\WindowsStore\include;$(IncludePath) + + + false + $(EngineRoot)\Platforms\WindowsStore\include;$(IncludePath) + + + false + $(EngineRoot)\Platforms\WindowsStore\include;$(IncludePath) + + + + Use + false + true + + + Console + false + false + + + + + Use + false + true + + + Console + false + false + + + + + Use + false + true + + + Console + false + false + + + + + Use + false + true + + + Console + false + false + + + + + + \ No newline at end of file diff --git a/Platforms/WindowsStore/build/WindowsStore/WindowsStorePlatform.WindowsPhone/WindowsStorePlatform.WindowsPhone.vcxproj.filters b/Platforms/WindowsStore/build/WindowsStore/WindowsStorePlatform.WindowsPhone/WindowsStorePlatform.WindowsPhone.vcxproj.filters new file mode 100644 index 00000000..a7761ab0 --- /dev/null +++ b/Platforms/WindowsStore/build/WindowsStore/WindowsStorePlatform.WindowsPhone/WindowsStorePlatform.WindowsPhone.vcxproj.filters @@ -0,0 +1,5 @@ + + + + + diff --git a/Platforms/WindowsStore/include/WindowsStoreDebug.h b/Platforms/WindowsStore/include/WindowsStoreDebug.h new file mode 100644 index 00000000..a4ed3ace --- /dev/null +++ b/Platforms/WindowsStore/include/WindowsStoreDebug.h @@ -0,0 +1,32 @@ +/* Copyright 2015 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +#include "..\Basic\include\BasicPlatformDebug.h" + +struct WindowsStoreDebug : public BasicPlatformDebug +{ + static void AssertionFailed( const Diligent::Char *Message, const char *Function, const char *File, int Line ); + static void OutputDebugMessage( DebugMessageSeverity Severity, const Diligent::Char *Message ); +}; diff --git a/Platforms/WindowsStore/include/WindowsStoreFileSystem.h b/Platforms/WindowsStore/include/WindowsStoreFileSystem.h new file mode 100644 index 00000000..d2ac1d1f --- /dev/null +++ b/Platforms/WindowsStore/include/WindowsStoreFileSystem.h @@ -0,0 +1,72 @@ +/* Copyright 2015 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +#include "..\Basic\include\BasicFileSystem.h" +#include + +// Do not include windows headers here as they will mess up CreateDirectory() +// and DeleteFile() functions! +//#define NOMINMAX +//#include + +class WindowsStoreFile : public BasicFile +{ +public: + WindowsStoreFile( const FileOpenAttribs &OpenAttribs ); + ~WindowsStoreFile(); + + void Read( Diligent::IDataBlob *pData ); + + bool Read( void *Data, size_t BufferSize ); + + void Write( Diligent::IDataBlob *pData ); + bool Write( const void *Data, size_t BufferSize ); + + size_t GetSize(); + + size_t GetPos(); + + void SetPos(size_t Offset, FilePosOrigin Origin); + +private: + // We have to do such tricks, because we cannot #include + // to avoid name clashes. + std::unique_ptr m_FileHandle; +}; + +struct WindowsStoreFileSystem : public BasicFileSystem +{ +public: + static WindowsStoreFile* OpenFile( const FileOpenAttribs &OpenAttribs ); + static inline Diligent::Char GetSlashSymbol(){ return '\\'; } + + static bool FileExists( const Diligent::Char *strFilePath ); + static bool PathExists( const Diligent::Char *strPath ); + + static bool CreateDirectory( const Diligent::Char *strPath ); + static void ClearDirectory( const Diligent::Char *strPath ); + static void DeleteFile( const Diligent::Char *strPath ); + static std::vector> Search(const Diligent::Char *SearchPattern); +}; diff --git a/Platforms/WindowsStore/include/WindowsStorePlatformDefinitions.h b/Platforms/WindowsStore/include/WindowsStorePlatformDefinitions.h new file mode 100644 index 00000000..7f6a56e3 --- /dev/null +++ b/Platforms/WindowsStore/include/WindowsStorePlatformDefinitions.h @@ -0,0 +1,25 @@ +/* Copyright 2015 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + diff --git a/Platforms/WindowsStore/include/pch.h b/Platforms/WindowsStore/include/pch.h new file mode 100644 index 00000000..1d97fc93 --- /dev/null +++ b/Platforms/WindowsStore/include/pch.h @@ -0,0 +1,29 @@ +/* Copyright 2015 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +#include + +// Do not include windows headers here because they mess up DeleteFile() and CreateDirectory() +// #include \ No newline at end of file diff --git a/Platforms/WindowsStore/src/WindowsStoreDebug.cpp b/Platforms/WindowsStore/src/WindowsStoreDebug.cpp new file mode 100644 index 00000000..a694d6ec --- /dev/null +++ b/Platforms/WindowsStore/src/WindowsStoreDebug.cpp @@ -0,0 +1,84 @@ +/* Copyright 2015 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "pch.h" + +#include "WindowsStoreDebug.h" +#include "FormatMessage.h" +#include "FileSystem.h" +#include + +#define NOMINMAX +#include + +using namespace Diligent; + +void WindowsStoreDebug :: AssertionFailed( const Diligent::Char *Message, const char *Function, const char *File, int Line ) +{ + std::string FileName; + FileSystem::SplitFilePath( File, nullptr, &FileName ); + std::stringstream msgss; + Diligent::FormatMsg( msgss, "Debug assertion failed in ", Function, "(), file ", FileName, ", line ", Line, ":\n\n", Message); + auto FullMsg = msgss.str(); + OutputDebugMessage( DebugMessageSeverity::Error, FullMsg.c_str() ); + + __debugbreak(); + //int nCode = MessageBoxA(NULL, + // FullMsg.c_str(), + // "Runtime assertion failed", + // MB_TASKMODAL|MB_ICONHAND|MB_ABORTRETRYIGNORE|MB_SETFOREGROUND); + + //// Abort: abort the program + //if (nCode == IDABORT) + //{ + // // raise abort signal + // raise(SIGABRT); + + // // We usually won't get here, but it's possible that + // // SIGABRT was ignored. So exit the program anyway. + // exit(3); + //} + + //// Retry: call the debugger + //if (nCode == IDRETRY) + //{ + // DebugBreak(); + // /* return to user code */ + // return; + //} + + //// Ignore: continue execution + //if (nCode == IDIGNORE) + // return; +}; + + +void WindowsStoreDebug::OutputDebugMessage( DebugMessageSeverity Severity, const Diligent::Char *Message ) +{ + String str = Message; + str += '\n'; + static Char* strSeverities[] = { "Info: ", "Warning: ", "ERROR: ", "CRITICAL ERROR: " }; + auto* MessageSevery = strSeverities[ static_cast(Severity) ]; + str += MessageSevery; + OutputDebugStringA( str.c_str() ); +} diff --git a/Platforms/WindowsStore/src/WindowsStoreFileSystem.cpp b/Platforms/WindowsStore/src/WindowsStoreFileSystem.cpp new file mode 100644 index 00000000..1f6fd239 --- /dev/null +++ b/Platforms/WindowsStore/src/WindowsStoreFileSystem.cpp @@ -0,0 +1,273 @@ +/* Copyright 2015 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "pch.h" +#include "WindowsStoreFileSystem.h" +#include "Errors.h" +#include "StringTools.h" +#include "DebugUtilities.h" + + +// Windows headers define CreateDirectory and DeleteFile as macros. +// So we need to do some tricks to avoid name mess. +bool CreateDirectoryImpl( const Diligent::Char *strPath ); +bool WindowsStoreFileSystem::CreateDirectory( const Diligent::Char *strPath ) +{ + return CreateDirectoryImpl(strPath); +} + +void DeleteFileImpl( const Diligent::Char *strPath ); +void WindowsStoreFileSystem::DeleteFile( const Diligent::Char *strPath ) +{ + return DeleteFileImpl(strPath); +} + + +#define NOMINMAX +#include + +using namespace Diligent; +using namespace Microsoft::WRL; + +class FileHandleWrapper +{ +public: + Wrappers::FileHandle FH; +}; + +WindowsStoreFile::WindowsStoreFile( const FileOpenAttribs &OpenAttribs ) : + BasicFile(OpenAttribs, WindowsStoreFileSystem::GetSlashSymbol()), + m_FileHandle(new FileHandleWrapper) +{ + CREATEFILE2_EXTENDED_PARAMETERS extendedParams = {0}; + extendedParams.dwSize = sizeof(CREATEFILE2_EXTENDED_PARAMETERS); + extendedParams.dwFileAttributes = FILE_ATTRIBUTE_NORMAL; + extendedParams.dwFileFlags = FILE_FLAG_SEQUENTIAL_SCAN; + extendedParams.dwSecurityQosFlags = SECURITY_ANONYMOUS; + extendedParams.lpSecurityAttributes = nullptr; + extendedParams.hTemplateFile = nullptr; + + auto wstrPath = Diligent::WidenString(m_OpenAttribs.strFilePath); + DWORD dwDesiredAccess = 0; + DWORD dwShareMode = 0; + DWORD dwCreateDeposition = 0; + switch( OpenAttribs.AccessMode ) + { + case EFileAccessMode::Read: + dwDesiredAccess = GENERIC_READ; + // In Windows 8.1, the file cannot be opened if it is not shared! + dwShareMode = FILE_SHARE_READ; + dwCreateDeposition = OPEN_EXISTING; + break; + + case EFileAccessMode::Overwrite: + dwDesiredAccess = GENERIC_WRITE; + dwShareMode = 0; + dwCreateDeposition = CREATE_ALWAYS; + break; + + case EFileAccessMode::Append: + dwDesiredAccess = GENERIC_WRITE; + dwShareMode = 0; + dwCreateDeposition = OPEN_ALWAYS; + break; + + default: + UNEXPECTED( "Unknown file access mode" ); + break; + } + m_FileHandle->FH.Attach( CreateFile2( + wstrPath.c_str(), + dwDesiredAccess, + dwShareMode, + dwCreateDeposition, + &extendedParams + ) ); + + if (m_FileHandle->FH.Get() == INVALID_HANDLE_VALUE) + { + LOG_ERROR_AND_THROW( "Failed to open file ", m_OpenAttribs.strFilePath ); + } +} + +WindowsStoreFile::~WindowsStoreFile() +{ +} + +bool WindowsStoreFile::Read( void *Data, size_t BufferSize ) +{ + UNSUPPORTED( "Not implemented" ); + + return false; +} + +size_t WindowsStoreFile::GetSize() +{ + FILE_STANDARD_INFO fileInfo = {0}; + if (!GetFileInformationByHandleEx( + m_FileHandle->FH.Get(), + FileStandardInfo, + &fileInfo, + sizeof(fileInfo) + )) + { + LOG_ERROR_AND_THROW( "Failed to get file info" ); + } + + if (fileInfo.EndOfFile.HighPart != 0) + { + LOG_ERROR_AND_THROW( "File is too large to be read" ); + } + + return fileInfo.EndOfFile.LowPart; +} + +void WindowsStoreFile::Read( Diligent::IDataBlob *pData ) +{ + pData->Resize( GetSize() ); + + if (!ReadFile( + m_FileHandle->FH.Get(), + pData->GetDataPtr(), + static_cast(pData->GetSize()), + nullptr, + nullptr + )) + { + LOG_ERROR_AND_THROW( "Failed to read data from file" ); + } +} + +void WindowsStoreFile::Write( Diligent::IDataBlob *pData ) +{ + DWORD numBytesWritten; + if ( + !WriteFile( + m_FileHandle->FH.Get(), + pData->GetDataPtr(), + static_cast(pData->GetSize()), + &numBytesWritten, + nullptr + ) || + numBytesWritten != pData->GetSize() + ) + { + LOG_ERROR_AND_THROW( "Failed to write data to file" ); + } +} + +bool WindowsStoreFile::Write( const void *Data, size_t BufferSize ) +{ + UNSUPPORTED("Not implemented"); + return false; +} + +size_t WindowsStoreFile::GetPos() +{ + UNSUPPORTED("Not implemented"); + return 0; +} + +void WindowsStoreFile::SetPos(size_t Offset, FilePosOrigin Origin) +{ + UNSUPPORTED("Not implemented"); +} + + +WindowsStoreFile* WindowsStoreFileSystem::OpenFile( const FileOpenAttribs &OpenAttribs ) +{ + WindowsStoreFile *pFile = nullptr; + try + { + pFile = new WindowsStoreFile( OpenAttribs ); + } + catch( const std::runtime_error &/*err*/ ) + { + + } + + return pFile; +} + +bool WindowsStoreFileSystem::FileExists( const Diligent::Char *strFilePath ) +{ + FileOpenAttribs OpenAttribs; + OpenAttribs.AccessMode = EFileAccessMode::Read; + OpenAttribs.strFilePath = strFilePath; + BasicFile DummyFile( OpenAttribs, WindowsStoreFileSystem::GetSlashSymbol() ); + const auto &Path = DummyFile.GetPath(); + + CREATEFILE2_EXTENDED_PARAMETERS extendedParams = {0}; + extendedParams.dwSize = sizeof(CREATEFILE2_EXTENDED_PARAMETERS); + extendedParams.dwFileAttributes = FILE_ATTRIBUTE_NORMAL; + extendedParams.dwFileFlags = FILE_FLAG_SEQUENTIAL_SCAN; + extendedParams.dwSecurityQosFlags = SECURITY_ANONYMOUS; + extendedParams.lpSecurityAttributes = nullptr; + extendedParams.hTemplateFile = nullptr; + + auto wstrPath = Diligent::WidenString(Path); + + auto Handle = CreateFile2( + wstrPath.c_str(), + GENERIC_READ, + FILE_SHARE_READ, + OPEN_EXISTING, + &extendedParams); + bool Exists = false; + if( Handle != INVALID_HANDLE_VALUE ) + { + CloseHandle( Handle ); + Exists = true; + } + return Exists; +} + + +bool WindowsStoreFileSystem::PathExists( const Diligent::Char *strPath ) +{ + UNSUPPORTED("Not implemented"); + return false; +} + +void WindowsStoreFileSystem::ClearDirectory( const Diligent::Char *strPath ) +{ + UNSUPPORTED("Not implemented"); +} + + +bool CreateDirectoryImpl( const Diligent::Char *strPath ) +{ + UNSUPPORTED("Not implemented"); + return false; +} + +void DeleteFileImpl( const Diligent::Char *strPath ) +{ + UNSUPPORTED("Not implemented"); +} + +std::vector> WindowsStoreFileSystem::Search(const Diligent::Char *SearchPattern) +{ + UNSUPPORTED("Not implemented"); + return std::vector>(); +} diff --git a/Platforms/WindowsStore/src/pch.cpp b/Platforms/WindowsStore/src/pch.cpp new file mode 100644 index 00000000..809315e1 --- /dev/null +++ b/Platforms/WindowsStore/src/pch.cpp @@ -0,0 +1,24 @@ +/* Copyright 2015 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#include "pch.h" diff --git a/Platforms/interface/Atomics.h b/Platforms/interface/Atomics.h new file mode 100644 index 00000000..01f0ba0e --- /dev/null +++ b/Platforms/interface/Atomics.h @@ -0,0 +1,32 @@ +/* Copyright 2015 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +#include "PlatformDefinitions.h" + +// Atomics are implemented using c++11 standard atomics, so there is no need +// to use different implementations for different platforms +#include "..\Basic\include\BasicAtomics.h" + +typedef BasicAtomics Atomics; diff --git a/Platforms/interface/FileSystem.h b/Platforms/interface/FileSystem.h new file mode 100644 index 00000000..42dbbf39 --- /dev/null +++ b/Platforms/interface/FileSystem.h @@ -0,0 +1,45 @@ +/* Copyright 2015 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +#include "PlatformDefinitions.h" + +#if defined( PLATFORM_WINDOWS ) + + #include "..\Windows\include\WindowsFileSystem.h" + typedef WindowsFileSystem FileSystem; + typedef WindowsFile CFile; + +#elif defined( PLATFORM_WINDOWS_STORE ) + + #include "..\WindowsStore\include\WindowsStoreFileSystem.h" + typedef WindowsStoreFileSystem FileSystem; + typedef WindowsStoreFile CFile; + +#elif defined ( PLATFORM_ANDROID ) + + #include "..\Android\include\AndroidFileSystem.h" + typedef AndroidFileSystem FileSystem; + typedef AndroidFile CFile; +#endif diff --git a/Platforms/interface/PlatformDebug.h b/Platforms/interface/PlatformDebug.h new file mode 100644 index 00000000..7c3a4c77 --- /dev/null +++ b/Platforms/interface/PlatformDebug.h @@ -0,0 +1,39 @@ +/* Copyright 2015 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +#include "PlatformDefinitions.h" + +#if defined( PLATFORM_WINDOWS ) + #include "..\Windows\include\WindowsDebug.h" + typedef WindowsDebug PlatformDebug; + +#elif defined( PLATFORM_WINDOWS_STORE ) + #include "..\WindowsStore\include\WindowsStoreDebug.h" + typedef WindowsStoreDebug PlatformDebug; + +#elif defined ( PLATFORM_ANDROID ) + #include "..\Android\include\AndroidDebug.h" + typedef AndroidDebug PlatformDebug; +#endif diff --git a/Platforms/interface/PlatformDefinitions.h b/Platforms/interface/PlatformDefinitions.h new file mode 100644 index 00000000..15c4658b --- /dev/null +++ b/Platforms/interface/PlatformDefinitions.h @@ -0,0 +1,42 @@ +/* Copyright 2015 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +#if defined(_WINDOWS) + #define PLATFORM_WINDOWS +#elif defined (_WINDOWS_STORE) + #define PLATFORM_WINDOWS_STORE +#elif defined (ANDROID) + #define PLATFORM_ANDROID +#else + #error Platform is not defined +#endif + +#if defined( PLATFORM_WINDOWS ) + #include "..\Windows\include\WindowsPlatformDefinitions.h" +#elif defined( PLATFORM_WINDOWS_STORE ) + #include "..\WindowsStore\include\WindowsStorePlatformDefinitions.h" +#elif defined ( PLATFORM_ANDROID ) + #include "..\Android\include\AndroidPlatformDefinitions.h" +#endif diff --git a/Platforms/interface/PlatformMisc.h b/Platforms/interface/PlatformMisc.h new file mode 100644 index 00000000..1b4368c0 --- /dev/null +++ b/Platforms/interface/PlatformMisc.h @@ -0,0 +1,39 @@ +/* Copyright 2015 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +#include "PlatformDefinitions.h" + +#if defined( PLATFORM_WINDOWS ) + #include "..\Windows\include\WindowsPlatformMisc.h" + typedef WindowsMisc PlatformMisc; + +#elif defined( PLATFORM_WINDOWS_STORE ) + #include "..\Windows\include\WindowsPlatformMisc.h" + typedef WindowsMisc PlatformMisc; + +#elif defined ( PLATFORM_ANDROID ) + #include "..\Android\include\AndroidPlatformMisc.h" + typedef AndroidMisc PlatformMisc; +#endif diff --git a/Platforms/interface/build/WindowsStore/PlatformInterface.Shared.vcxitems b/Platforms/interface/build/WindowsStore/PlatformInterface.Shared.vcxitems new file mode 100644 index 00000000..8e2ef7dd --- /dev/null +++ b/Platforms/interface/build/WindowsStore/PlatformInterface.Shared.vcxitems @@ -0,0 +1,26 @@ + + + + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + true + {C8F281ED-F3B9-4C24-A2D3-40A922363466} + BasicPlatform + PlatformInterface.Shared + 248F659F-DAC5-46E8-AC09-60EC9FC95053 + + + + %(AdditionalIncludeDirectories);$(MSBuildThisFileDirectory) + + + + + + + + + + + + + \ No newline at end of file diff --git a/Platforms/interface/build/WindowsStore/PlatformInterface.Shared.vcxitems.filters b/Platforms/interface/build/WindowsStore/PlatformInterface.Shared.vcxitems.filters new file mode 100644 index 00000000..9945c4f3 --- /dev/null +++ b/Platforms/interface/build/WindowsStore/PlatformInterface.Shared.vcxitems.filters @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file -- cgit v1.2.3