Diligent Engine  v.2.4.g
EngineFactoryOpenGL.h
Go to the documentation of this file.
1 /*
2  * Copyright 2019-2021 Diligent Graphics LLC
3  * Copyright 2015-2019 Egor Yusov
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * In no event and under no legal theory, whether in tort (including negligence),
18  * contract, or otherwise, unless required by applicable law (such as deliberate
19  * and grossly negligent acts) or agreed to in writing, shall any Contributor be
20  * liable for any damages, including any direct, indirect, special, incidental,
21  * or consequential damages of any character arising as a result of this License or
22  * out of the use or inability to use the software (including but not limited to damages
23  * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
24  * all other commercial damages or losses), even if such Contributor has been advised
25  * of the possibility of such damages.
26  */
27 
28 #pragma once
29 
32 
33 #include "../../GraphicsEngine/interface/EngineFactory.h"
34 #include "../../GraphicsEngine/interface/RenderDevice.h"
35 #include "../../GraphicsEngine/interface/DeviceContext.h"
36 #include "../../GraphicsEngine/interface/SwapChain.h"
37 
38 #include "../../HLSL2GLSLConverterLib/interface/HLSL2GLSLConverter.h"
39 
40 
41 #if PLATFORM_ANDROID || PLATFORM_LINUX || PLATFORM_MACOS || PLATFORM_IOS || (PLATFORM_WIN32 && !defined(_MSC_VER))
42 // https://gcc.gnu.org/wiki/Visibility
43 # define API_QUALIFIER __attribute__((visibility("default")))
44 #elif PLATFORM_WIN32
45 # define API_QUALIFIER
46 #else
47 # error Unsupported platform
48 #endif
49 
50 #if ENGINE_DLL && PLATFORM_WIN32 && defined(_MSC_VER)
51 # include "../../GraphicsEngine/interface/LoadEngineDll.h"
52 # define EXPLICITLY_LOAD_ENGINE_GL_DLL 1
53 #endif
54 
56 
57 // {9BAAC767-02CC-4FFA-9E4B-E1340F572C49}
58 static const INTERFACE_ID IID_EngineFactoryOpenGL =
59  {0x9baac767, 0x2cc, 0x4ffa, {0x9e, 0x4b, 0xe1, 0x34, 0xf, 0x57, 0x2c, 0x49}};
60 
61 #define DILIGENT_INTERFACE_NAME IEngineFactoryOpenGL
62 #include "../../../Primitives/interface/DefineInterfaceHelperMacros.h"
63 
64 #define IEngineFactoryOpenGLInclusiveMethods \
65  IEngineFactoryInclusiveMethods; \
66  IEngineFactoryOpenGLMethods EngineFactoryOpenGL
67 
68 // clang-format off
69 
71 {
72  VIRTUAL void METHOD(CreateDeviceAndSwapChainGL)(THIS_
73  const EngineGLCreateInfo REF EngineCI,
74  IRenderDevice** ppDevice,
75  IDeviceContext** ppImmediateContext,
76  const SwapChainDesc REF SCDesc,
77  ISwapChain** ppSwapChain) PURE;
78 
79  VIRTUAL void METHOD(CreateHLSL2GLSLConverter)(THIS_
80  IHLSL2GLSLConverter** ppConverter) PURE;
81 
82  VIRTUAL void METHOD(AttachToActiveGLContext)(THIS_
83  const EngineGLCreateInfo REF EngineCI,
84  IRenderDevice** ppDevice,
85  IDeviceContext** ppImmediateContext) PURE;
86 };
88 
89 #include "../../../Primitives/interface/UndefInterfaceHelperMacros.h"
90 
91 #if DILIGENT_C_INTERFACE
92 
93 // clang-format off
94 
95 # define IEngineFactoryOpenGL_CreateDeviceAndSwapChainGL(This, ...) CALL_IFACE_METHOD(EngineFactoryOpenGL, CreateDeviceAndSwapChainGL, This, __VA_ARGS__)
96 # define IEngineFactoryOpenGL_CreateHLSL2GLSLConverter(This, ...) CALL_IFACE_METHOD(EngineFactoryOpenGL, CreateHLSL2GLSLConverter, This, __VA_ARGS__)
97 # define IEngineFactoryOpenGL_AttachToActiveGLContext(This, ...) CALL_IFACE_METHOD(EngineFactoryOpenGL, AttachToActiveGLContext, This, __VA_ARGS__)
98 
99 // clang-format on
100 
101 #endif
102 
103 
104 #if EXPLICITLY_LOAD_ENGINE_GL_DLL
105 
106 typedef struct IEngineFactoryOpenGL* (*GetEngineFactoryOpenGLType)();
107 
108 inline GetEngineFactoryOpenGLType DILIGENT_GLOBAL_FUNCTION(LoadGraphicsEngineOpenGL)()
109 {
110  return (GetEngineFactoryOpenGLType)LoadEngineDll("GraphicsEngineOpenGL", "GetEngineFactoryOpenGL");
111 }
112 
113 #else
114 
115 // Do not forget to call System.loadLibrary("GraphicsEngineOpenGL") in Java on Android!
117 struct IEngineFactoryOpenGL* DILIGENT_GLOBAL_FUNCTION(GetEngineFactoryOpenGL)();
118 
119 #endif
120 
121 DILIGENT_END_NAMESPACE // namespace Diligent
DILIGENT_END_INTERFACE
#define DILIGENT_END_INTERFACE
Definition: DefineInterfaceHelperMacros.h:88
Diligent::INTERFACE_ID
struct INTERFACE_ID INTERFACE_ID
Definition: InterfaceID.h:54
VIRTUAL
#define VIRTUAL
Definition: DefineInterfaceHelperMacros.h:83
DILIGENT_BEGIN_INTERFACE
#define DILIGENT_BEGIN_INTERFACE(Name, Base)
Definition: CommonDefinitions.h:97
API_QUALIFIER
#define API_QUALIFIER
Definition: EngineFactoryMtl.h:39
DILIGENT_GLOBAL_FUNCTION
#define DILIGENT_GLOBAL_FUNCTION(FuncName)
Definition: CommonDefinitions.h:95
Diligent::ISwapChain
Swap chain interface.
Definition: SwapChain.h:56
Diligent::IEngineFactoryOpenGL
Definition: EngineFactoryOpenGL.h:70
PURE
#define PURE
Definition: DefineInterfaceHelperMacros.h:85
Diligent::IRenderDevice
Render device interface.
Definition: RenderDevice.h:75
DILIGENT_END_NAMESPACE
#define DILIGENT_END_NAMESPACE
Definition: CommonDefinitions.h:86
Diligent::SwapChainDesc
Swap chain description.
Definition: GraphicsTypes.h:1347
Diligent::EngineGLCreateInfo
Attributes of the OpenGL-based engine implementation.
Definition: GraphicsTypes.h:2015
Diligent::LoadEngineDll
FARPROC LoadEngineDll(const char *EngineName, const char *GetFactoryFuncName)
Definition: LoadEngineDll.h:49
REF
#define REF
Definition: DefineGlobalFuncHelperMacros.h:39
METHOD
#define METHOD(Name)
Definition: DefineInterfaceHelperMacros.h:87
Diligent::IDeviceContext
Device context interface.
Definition: DeviceContext.h:1460
Diligent::GetEngineFactoryOpenGL
API_QUALIFIER struct IEngineFactoryOpenGL * GetEngineFactoryOpenGL()
Definition: EngineFactoryOpenGL.cpp:299
DILIGENT_BEGIN_NAMESPACE
#define DILIGENT_BEGIN_NAMESPACE(Name)
Definition: CommonDefinitions.h:82
Diligent::IEngineFactory
Engine factory base interface.
Definition: EngineFactory.h:60
Diligent::IHLSL2GLSLConverter
Interface to the buffer object implemented in OpenGL.
Definition: HLSL2GLSLConverter.h:91
Diligent
The library uses Direct3D-style math:
Definition: AdvancedMath.hpp:37
THIS_
#define THIS_
Definition: DefineInterfaceHelperMacros.h:82