Diligent Engine API Reference: D:/GitHub/DiligentEngine/DiligentCore/Graphics/GraphicsEngineOpenGL/interface/RenderDeviceFactoryOpenGL.h Source File

Diligent Engine API Reference

RenderDeviceFactoryOpenGL.h
1 /* Copyright 2015-2018 Egor Yusov
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
10 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
11 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS.
12 *
13 * In no event and under no legal theory, whether in tort (including negligence),
14 * contract, or otherwise, unless required by applicable law (such as deliberate
15 * and grossly negligent acts) or agreed to in writing, shall any Contributor be
16 * liable for any damages, including any direct, indirect, special, incidental,
17 * or consequential damages of any character arising as a result of this License or
18 * out of the use or inability to use the software (including but not limited to damages
19 * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
20 * all other commercial damages or losses), even if such Contributor has been advised
21 * of the possibility of such damages.
22 */
23
24 #pragma once
25
28
29 #include "RenderDevice.h"
30 #include "DeviceContext.h"
31 #include "SwapChain.h"
32 #include "HLSL2GLSLConverter.h"
33
34 #if defined(PLATFORM_WIN32) || defined(PLATFORM_UNIVERSAL_WINDOWS)
35
36 # define API_QUALIFIER
37
38 #elif defined(PLATFORM_ANDROID) || defined(PLATFORM_LINUX)
39
40 # ifdef ENGINE_DLL
41 # ifdef BUILDING_DLL
42 // https://gcc.gnu.org/wiki/Visibility
43 # define API_QUALIFIER __attribute__((visibility("default")))
44 # else
45 # define API_QUALIFIER __attribute__((visibility("default")))
46 # endif
47 # else
48 # define API_QUALIFIER
49 # endif
50
51 #endif
52
53 namespace Diligent
54 {
55
56 class IEngineFactoryOpenGL
57 {
58 public:
59 virtual void CreateDeviceAndSwapChainGL(const EngineCreationAttribs& CreationAttribs,
60 IRenderDevice **ppDevice,
61 IDeviceContext **ppImmediateContext,
62 const SwapChainDesc& SCDesc,
63 void *pNativeWndHandle,
64 #if PLATFORM_LINUX
65 void *pDisplay,
66 #endif
67 ISwapChain **ppSwapChain ) = 0;
68 virtual void CreateHLSL2GLSLConverter(IHLSL2GLSLConverter **ppConverter) = 0;
69
70 virtual void AttachToActiveGLContext( const EngineCreationAttribs& CreationAttribs,
71 IRenderDevice **ppDevice,
72 IDeviceContext **ppImmediateContext ) = 0;
73 };
74
75 }
76
77 extern "C"
78 {
79
80 #if defined(ENGINE_DLL) && (defined(PLATFORM_WIN32) || defined(PLATFORM_UNIVERSAL_WINDOWS))
81
82 typedef Diligent::IEngineFactoryOpenGL* (*GetEngineFactoryOpenGLType)();
83
84 static bool LoadGraphicsEngineOpenGL(GetEngineFactoryOpenGLType &GetFactoryFunc)
85 {
86 GetFactoryFunc = nullptr;
87 std::string LibName = "GraphicsEngineOpenGL_";
88
89 #if _WIN64
90 LibName += "64";
91 #else
92 LibName += "32";
93 #endif
94
95 #ifdef _DEBUG
96 LibName += "d";
97 #else
98 LibName += "r";
99 #endif
100
101 LibName += ".dll";
102 auto hModule = LoadLibraryA( LibName.c_str() );
103 if( hModule == NULL )
104 {
105 LOG_ERROR_MESSAGE( "Failed to load ", LibName, " library." );
106 return false;
107 }
108
109 GetFactoryFunc = reinterpret_cast<GetEngineFactoryOpenGLType>( GetProcAddress(hModule, "GetEngineFactoryOpenGL") );
110 if( GetFactoryFunc == NULL )
111 {
112 LOG_ERROR_MESSAGE( "Failed to load GetEngineFactoryOpenGL() from ", LibName, " library." );
113 FreeLibrary( hModule );
114 return false;
115 }
116 return true;
117 }
118
119 #else
120
121 // Do not forget to call System.loadLibrary("GraphicsEngineOpenGL") in Java on Android!
122 API_QUALIFIER
123 Diligent::IEngineFactoryOpenGL* GetEngineFactoryOpenGL();
124 #endif
125 }
Diligent
Namespace for the OpenGL implementation of the graphics engine.
Definition: BufferD3D11Impl.h:34
Diligent::LoadGraphicsEngineOpenGL
void LoadGraphicsEngineOpenGL(GetEngineFactoryOpenGLType &GetFactoryFunc)
Loads OpenGL-based engine implementation and exports factory functions.
Definition: RenderDeviceFactoryOpenGL.cpp:230