-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathOpenGLModule.h
More file actions
executable file
·147 lines (120 loc) · 5.65 KB
/
OpenGLModule.h
File metadata and controls
executable file
·147 lines (120 loc) · 5.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
//==============================================================================
// Copyright (c) 2012-2016 Advanced Micro Devices, Inc. All rights reserved.
/// \author AMD Developer Tools
/// \file
/// \brief This class manages the dynamic loading of OpenGL.
//==============================================================================
#ifndef _OPENGL_MODULE_H_
#define _OPENGL_MODULE_H_
#include "DynamicLibraryModule.h"
#ifdef _WIN32
// WGL functions:
typedef int (WINAPI* wglChoosePixelFormat_fn)(HDC a, CONST PIXELFORMATDESCRIPTOR* b);
typedef BOOL(WINAPI* wglCopyContext_fn)(HGLRC a, HGLRC b, UINT c);
typedef HGLRC(WINAPI* wglCreateContext_fn)(HDC a);
typedef HGLRC(WINAPI* wglCreateLayerContext_fn)(HDC a, int b);
typedef BOOL(WINAPI* wglDeleteContext_fn)(HGLRC a);
typedef BOOL(WINAPI* wglDescribeLayerPlane_fn)(HDC a, int b, int c, UINT d, LPLAYERPLANEDESCRIPTOR e);
typedef int (WINAPI* wglDescribePixelFormat_fn)(HDC a, int b, UINT c, LPPIXELFORMATDESCRIPTOR d);
typedef HGLRC(WINAPI* wglGetCurrentContext_fn)(void);
typedef HDC(WINAPI* wglGetCurrentDC_fn)(void);
typedef PROC(WINAPI* wglGetDefaultProcAddress_fn)(LPCSTR a);
typedef int (WINAPI* wglGetLayerPaletteEntries_fn)(HDC a, int b, int c, int d, COLORREF* e);
typedef int (WINAPI* wglGetPixelFormat_fn)(HDC a);
typedef PROC(WINAPI* wglGetProcAddress_fn)(LPCSTR a);
typedef BOOL(WINAPI* wglMakeCurrent_fn)(HDC a, HGLRC b);
typedef BOOL(WINAPI* wglRealizeLayerPalette_fn)(HDC a, int b, BOOL c);
typedef int (WINAPI* wglSetLayerPaletteEntries_fn)(HDC a, int b, int c, int d, CONST COLORREF* e);
typedef BOOL(WINAPI* wglSetPixelFormat_fn)(HDC a, int b, CONST PIXELFORMATDESCRIPTOR* c);
typedef BOOL(WINAPI* wglShareLists_fn)(HGLRC a, HGLRC b);
typedef BOOL(WINAPI* wglSwapBuffers_fn)(HDC a);
typedef BOOL(WINAPI* wglSwapLayerBuffers_fn)(HDC hdc, UINT fuPlanes);
typedef DWORD(WINAPI* wglSwapMultipleBuffers_fn)(UINT a, const WGLSWAP* b);
typedef BOOL(WINAPI* wglUseFontBitmapsA_fn)(HDC a, DWORD b, DWORD c, DWORD d);
typedef BOOL(WINAPI* wglUseFontBitmapsW_fn)(HDC a, DWORD b, DWORD c, DWORD d);
typedef BOOL(WINAPI* wglUseFontOutlinesA_fn)(HDC a, DWORD b, DWORD c, DWORD d, FLOAT e, FLOAT f, int g, LPGLYPHMETRICSFLOAT h);
typedef BOOL(WINAPI* wglUseFontOutlinesW_fn)(HDC a, DWORD b, DWORD c, DWORD d, FLOAT e, FLOAT f, int g, LPGLYPHMETRICSFLOAT h);
// OGL functions:
typedef unsigned char GLubyte;
typedef unsigned int GLenum;
typedef const GLubyte* (WINAPI* glGetString_fn)(GLenum glEnum);
#else
// Linux code: should be added here.
#endif
/// This class handles the dynamic loading of OpenCL.dll.
/// \note There will typically be one of these objects.
/// That instance will be global.
/// There is a trap for the unwary.
/// The order of global ctors is only defined within a single compilation unit.
/// So, one should not use these interfaces before "main" is reached.
/// This is different than calling these functions when the .dll/.so is linked against.
class OpenGLModule
{
public:
/// Which shared image is loaded?
enum OpenGLVersion
{
OpenGL_None, ///< No OpenCL version is loaded
OpenGL_3_0, ///< OpenCL V3.0 is loaded
};
/// Default name to use for construction.
/// This is usually OpenGL.dll
static const char* s_DefaultModuleName;
/// Constructor
/// \param module to load.
OpenGLModule(const std::string& moduleName);
/// destructor
~OpenGLModule();
/// Checks id the module is loaded
bool IsModuleLoaded() const
{
return m_bIsModuleLoaded;
}
/// Unload OpenCL.dll
void UnloadModule();
/// Which OpenCL have we got?
/// \return enumeration value to answer query.
OpenGLVersion OpenGLLoaded();
// OpenGl functions
wglChoosePixelFormat_fn m_wglChoosePixelFormat_fn;
wglCopyContext_fn m_wglCopyContext_fn;
wglCreateContext_fn m_wglCreateContext_fn;
wglCreateLayerContext_fn m_wglCreateLayerContext_fn;
wglDeleteContext_fn m_wglDeleteContext_fn;
wglDescribeLayerPlane_fn m_wglDescribeLayerPlane_fn;
wglDescribePixelFormat_fn m_wglDescribePixelFormat_fn;
wglGetCurrentContext_fn m_wglGetCurrentContext_fn;
wglGetCurrentDC_fn m_wglGetCurrentDC_fn;
wglGetDefaultProcAddress_fn m_wglGetDefaultProcAddress_fn;
wglGetLayerPaletteEntries_fn m_wglGetLayerPaletteEntries_fn;
wglGetPixelFormat_fn m_wglGetPixelFormat_fn;
wglGetProcAddress_fn m_wglGetProcAddress_fn;
wglMakeCurrent_fn m_wglMakeCurrent_fn;
wglRealizeLayerPalette_fn m_wglRealizeLayerPalette_fn;
wglSetLayerPaletteEntries_fn m_wglSetLayerPaletteEntries_fn;
wglSetPixelFormat_fn m_wglSetPixelFormat_fn;
wglShareLists_fn m_wglShareLists_fn;
wglSwapBuffers_fn m_wglSwapBuffers_fn;
wglSwapLayerBuffers_fn m_wglSwapLayerBuffers_fn;
wglSwapMultipleBuffers_fn m_wglSwapMultipleBuffers_fn;
wglUseFontBitmapsA_fn m_wglUseFontBitmapsA_fn;
wglUseFontBitmapsW_fn m_wglUseFontBitmapsW_fn;
wglUseFontOutlinesA_fn m_wglUseFontOutlinesA_fn;
wglUseFontOutlinesW_fn m_wglUseFontOutlinesW_fn;
glGetString_fn m_glGetString_fn;
private:
/// Initialize the internal data
void Initialize();
/// Is module loaded
OpenGLVersion m_openGLVersion;
#ifdef _WIN32
typedef HMODULE ImageHandle_t;
#else
typedef void* ImageHandle_t;
#endif
/// Handle/pointer to .so/.dll.
ImageHandle_t m_Module;
std::string m_ModuleName;
bool m_bIsModuleLoaded;
};
#endif