git.s-ol.nu forks/DiligentCore / dadb44e
Introduced NativeWindow wrapper for supported platforms Robert Campbell authored 3 years ago assiduous committed 3 years ago
28 changed file(s) with 371 addition(s) and 51 deletion(s). Raw diff Collapse all Expand all
3434 #include "../../../Primitives/interface/BasicTypes.h"
3535 #include "../../../Primitives/interface/DebugOutput.h"
3636 #include "../../../Primitives/interface/FlagEnum.h"
37 #include "../../../Platforms/interface/NativeWindow.h"
3738 #include "APIInfo.h"
3839
3940 /// Graphics engine namespace
13171318 };
13181319 typedef struct EngineCreateInfo EngineCreateInfo;
13191320
1320
13211321 /// Attributes of the OpenGL-based engine implementation
13221322 struct EngineGLCreateInfo DILIGENT_DERIVE(EngineCreateInfo)
13231323
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;
13351326 };
13361327 typedef struct EngineGLCreateInfo EngineGLCreateInfo;
13371328
236236 major_version_(0),
237237 minor_version_(0)
238238 {
239 auto* NativeWindow = reinterpret_cast<ANativeWindow*>(InitAttribs.pNativeWndHandle);
239 auto* NativeWindow = reinterpret_cast<ANativeWindow*>(InitAttribs.Window.pAWindow);
240240 Init(NativeWindow);
241241
242242 FillDeviceCaps(deviceCaps);
4545 //Or better yet, use the GL3 way to get the version number
4646 glGetIntegerv( GL_MAJOR_VERSION, &MajorVersion );
4747 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, ')');
4949
5050 // Under the standard filtering rules for cubemaps, filtering does not work across faces of the cubemap.
5151 // This results in a seam across the faces of a cubemap. This was a hardware limitation in the past, but
8686
8787 GLContext::GLContext(const EngineGLCreateInfo& InitAttribs, DeviceCaps& deviceCaps, const struct SwapChainDesc* /*pSCDesc*/) :
8888 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)
9191 {
9292 auto CurrentCtx = glXGetCurrentContext();
9393 if (CurrentCtx == 0)
100100 if (GLEW_OK != err)
101101 LOG_ERROR_AND_THROW("Failed to initialize GLEW");
102102
103 if (InitAttribs.pNativeWndHandle != nullptr && InitAttribs.pDisplay != nullptr)
103 if (InitAttribs.Window.pWindow != nullptr && InitAttribs.Window.pDisplay != nullptr)
104104 {
105105 //glXSwapIntervalEXT(0);
106106
126126 //Or better yet, use the GL3 way to get the version number
127127 glGetIntegerv(GL_MAJOR_VERSION, &MajorVersion);
128128 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, ')');
130130
131131 // Under the standard filtering rules for cubemaps, filtering does not work across faces of the cubemap.
132132 // This results in a seam across the faces of a cubemap. This was a hardware limitation in the past, but
7373 //Or better yet, use the GL3 way to get the version number
7474 glGetIntegerv( GL_MAJOR_VERSION, &MajorVersion );
7575 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, ')');
7777
7878 // Under the standard filtering rules for cubemaps, filtering does not work across faces of the cubemap.
7979 // This results in a seam across the faces of a cubemap. This was a hardware limitation in the past, but
103103 m_WindowHandleToDeviceContext{0}
104104 {
105105 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);
109109
110110 // See http://www.opengl.org/wiki/Tutorial:_OpenGL_3.1_The_First_Triangle_(C%2B%2B/Win)
111111 // http://www.opengl.org/wiki/Creating_an_OpenGL_Context_(WGL)
272272 //Or better yet, use the GL3 way to get the version number
273273 glGetIntegerv(GL_MAJOR_VERSION, &MajorVersion);
274274 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, ')');
276276
277277 // Under the standard filtering rules for cubemaps, filtering does not work across faces of the cubemap.
278278 // This results in a seam across the faces of a cubemap. This was a hardware limitation in the past, but
4242 m_DepthRenderBuffer(false),
4343 m_DefaultFBO(false)
4444 {
45 m_CALayer = InitAttribs.pNativeWndHandle;
45 m_CALayer = InitAttribs.Window.pNSView;
4646 InitRenderBuffers(true, m_SwapChainDesc.Width, m_SwapChainDesc.Height);
4747 CreateDummyBuffers(m_pRenderDevice.RawPtr<RenderDeviceGLImpl>());
4848 }
4747 // clang-format on
4848 {
4949 #if PLATFORM_WIN32
50 HWND hWnd = reinterpret_cast<HWND>(InitAttribs.pNativeWndHandle);
50 HWND hWnd = reinterpret_cast<HWND>(InitAttribs.Window.hWnd);
5151 RECT rc;
5252 GetClientRect(hWnd, &rc);
5353 m_SwapChainDesc.Width = rc.right - rc.left;
5454 m_SwapChainDesc.Height = rc.bottom - rc.top;
5555 #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);
5858
5959 XWindowAttributes XWndAttribs;
6060 XGetWindowAttributes(display, wnd, &XWndAttribs);
66 interface/AndroidFileSystem.hpp
77 interface/AndroidPlatformDefinitions.h
88 interface/AndroidPlatformMisc.hpp
9 interface/AndroidNativeWindow.hpp
910 )
1011
1112 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
00 cmake_minimum_required (VERSION 3.6)
11
22 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()
39
410 set(INTERFACE
511 interface/CFObjectWrapper.hpp
713 interface/AppleFileSystem.hpp
814 interface/ApplePlatformDefinitions.h
915 interface/ApplePlatformMisc.hpp
16 ${APPLE_NATIVE_WINDOW_H}
1017 )
1118
1219 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
99 ../interface/PlatformDebug.hpp
1010 ../interface/PlatformDefinitions.h
1111 ../interface/PlatformMisc.hpp
12 ../interface/NativeWindow.h
1213 )
1314
1415 add_subdirectory(Basic)
66 interface/LinuxFileSystem.hpp
77 interface/LinuxPlatformDefinitions.h
88 interface/LinuxPlatformMisc.hpp
9 interface/LinuxNativeWindow.hpp
910 )
1011
1112 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
55 interface/UWPDebug.hpp
66 interface/UWPFileSystem.hpp
77 interface/UWPDefinitions.h
8 interface/UWPNativeWindow.hpp
89 ../Win32/interface/Win32Atomics.hpp
910 )
1011
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
77 interface/Win32FileSystem.hpp
88 interface/Win32PlatformDefinitions.h
99 interface/Win32PlatformMisc.hpp
10 interface/Win32NativeWindow.hpp
1011 )
1112
1213 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
115115 #endif
116116 auto* pFactoryOpenGL = GetEngineFactoryOpenGL();
117117 EngineGLCreateInfo EngineCI;
118 EngineCI.pNativeWndHandle = NativeWindowHandle;
118 EngineCI.Window.hWnd = NativeWindowHandle;
119119 pFactoryOpenGL->CreateDeviceAndSwapChainGL(
120120 EngineCI, &m_pDevice, &m_pImmediateContext, SCDesc, &m_pSwapChain);
121121 }
216216 ```cpp
217217 auto* pFactoryOpenGL = GetEngineFactoryOpenGL();
218218 EngineGLCreateInfo EngineCI;
219 EngineCI.pNativeWndHandle = NativeWindowHandle;
219 EngineCI.NativeWindow.pAWindow = NativeWindowHandle;
220220 pFactoryOpenGL->CreateDeviceAndSwapChainGL(
221221 EngineCI, &m_pDevice, &m_pContext, SCDesc, &m_pSwapChain);
222222 IRenderDeviceGLES *pRenderDeviceOpenGLES;
00 ## Current Progress
11
2 * Added `NativeWindow` wrapper and replaced `pNativeWndHandle` and `pDisplay` members with it in `EngineGLCreateInfo` (API Version 240053)
23 * Added C Interface (API Version 240052)
34
45 ## v2.4.d
3333 #include "RefCntAutoPtr.hpp"
3434 #include "SwapChain.h"
3535 #include "GraphicsTypesOutputInserters.hpp"
36 #include "NativeWindow.h"
3637
3738 #include "gtest/gtest.h"
3839
4546 class TestingEnvironment : public ::testing::Environment
4647 {
4748 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);
5550
56
57 TestingEnvironment(RENDER_DEVICE_TYPE deviceType, ADAPTER_TYPE AdapterType, const SwapChainDesc& SCDesc);
5851 ~TestingEnvironment() override;
5952
6053 // Override this to define how to set up the environment.
3232 namespace Testing
3333 {
3434
35 TestingEnvironment::NativeWindow TestingEnvironment::CreateNativeWindow()
35 NativeWindow TestingEnvironment::CreateNativeWindow()
3636 {
37 return TestingEnvironment::NativeWindow{};
37 return NativeWindow{};
3838 }
3939
4040 } // namespace Testing
3232 namespace Testing
3333 {
3434
35 TestingEnvironment::NativeWindow TestingEnvironment::CreateNativeWindow()
35 NativeWindow TestingEnvironment::CreateNativeWindow()
3636 {
37 return TestingEnvironment::NativeWindow{};
37 return NativeWindow{};
3838 }
3939
4040 } // namespace Testing
268268 # endif
269269 auto* pFactoryOpenGL = GetEngineFactoryOpenGL();
270270
271 auto NativeWnd = CreateNativeWindow();
271 NativeWindow Window = CreateNativeWindow();
272272
273273 EngineGLCreateInfo CreateInfo;
274274 CreateInfo.DebugMessageCallback = MessageCallback;
275 CreateInfo.pNativeWndHandle = NativeWnd.NativeWindowHandle;
276 # if PLATFORM_LINUX
277 CreateInfo.pDisplay = NativeWnd.Display;
278 # endif
275 CreateInfo.Window = Window;
276
279277 if (NumDeferredCtx != 0)
280278 {
281279 LOG_ERROR_MESSAGE("Deferred contexts are not supported in OpenGL mode");
3737 namespace Testing
3838 {
3939
40 TestingEnvironment::NativeWindow TestingEnvironment::CreateNativeWindow()
40 NativeWindow TestingEnvironment::CreateNativeWindow()
4141 {
4242 #ifdef UNICODE
4343 const auto* const WindowClassName = L"SampleApp";
6161 if (wnd == NULL)
6262 LOG_ERROR_AND_THROW("Unable to create a window");
6363
64 NativeWindow NativeWnd;
65 NativeWnd.NativeWindowHandle = wnd;
64 NativeWindow Window;
65 Window.hWnd = wnd;
6666
67 return NativeWnd;
67 return Window;
6868 }
6969
7070 } // namespace Testing