From dadb44ef46cb83a957507a1d2d5d20986b3cec22 Mon Sep 17 00:00:00 2001 From: Robert Campbell Date: Thu, 30 Jan 2020 04:39:19 -0500 Subject: Introduced NativeWindow wrapper for supported platforms --- Platforms/Android/CMakeLists.txt | 1 + .../Android/interface/AndroidNativeWindow.hpp | 39 ++++++++++ Platforms/Apple/CMakeLists.txt | 7 ++ Platforms/Apple/interface/IOSNativeWindow.hpp | 39 ++++++++++ Platforms/Apple/interface/MacOSNativeWindow.hpp | 39 ++++++++++ Platforms/CMakeLists.txt | 1 + Platforms/Linux/CMakeLists.txt | 1 + Platforms/Linux/interface/LinuxNativeWindow.hpp | 40 ++++++++++ Platforms/UWP/CMakeLists.txt | 1 + Platforms/UWP/interface/UWPNativeWindow.hpp | 39 ++++++++++ Platforms/Win32/CMakeLists.txt | 1 + Platforms/Win32/interface/Win32NativeWindow.hpp | 39 ++++++++++ Platforms/interface/NativeWindow.h | 90 ++++++++++++++++++++++ 13 files changed, 337 insertions(+) create mode 100644 Platforms/Android/interface/AndroidNativeWindow.hpp create mode 100644 Platforms/Apple/interface/IOSNativeWindow.hpp create mode 100644 Platforms/Apple/interface/MacOSNativeWindow.hpp create mode 100644 Platforms/Linux/interface/LinuxNativeWindow.hpp create mode 100644 Platforms/UWP/interface/UWPNativeWindow.hpp create mode 100644 Platforms/Win32/interface/Win32NativeWindow.hpp create mode 100644 Platforms/interface/NativeWindow.h (limited to 'Platforms') diff --git a/Platforms/Android/CMakeLists.txt b/Platforms/Android/CMakeLists.txt index 8bc86337..d05f4034 100644 --- a/Platforms/Android/CMakeLists.txt +++ b/Platforms/Android/CMakeLists.txt @@ -7,6 +7,7 @@ set(INTERFACE interface/AndroidFileSystem.hpp interface/AndroidPlatformDefinitions.h interface/AndroidPlatformMisc.hpp + interface/AndroidNativeWindow.hpp ) set(SOURCE diff --git a/Platforms/Android/interface/AndroidNativeWindow.hpp b/Platforms/Android/interface/AndroidNativeWindow.hpp new file mode 100644 index 00000000..6eac6172 --- /dev/null +++ b/Platforms/Android/interface/AndroidNativeWindow.hpp @@ -0,0 +1,39 @@ +/* + * Copyright 2019-2020 Diligent Graphics LLC + * Copyright 2015-2019 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 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * 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 "../../../Primitives/interface/CommonDefinitions.h" + +DILIGENT_BEGIN_NAMESPACE(Diligent) + +struct AndroidNativeWindow +{ + void* pAWindow DEFAULT_INITIALIZER(nullptr); +}; + +DILIGENT_END_NAMESPACE // namespace Diligent \ No newline at end of file diff --git a/Platforms/Apple/CMakeLists.txt b/Platforms/Apple/CMakeLists.txt index dd1efec0..b298fa8d 100644 --- a/Platforms/Apple/CMakeLists.txt +++ b/Platforms/Apple/CMakeLists.txt @@ -2,12 +2,19 @@ cmake_minimum_required (VERSION 3.6) project(Diligent-ApplePlatform CXX) +if(PLATFORM_MACOS) + set(APPLE_NATIVE_WINDOW_H interface/MacOSNativeWindow.hpp) +elseif(PLATFORM_IOS) + set(APPLE_NATIVE_WINDOW_H interface/IOSNativeWindow.hpp) +endif() + set(INTERFACE interface/CFObjectWrapper.hpp interface/AppleDebug.hpp interface/AppleFileSystem.hpp interface/ApplePlatformDefinitions.h interface/ApplePlatformMisc.hpp + ${APPLE_NATIVE_WINDOW_H} ) set(SOURCE diff --git a/Platforms/Apple/interface/IOSNativeWindow.hpp b/Platforms/Apple/interface/IOSNativeWindow.hpp new file mode 100644 index 00000000..5d373942 --- /dev/null +++ b/Platforms/Apple/interface/IOSNativeWindow.hpp @@ -0,0 +1,39 @@ +/* + * Copyright 2019-2020 Diligent Graphics LLC + * Copyright 2015-2019 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 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * 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 "../../../Primitives/interface/CommonDefinitions.h" + +DILIGENT_BEGIN_NAMESPACE(Diligent) + +struct IOSNativeWindow +{ + void* pNSView DEFAULT_INITIALIZER(nullptr); +}; + +DILIGENT_END_NAMESPACE // namespace Diligent diff --git a/Platforms/Apple/interface/MacOSNativeWindow.hpp b/Platforms/Apple/interface/MacOSNativeWindow.hpp new file mode 100644 index 00000000..e54fd774 --- /dev/null +++ b/Platforms/Apple/interface/MacOSNativeWindow.hpp @@ -0,0 +1,39 @@ +/* + * Copyright 2019-2020 Diligent Graphics LLC + * Copyright 2015-2019 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 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * 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 "../../../Primitives/interface/CommonDefinitions.h" + +DILIGENT_BEGIN_NAMESPACE(Diligent) + +struct MacOSNativeWindow +{ + void* pNSWindow DEFAULT_INITIALIZER(nullptr); +}; + +DILIGENT_END_NAMESPACE // namespace Diligent \ No newline at end of file diff --git a/Platforms/CMakeLists.txt b/Platforms/CMakeLists.txt index 0a310dab..690ece42 100644 --- a/Platforms/CMakeLists.txt +++ b/Platforms/CMakeLists.txt @@ -10,6 +10,7 @@ set(PLATFORM_INTERFACE_HEADERS ../interface/PlatformDebug.hpp ../interface/PlatformDefinitions.h ../interface/PlatformMisc.hpp + ../interface/NativeWindow.h ) add_subdirectory(Basic) diff --git a/Platforms/Linux/CMakeLists.txt b/Platforms/Linux/CMakeLists.txt index 0b0214de..a0113c60 100644 --- a/Platforms/Linux/CMakeLists.txt +++ b/Platforms/Linux/CMakeLists.txt @@ -7,6 +7,7 @@ set(INTERFACE interface/LinuxFileSystem.hpp interface/LinuxPlatformDefinitions.h interface/LinuxPlatformMisc.hpp + interface/LinuxNativeWindow.hpp ) set(SOURCE diff --git a/Platforms/Linux/interface/LinuxNativeWindow.hpp b/Platforms/Linux/interface/LinuxNativeWindow.hpp new file mode 100644 index 00000000..937c2d97 --- /dev/null +++ b/Platforms/Linux/interface/LinuxNativeWindow.hpp @@ -0,0 +1,40 @@ +/* + * Copyright 2019-2020 Diligent Graphics LLC + * Copyright 2015-2019 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 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * 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 "../../../Primitives/interface/CommonDefinitions.h" + +DILIGENT_BEGIN_NAMESPACE(Diligent) + +struct LinuxNativeWindow +{ + void* pDisplay DEFAULT_INITIALIZER(nullptr); + void* pWindow DEFAULT_INITIALIZER(nullptr); +}; + +DILIGENT_END_NAMESPACE // namespace Diligent \ No newline at end of file diff --git a/Platforms/UWP/CMakeLists.txt b/Platforms/UWP/CMakeLists.txt index 0160b23c..ae2e1c93 100644 --- a/Platforms/UWP/CMakeLists.txt +++ b/Platforms/UWP/CMakeLists.txt @@ -6,6 +6,7 @@ set(INTERFACE interface/UWPDebug.hpp interface/UWPFileSystem.hpp interface/UWPDefinitions.h + interface/UWPNativeWindow.hpp ../Win32/interface/Win32Atomics.hpp ) diff --git a/Platforms/UWP/interface/UWPNativeWindow.hpp b/Platforms/UWP/interface/UWPNativeWindow.hpp new file mode 100644 index 00000000..1cef2430 --- /dev/null +++ b/Platforms/UWP/interface/UWPNativeWindow.hpp @@ -0,0 +1,39 @@ +/* + * Copyright 2019-2020 Diligent Graphics LLC + * Copyright 2015-2019 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 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * 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 "../../../Primitives/interface/CommonDefinitions.h" + +DILIGENT_BEGIN_NAMESPACE(Diligent) + +struct UWPNativeWindow +{ + void* pWindow DEFAULT_INITIALIZER(nullptr); +}; + +DILIGENT_END_NAMESPACE // namespace Diligent \ No newline at end of file diff --git a/Platforms/Win32/CMakeLists.txt b/Platforms/Win32/CMakeLists.txt index 84462ade..75b24049 100644 --- a/Platforms/Win32/CMakeLists.txt +++ b/Platforms/Win32/CMakeLists.txt @@ -8,6 +8,7 @@ set(INTERFACE interface/Win32FileSystem.hpp interface/Win32PlatformDefinitions.h interface/Win32PlatformMisc.hpp + interface/Win32NativeWindow.hpp ) set(SOURCE diff --git a/Platforms/Win32/interface/Win32NativeWindow.hpp b/Platforms/Win32/interface/Win32NativeWindow.hpp new file mode 100644 index 00000000..530b6569 --- /dev/null +++ b/Platforms/Win32/interface/Win32NativeWindow.hpp @@ -0,0 +1,39 @@ +/* + * Copyright 2019-2020 Diligent Graphics LLC + * Copyright 2015-2019 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 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * 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 "../../../Primitives/interface/CommonDefinitions.h" + +DILIGENT_BEGIN_NAMESPACE(Diligent) + +struct Win32NativeWindow +{ + void* hWnd DEFAULT_INITIALIZER(nullptr); +}; + +DILIGENT_END_NAMESPACE // namespace Diligent \ No newline at end of file diff --git a/Platforms/interface/NativeWindow.h b/Platforms/interface/NativeWindow.h new file mode 100644 index 00000000..79724630 --- /dev/null +++ b/Platforms/interface/NativeWindow.h @@ -0,0 +1,90 @@ +/* + * Copyright 2019-2020 Diligent Graphics LLC + * Copyright 2015-2019 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 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * 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 PLATFORM_WIN32 + +# include "../Win32/interface/Win32NativeWindow.hpp" + +#elif PLATFORM_UNIVERSAL_WINDOWS + +# include "../UWP/interface/UWPNativeWindow.hpp" + +#elif PLATFORM_ANDROID + +# include "../Android/interface/AndroidNativeWindow.hpp" + +#elif PLATFORM_LINUX + +# include "../Linux/interface/LinuxNativeWindow.hpp" + +#elif PLATFORM_MACOS + +# include "../Apple/interface/MacOSNativeWindow.hpp" + +#elif PLATFORM_IOS + +# include "../Apple/interface/IOSNativeWindow.hpp" + +#else +# error Unknown platform. Please define one of the following macros as 1: PLATFORM_WIN32, PLATFORM_UNIVERSAL_WINDOWS, PLATFORM_ANDROID, PLATFORM_LINUX, PLATFORM_MACOS, PLATFORM_IOS. +#endif + +DILIGENT_BEGIN_NAMESPACE(Diligent) + +#if PLATFORM_WIN32 + +typedef struct Win32NativeWindow NativeWindow; + +#elif PLATFORM_UNIVERSAL_WINDOWS + +typedef struct UWPNativeWindow NativeWindow; + +#elif PLATFORM_ANDROID + +typedef struct AndroidNativeWindow NativeWindow; + +#elif PLATFORM_LINUX + +typedef struct LinuxNativeWindow NativeWindow; + +#elif PLATFORM_MACOS + +typedef struct MacOSNativeWindow NativeWindow; + +#elif PLATFORM_IOS + +typedef struct IOSNativeWindow NativeWindow; + +#else +# error Unknown platform. Please define one of the following macros as 1: PLATFORM_WIN32, PLATFORM_UNIVERSAL_WINDOWS, PLATFORM_ANDROID, PLATFORM_LINUX, PLATFORM_MACOS, PLATFORM_IOS. +#endif + +DILIGENT_END_NAMESPACE // namespace Diligent \ No newline at end of file -- cgit v1.2.3