Introduced NativeWindow wrapper for supported platforms
Robert Campbell authored 3 years ago
assiduous committed 3 years ago
34 | 34 | #include "../../../Primitives/interface/BasicTypes.h" |
35 | 35 | #include "../../../Primitives/interface/DebugOutput.h" |
36 | 36 | #include "../../../Primitives/interface/FlagEnum.h" |
37 | #include "../../../Platforms/interface/NativeWindow.h" | |
37 | 38 | #include "APIInfo.h" |
38 | 39 | |
39 | 40 | /// Graphics engine namespace |
1317 | 1318 | }; |
1318 | 1319 | typedef struct EngineCreateInfo EngineCreateInfo; |
1319 | 1320 | |
1320 | ||
1321 | 1321 | /// Attributes of the OpenGL-based engine implementation |
1322 | 1322 | struct EngineGLCreateInfo DILIGENT_DERIVE(EngineCreateInfo) |
1323 | 1323 | |
1324 | /// Native window handle | |
1325 | ||
1326 | /// * On Win32 platform, this is a window handle (HWND) | |
1327 | /// * On Android platform, this is a pointer to the native window (ANativeWindow*) | |
1328 | /// * On Linux, this is the native window (Window) | |
1329 | void* pNativeWndHandle DEFAULT_INITIALIZER(nullptr); | |
1330 | ||
1331 | #if PLATFORM_LINUX | |
1332 | /// For linux platform only, this is the pointer to the display | |
1333 | void* pDisplay DEFAULT_INITIALIZER(nullptr); | |
1334 | #endif | |
1324 | /// Native window wrapper | |
1325 | NativeWindow Window; | |
1335 | 1326 | }; |
1336 | 1327 | typedef struct EngineGLCreateInfo EngineGLCreateInfo; |
1337 | 1328 |
236 | 236 | major_version_(0), |
237 | 237 | minor_version_(0) |
238 | 238 | { |
239 | auto* NativeWindow = reinterpret_cast<ANativeWindow*>(InitAttribs.pNativeWndHandle); | |
239 | auto* NativeWindow = reinterpret_cast<ANativeWindow*>(InitAttribs.Window.pAWindow); | |
240 | 240 | Init(NativeWindow); |
241 | 241 | |
242 | 242 | FillDeviceCaps(deviceCaps); |
45 | 45 | //Or better yet, use the GL3 way to get the version number |
46 | 46 | glGetIntegerv( GL_MAJOR_VERSION, &MajorVersion ); |
47 | 47 | glGetIntegerv( GL_MINOR_VERSION, &MinorVersion ); |
48 | LOG_INFO_MESSAGE(Info.pNativeWndHandle != nullptr ? "Initialized OpenGLES " : "Attached to OpenGLES ", MajorVersion, '.', MinorVersion, " context (", GLVersionString, ", ", GLRenderer, ')'); | |
48 | LOG_INFO_MESSAGE(Info.Window.pNSView != nullptr ? "Initialized OpenGLES " : "Attached to OpenGLES ", MajorVersion, '.', MinorVersion, " context (", GLVersionString, ", ", GLRenderer, ')'); | |
49 | 49 | |
50 | 50 | // Under the standard filtering rules for cubemaps, filtering does not work across faces of the cubemap. |
51 | 51 | // This results in a seam across the faces of a cubemap. This was a hardware limitation in the past, but |
86 | 86 | |
87 | 87 | GLContext::GLContext(const EngineGLCreateInfo& InitAttribs, DeviceCaps& deviceCaps, const struct SwapChainDesc* /*pSCDesc*/) : |
88 | 88 | m_Context(0), |
89 | m_pNativeWindow(InitAttribs.pNativeWndHandle), | |
90 | m_pDisplay(InitAttribs.pDisplay) | |
89 | m_pNativeWindow(InitAttribs.Window.pWindow), | |
90 | m_pDisplay(InitAttribs.Window.pDisplay) | |
91 | 91 | { |
92 | 92 | auto CurrentCtx = glXGetCurrentContext(); |
93 | 93 | if (CurrentCtx == 0) |
100 | 100 | if (GLEW_OK != err) |
101 | 101 | LOG_ERROR_AND_THROW("Failed to initialize GLEW"); |
102 | 102 | |
103 | if (InitAttribs.pNativeWndHandle != nullptr && InitAttribs.pDisplay != nullptr) | |
103 | if (InitAttribs.Window.pWindow != nullptr && InitAttribs.Window.pDisplay != nullptr) | |
104 | 104 | { |
105 | 105 | //glXSwapIntervalEXT(0); |
106 | 106 | |
126 | 126 | //Or better yet, use the GL3 way to get the version number |
127 | 127 | glGetIntegerv(GL_MAJOR_VERSION, &MajorVersion); |
128 | 128 | glGetIntegerv(GL_MINOR_VERSION, &MinorVersion); |
129 | LOG_INFO_MESSAGE(InitAttribs.pNativeWndHandle != nullptr ? "Initialized OpenGL " : "Attached to OpenGL ", MajorVersion, '.', MinorVersion, " context (", GLVersionString, ", ", GLRenderer, ')'); | |
129 | LOG_INFO_MESSAGE(InitAttribs.Window.pWindow != nullptr ? "Initialized OpenGL " : "Attached to OpenGL ", MajorVersion, '.', MinorVersion, " context (", GLVersionString, ", ", GLRenderer, ')'); | |
130 | 130 | |
131 | 131 | // Under the standard filtering rules for cubemaps, filtering does not work across faces of the cubemap. |
132 | 132 | // This results in a seam across the faces of a cubemap. This was a hardware limitation in the past, but |
73 | 73 | //Or better yet, use the GL3 way to get the version number |
74 | 74 | glGetIntegerv( GL_MAJOR_VERSION, &MajorVersion ); |
75 | 75 | glGetIntegerv( GL_MINOR_VERSION, &MinorVersion ); |
76 | LOG_INFO_MESSAGE(InitAttribs.pNativeWndHandle != nullptr ? "Initialized OpenGL " : "Attached to OpenGL ", MajorVersion, '.', MinorVersion, " context (", GLVersionString, ", ", GLRenderer, ')'); | |
76 | LOG_INFO_MESSAGE(InitAttribs.Window.pNSWindow != nullptr ? "Initialized OpenGL " : "Attached to OpenGL ", MajorVersion, '.', MinorVersion, " context (", GLVersionString, ", ", GLRenderer, ')'); | |
77 | 77 | |
78 | 78 | // Under the standard filtering rules for cubemaps, filtering does not work across faces of the cubemap. |
79 | 79 | // This results in a seam across the faces of a cubemap. This was a hardware limitation in the past, but |
103 | 103 | m_WindowHandleToDeviceContext{0} |
104 | 104 | { |
105 | 105 | Int32 MajorVersion = 0, MinorVersion = 0; |
106 | if (InitAttribs.pNativeWndHandle != nullptr) | |
107 | { | |
108 | HWND hWnd = reinterpret_cast<HWND>(InitAttribs.pNativeWndHandle); | |
106 | if (InitAttribs.Window.hWnd != nullptr) | |
107 | { | |
108 | HWND hWnd = reinterpret_cast<HWND>(InitAttribs.Window.hWnd); | |
109 | 109 | |
110 | 110 | // See http://www.opengl.org/wiki/Tutorial:_OpenGL_3.1_The_First_Triangle_(C%2B%2B/Win) |
111 | 111 | // http://www.opengl.org/wiki/Creating_an_OpenGL_Context_(WGL) |
272 | 272 | //Or better yet, use the GL3 way to get the version number |
273 | 273 | glGetIntegerv(GL_MAJOR_VERSION, &MajorVersion); |
274 | 274 | glGetIntegerv(GL_MINOR_VERSION, &MinorVersion); |
275 | LOG_INFO_MESSAGE(InitAttribs.pNativeWndHandle != nullptr ? "Initialized OpenGL " : "Attached to OpenGL ", MajorVersion, '.', MinorVersion, " context (", GLVersionString, ')'); | |
275 | LOG_INFO_MESSAGE(InitAttribs.Window.hWnd != nullptr ? "Initialized OpenGL " : "Attached to OpenGL ", MajorVersion, '.', MinorVersion, " context (", GLVersionString, ')'); | |
276 | 276 | |
277 | 277 | // Under the standard filtering rules for cubemaps, filtering does not work across faces of the cubemap. |
278 | 278 | // This results in a seam across the faces of a cubemap. This was a hardware limitation in the past, but |
42 | 42 | m_DepthRenderBuffer(false), |
43 | 43 | m_DefaultFBO(false) |
44 | 44 | { |
45 | m_CALayer = InitAttribs.pNativeWndHandle; | |
45 | m_CALayer = InitAttribs.Window.pNSView; | |
46 | 46 | InitRenderBuffers(true, m_SwapChainDesc.Width, m_SwapChainDesc.Height); |
47 | 47 | CreateDummyBuffers(m_pRenderDevice.RawPtr<RenderDeviceGLImpl>()); |
48 | 48 | } |
47 | 47 | // clang-format on |
48 | 48 | { |
49 | 49 | #if PLATFORM_WIN32 |
50 | HWND hWnd = reinterpret_cast<HWND>(InitAttribs.pNativeWndHandle); | |
50 | HWND hWnd = reinterpret_cast<HWND>(InitAttribs.Window.hWnd); | |
51 | 51 | RECT rc; |
52 | 52 | GetClientRect(hWnd, &rc); |
53 | 53 | m_SwapChainDesc.Width = rc.right - rc.left; |
54 | 54 | m_SwapChainDesc.Height = rc.bottom - rc.top; |
55 | 55 | #elif PLATFORM_LINUX |
56 | auto wnd = static_cast<Window>(reinterpret_cast<size_t>(InitAttribs.pNativeWndHandle)); | |
57 | auto display = reinterpret_cast<Display*>(InitAttribs.pDisplay); | |
56 | auto wnd = static_cast<Window>(reinterpret_cast<size_t>(InitAttribs.Window.pWindow)); | |
57 | auto display = reinterpret_cast<Display*>(InitAttribs.Window.pDisplay); | |
58 | 58 | |
59 | 59 | XWindowAttributes XWndAttribs; |
60 | 60 | XGetWindowAttributes(display, wnd, &XWndAttribs); |
6 | 6 | interface/AndroidFileSystem.hpp |
7 | 7 | interface/AndroidPlatformDefinitions.h |
8 | 8 | interface/AndroidPlatformMisc.hpp |
9 | interface/AndroidNativeWindow.hpp | |
9 | 10 | ) |
10 | 11 | |
11 | 12 | set(SOURCE |
0 | /* | |
1 | * Copyright 2019-2020 Diligent Graphics LLC | |
2 | * Copyright 2015-2019 Egor Yusov | |
3 | * | |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | * you may not use this file except in compliance with the License. | |
6 | * You may obtain a copy of the License at | |
7 | * | |
8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | * | |
10 | * Unless required by applicable law or agreed to in writing, software | |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | * See the License for the specific language governing permissions and | |
14 | * limitations under the License. | |
15 | * | |
16 | * In no event and under no legal theory, whether in tort (including negligence), | |
17 | * contract, or otherwise, unless required by applicable law (such as deliberate | |
18 | * and grossly negligent acts) or agreed to in writing, shall any Contributor be | |
19 | * liable for any damages, including any direct, indirect, special, incidental, | |
20 | * or consequential damages of any character arising as a result of this License or | |
21 | * out of the use or inability to use the software (including but not limited to damages | |
22 | * for loss of goodwill, work stoppage, computer failure or malfunction, or any and | |
23 | * all other commercial damages or losses), even if such Contributor has been advised | |
24 | * of the possibility of such damages. | |
25 | */ | |
26 | ||
27 | #pragma once | |
28 | ||
29 | #include "../../../Primitives/interface/CommonDefinitions.h" | |
30 | ||
31 | DILIGENT_BEGIN_NAMESPACE(Diligent) | |
32 | ||
33 | struct AndroidNativeWindow | |
34 | { | |
35 | void* pAWindow DEFAULT_INITIALIZER(nullptr); | |
36 | }; | |
37 | ||
38 | DILIGENT_END_NAMESPACE // namespace Diligent⏎ |
0 | 0 | cmake_minimum_required (VERSION 3.6) |
1 | 1 | |
2 | 2 | project(Diligent-ApplePlatform CXX) |
3 | ||
4 | if(PLATFORM_MACOS) | |
5 | set(APPLE_NATIVE_WINDOW_H interface/MacOSNativeWindow.hpp) | |
6 | elseif(PLATFORM_IOS) | |
7 | set(APPLE_NATIVE_WINDOW_H interface/IOSNativeWindow.hpp) | |
8 | endif() | |
3 | 9 | |
4 | 10 | set(INTERFACE |
5 | 11 | interface/CFObjectWrapper.hpp |
7 | 13 | interface/AppleFileSystem.hpp |
8 | 14 | interface/ApplePlatformDefinitions.h |
9 | 15 | interface/ApplePlatformMisc.hpp |
16 | ${APPLE_NATIVE_WINDOW_H} | |
10 | 17 | ) |
11 | 18 | |
12 | 19 | set(SOURCE |
0 | /* | |
1 | * Copyright 2019-2020 Diligent Graphics LLC | |
2 | * Copyright 2015-2019 Egor Yusov | |
3 | * | |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | * you may not use this file except in compliance with the License. | |
6 | * You may obtain a copy of the License at | |
7 | * | |
8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | * | |
10 | * Unless required by applicable law or agreed to in writing, software | |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | * See the License for the specific language governing permissions and | |
14 | * limitations under the License. | |
15 | * | |
16 | * In no event and under no legal theory, whether in tort (including negligence), | |
17 | * contract, or otherwise, unless required by applicable law (such as deliberate | |
18 | * and grossly negligent acts) or agreed to in writing, shall any Contributor be | |
19 | * liable for any damages, including any direct, indirect, special, incidental, | |
20 | * or consequential damages of any character arising as a result of this License or | |
21 | * out of the use or inability to use the software (including but not limited to damages | |
22 | * for loss of goodwill, work stoppage, computer failure or malfunction, or any and | |
23 | * all other commercial damages or losses), even if such Contributor has been advised | |
24 | * of the possibility of such damages. | |
25 | */ | |
26 | ||
27 | #pragma once | |
28 | ||
29 | #include "../../../Primitives/interface/CommonDefinitions.h" | |
30 | ||
31 | DILIGENT_BEGIN_NAMESPACE(Diligent) | |
32 | ||
33 | struct IOSNativeWindow | |
34 | { | |
35 | void* pNSView DEFAULT_INITIALIZER(nullptr); | |
36 | }; | |
37 | ||
38 | DILIGENT_END_NAMESPACE // namespace Diligent |
0 | /* | |
1 | * Copyright 2019-2020 Diligent Graphics LLC | |
2 | * Copyright 2015-2019 Egor Yusov | |
3 | * | |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | * you may not use this file except in compliance with the License. | |
6 | * You may obtain a copy of the License at | |
7 | * | |
8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | * | |
10 | * Unless required by applicable law or agreed to in writing, software | |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | * See the License for the specific language governing permissions and | |
14 | * limitations under the License. | |
15 | * | |
16 | * In no event and under no legal theory, whether in tort (including negligence), | |
17 | * contract, or otherwise, unless required by applicable law (such as deliberate | |
18 | * and grossly negligent acts) or agreed to in writing, shall any Contributor be | |
19 | * liable for any damages, including any direct, indirect, special, incidental, | |
20 | * or consequential damages of any character arising as a result of this License or | |
21 | * out of the use or inability to use the software (including but not limited to damages | |
22 | * for loss of goodwill, work stoppage, computer failure or malfunction, or any and | |
23 | * all other commercial damages or losses), even if such Contributor has been advised | |
24 | * of the possibility of such damages. | |
25 | */ | |
26 | ||
27 | #pragma once | |
28 | ||
29 | #include "../../../Primitives/interface/CommonDefinitions.h" | |
30 | ||
31 | DILIGENT_BEGIN_NAMESPACE(Diligent) | |
32 | ||
33 | struct MacOSNativeWindow | |
34 | { | |
35 | void* pNSWindow DEFAULT_INITIALIZER(nullptr); | |
36 | }; | |
37 | ||
38 | DILIGENT_END_NAMESPACE // namespace Diligent⏎ |
9 | 9 | ../interface/PlatformDebug.hpp |
10 | 10 | ../interface/PlatformDefinitions.h |
11 | 11 | ../interface/PlatformMisc.hpp |
12 | ../interface/NativeWindow.h | |
12 | 13 | ) |
13 | 14 | |
14 | 15 | add_subdirectory(Basic) |
6 | 6 | interface/LinuxFileSystem.hpp |
7 | 7 | interface/LinuxPlatformDefinitions.h |
8 | 8 | interface/LinuxPlatformMisc.hpp |
9 | interface/LinuxNativeWindow.hpp | |
9 | 10 | ) |
10 | 11 | |
11 | 12 | set(SOURCE |
0 | /* | |
1 | * Copyright 2019-2020 Diligent Graphics LLC | |
2 | * Copyright 2015-2019 Egor Yusov | |
3 | * | |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | * you may not use this file except in compliance with the License. | |
6 | * You may obtain a copy of the License at | |
7 | * | |
8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | * | |
10 | * Unless required by applicable law or agreed to in writing, software | |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | * See the License for the specific language governing permissions and | |
14 | * limitations under the License. | |
15 | * | |
16 | * In no event and under no legal theory, whether in tort (including negligence), | |
17 | * contract, or otherwise, unless required by applicable law (such as deliberate | |
18 | * and grossly negligent acts) or agreed to in writing, shall any Contributor be | |
19 | * liable for any damages, including any direct, indirect, special, incidental, | |
20 | * or consequential damages of any character arising as a result of this License or | |
21 | * out of the use or inability to use the software (including but not limited to damages | |
22 | * for loss of goodwill, work stoppage, computer failure or malfunction, or any and | |
23 | * all other commercial damages or losses), even if such Contributor has been advised | |
24 | * of the possibility of such damages. | |
25 | */ | |
26 | ||
27 | #pragma once | |
28 | ||
29 | #include "../../../Primitives/interface/CommonDefinitions.h" | |
30 | ||
31 | DILIGENT_BEGIN_NAMESPACE(Diligent) | |
32 | ||
33 | struct LinuxNativeWindow | |
34 | { | |
35 | void* pDisplay DEFAULT_INITIALIZER(nullptr); | |
36 | void* pWindow DEFAULT_INITIALIZER(nullptr); | |
37 | }; | |
38 | ||
39 | DILIGENT_END_NAMESPACE // namespace Diligent⏎ |
5 | 5 | interface/UWPDebug.hpp |
6 | 6 | interface/UWPFileSystem.hpp |
7 | 7 | interface/UWPDefinitions.h |
8 | interface/UWPNativeWindow.hpp | |
8 | 9 | ../Win32/interface/Win32Atomics.hpp |
9 | 10 | ) |
10 | 11 |
0 | /* | |
1 | * Copyright 2019-2020 Diligent Graphics LLC | |
2 | * Copyright 2015-2019 Egor Yusov | |
3 | * | |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | * you may not use this file except in compliance with the License. | |
6 | * You may obtain a copy of the License at | |
7 | * | |
8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | * | |
10 | * Unless required by applicable law or agreed to in writing, software | |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | * See the License for the specific language governing permissions and | |
14 | * limitations under the License. | |
15 | * | |
16 | * In no event and under no legal theory, whether in tort (including negligence), | |
17 | * contract, or otherwise, unless required by applicable law (such as deliberate | |
18 | * and grossly negligent acts) or agreed to in writing, shall any Contributor be | |
19 | * liable for any damages, including any direct, indirect, special, incidental, | |
20 | * or consequential damages of any character arising as a result of this License or | |
21 | * out of the use or inability to use the software (including but not limited to damages | |
22 | * for loss of goodwill, work stoppage, computer failure or malfunction, or any and | |
23 | * all other commercial damages or losses), even if such Contributor has been advised | |
24 | * of the possibility of such damages. | |
25 | */ | |
26 | ||
27 | #pragma once | |
28 | ||
29 | #include "../../../Primitives/interface/CommonDefinitions.h" | |
30 | ||
31 | DILIGENT_BEGIN_NAMESPACE(Diligent) | |
32 | ||
33 | struct UWPNativeWindow | |
34 | { | |
35 | void* pWindow DEFAULT_INITIALIZER(nullptr); | |
36 | }; | |
37 | ||
38 | DILIGENT_END_NAMESPACE // namespace Diligent⏎ |
7 | 7 | interface/Win32FileSystem.hpp |
8 | 8 | interface/Win32PlatformDefinitions.h |
9 | 9 | interface/Win32PlatformMisc.hpp |
10 | interface/Win32NativeWindow.hpp | |
10 | 11 | ) |
11 | 12 | |
12 | 13 | set(SOURCE |
0 | /* | |
1 | * Copyright 2019-2020 Diligent Graphics LLC | |
2 | * Copyright 2015-2019 Egor Yusov | |
3 | * | |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | * you may not use this file except in compliance with the License. | |
6 | * You may obtain a copy of the License at | |
7 | * | |
8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | * | |
10 | * Unless required by applicable law or agreed to in writing, software | |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | * See the License for the specific language governing permissions and | |
14 | * limitations under the License. | |
15 | * | |
16 | * In no event and under no legal theory, whether in tort (including negligence), | |
17 | * contract, or otherwise, unless required by applicable law (such as deliberate | |
18 | * and grossly negligent acts) or agreed to in writing, shall any Contributor be | |
19 | * liable for any damages, including any direct, indirect, special, incidental, | |
20 | * or consequential damages of any character arising as a result of this License or | |
21 | * out of the use or inability to use the software (including but not limited to damages | |
22 | * for loss of goodwill, work stoppage, computer failure or malfunction, or any and | |
23 | * all other commercial damages or losses), even if such Contributor has been advised | |
24 | * of the possibility of such damages. | |
25 | */ | |
26 | ||
27 | #pragma once | |
28 | ||
29 | #include "../../../Primitives/interface/CommonDefinitions.h" | |
30 | ||
31 | DILIGENT_BEGIN_NAMESPACE(Diligent) | |
32 | ||
33 | struct Win32NativeWindow | |
34 | { | |
35 | void* hWnd DEFAULT_INITIALIZER(nullptr); | |
36 | }; | |
37 | ||
38 | DILIGENT_END_NAMESPACE // namespace Diligent⏎ |
0 | /* | |
1 | * Copyright 2019-2020 Diligent Graphics LLC | |
2 | * Copyright 2015-2019 Egor Yusov | |
3 | * | |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | * you may not use this file except in compliance with the License. | |
6 | * You may obtain a copy of the License at | |
7 | * | |
8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | * | |
10 | * Unless required by applicable law or agreed to in writing, software | |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | * See the License for the specific language governing permissions and | |
14 | * limitations under the License. | |
15 | * | |
16 | * In no event and under no legal theory, whether in tort (including negligence), | |
17 | * contract, or otherwise, unless required by applicable law (such as deliberate | |
18 | * and grossly negligent acts) or agreed to in writing, shall any Contributor be | |
19 | * liable for any damages, including any direct, indirect, special, incidental, | |
20 | * or consequential damages of any character arising as a result of this License or | |
21 | * out of the use or inability to use the software (including but not limited to damages | |
22 | * for loss of goodwill, work stoppage, computer failure or malfunction, or any and | |
23 | * all other commercial damages or losses), even if such Contributor has been advised | |
24 | * of the possibility of such damages. | |
25 | */ | |
26 | ||
27 | #pragma once | |
28 | ||
29 | #include "PlatformDefinitions.h" | |
30 | ||
31 | #if PLATFORM_WIN32 | |
32 | ||
33 | # include "../Win32/interface/Win32NativeWindow.hpp" | |
34 | ||
35 | #elif PLATFORM_UNIVERSAL_WINDOWS | |
36 | ||
37 | # include "../UWP/interface/UWPNativeWindow.hpp" | |
38 | ||
39 | #elif PLATFORM_ANDROID | |
40 | ||
41 | # include "../Android/interface/AndroidNativeWindow.hpp" | |
42 | ||
43 | #elif PLATFORM_LINUX | |
44 | ||
45 | # include "../Linux/interface/LinuxNativeWindow.hpp" | |
46 | ||
47 | #elif PLATFORM_MACOS | |
48 | ||
49 | # include "../Apple/interface/MacOSNativeWindow.hpp" | |
50 | ||
51 | #elif PLATFORM_IOS | |
52 | ||
53 | # include "../Apple/interface/IOSNativeWindow.hpp" | |
54 | ||
55 | #else | |
56 | # 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. | |
57 | #endif | |
58 | ||
59 | DILIGENT_BEGIN_NAMESPACE(Diligent) | |
60 | ||
61 | #if PLATFORM_WIN32 | |
62 | ||
63 | typedef struct Win32NativeWindow NativeWindow; | |
64 | ||
65 | #elif PLATFORM_UNIVERSAL_WINDOWS | |
66 | ||
67 | typedef struct UWPNativeWindow NativeWindow; | |
68 | ||
69 | #elif PLATFORM_ANDROID | |
70 | ||
71 | typedef struct AndroidNativeWindow NativeWindow; | |
72 | ||
73 | #elif PLATFORM_LINUX | |
74 | ||
75 | typedef struct LinuxNativeWindow NativeWindow; | |
76 | ||
77 | #elif PLATFORM_MACOS | |
78 | ||
79 | typedef struct MacOSNativeWindow NativeWindow; | |
80 | ||
81 | #elif PLATFORM_IOS | |
82 | ||
83 | typedef struct IOSNativeWindow NativeWindow; | |
84 | ||
85 | #else | |
86 | # 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. | |
87 | #endif | |
88 | ||
89 | DILIGENT_END_NAMESPACE // namespace Diligent⏎ |
115 | 115 | #endif |
116 | 116 | auto* pFactoryOpenGL = GetEngineFactoryOpenGL(); |
117 | 117 | EngineGLCreateInfo EngineCI; |
118 | EngineCI.pNativeWndHandle = NativeWindowHandle; | |
118 | EngineCI.Window.hWnd = NativeWindowHandle; | |
119 | 119 | pFactoryOpenGL->CreateDeviceAndSwapChainGL( |
120 | 120 | EngineCI, &m_pDevice, &m_pImmediateContext, SCDesc, &m_pSwapChain); |
121 | 121 | } |
216 | 216 | ```cpp |
217 | 217 | auto* pFactoryOpenGL = GetEngineFactoryOpenGL(); |
218 | 218 | EngineGLCreateInfo EngineCI; |
219 | EngineCI.pNativeWndHandle = NativeWindowHandle; | |
219 | EngineCI.NativeWindow.pAWindow = NativeWindowHandle; | |
220 | 220 | pFactoryOpenGL->CreateDeviceAndSwapChainGL( |
221 | 221 | EngineCI, &m_pDevice, &m_pContext, SCDesc, &m_pSwapChain); |
222 | 222 | IRenderDeviceGLES *pRenderDeviceOpenGLES; |
0 | 0 | ## Current Progress |
1 | 1 | |
2 | * Added `NativeWindow` wrapper and replaced `pNativeWndHandle` and `pDisplay` members with it in `EngineGLCreateInfo` (API Version 240053) | |
2 | 3 | * Added C Interface (API Version 240052) |
3 | 4 | |
4 | 5 | ## v2.4.d |
33 | 33 | #include "RefCntAutoPtr.hpp" |
34 | 34 | #include "SwapChain.h" |
35 | 35 | #include "GraphicsTypesOutputInserters.hpp" |
36 | #include "NativeWindow.h" | |
36 | 37 | |
37 | 38 | #include "gtest/gtest.h" |
38 | 39 | |
45 | 46 | class TestingEnvironment : public ::testing::Environment |
46 | 47 | { |
47 | 48 | public: |
48 | struct NativeWindow | |
49 | { | |
50 | void* NativeWindowHandle = nullptr; | |
51 | #if PLATFORM_LINUX | |
52 | void* Display = nullptr; | |
53 | #endif | |
54 | }; | |
49 | TestingEnvironment(RENDER_DEVICE_TYPE deviceType, ADAPTER_TYPE AdapterType, const SwapChainDesc& SCDesc); | |
55 | 50 | |
56 | ||
57 | TestingEnvironment(RENDER_DEVICE_TYPE deviceType, ADAPTER_TYPE AdapterType, const SwapChainDesc& SCDesc); | |
58 | 51 | ~TestingEnvironment() override; |
59 | 52 | |
60 | 53 | // Override this to define how to set up the environment. |
32 | 32 | namespace Testing |
33 | 33 | { |
34 | 34 | |
35 | TestingEnvironment::NativeWindow TestingEnvironment::CreateNativeWindow() | |
35 | NativeWindow TestingEnvironment::CreateNativeWindow() | |
36 | 36 | { |
37 | return TestingEnvironment::NativeWindow{}; | |
37 | return NativeWindow{}; | |
38 | 38 | } |
39 | 39 | |
40 | 40 | } // namespace Testing |
32 | 32 | namespace Testing |
33 | 33 | { |
34 | 34 | |
35 | TestingEnvironment::NativeWindow TestingEnvironment::CreateNativeWindow() | |
35 | NativeWindow TestingEnvironment::CreateNativeWindow() | |
36 | 36 | { |
37 | return TestingEnvironment::NativeWindow{}; | |
37 | return NativeWindow{}; | |
38 | 38 | } |
39 | 39 | |
40 | 40 | } // namespace Testing |
268 | 268 | # endif |
269 | 269 | auto* pFactoryOpenGL = GetEngineFactoryOpenGL(); |
270 | 270 | |
271 | auto NativeWnd = CreateNativeWindow(); | |
271 | NativeWindow Window = CreateNativeWindow(); | |
272 | 272 | |
273 | 273 | EngineGLCreateInfo CreateInfo; |
274 | 274 | CreateInfo.DebugMessageCallback = MessageCallback; |
275 | CreateInfo.pNativeWndHandle = NativeWnd.NativeWindowHandle; | |
276 | # if PLATFORM_LINUX | |
277 | CreateInfo.pDisplay = NativeWnd.Display; | |
278 | # endif | |
275 | CreateInfo.Window = Window; | |
276 | ||
279 | 277 | if (NumDeferredCtx != 0) |
280 | 278 | { |
281 | 279 | LOG_ERROR_MESSAGE("Deferred contexts are not supported in OpenGL mode"); |
37 | 37 | namespace Testing |
38 | 38 | { |
39 | 39 | |
40 | TestingEnvironment::NativeWindow TestingEnvironment::CreateNativeWindow() | |
40 | NativeWindow TestingEnvironment::CreateNativeWindow() | |
41 | 41 | { |
42 | 42 | #ifdef UNICODE |
43 | 43 | const auto* const WindowClassName = L"SampleApp"; |
61 | 61 | if (wnd == NULL) |
62 | 62 | LOG_ERROR_AND_THROW("Unable to create a window"); |
63 | 63 | |
64 | NativeWindow NativeWnd; | |
65 | NativeWnd.NativeWindowHandle = wnd; | |
64 | NativeWindow Window; | |
65 | Window.hWnd = wnd; | |
66 | 66 | |
67 | return NativeWnd; | |
67 | return Window; | |
68 | 68 | } |
69 | 69 | |
70 | 70 | } // namespace Testing |