@@ -31,28 +31,30 @@ GLSharingFunctions::~GLSharingFunctions() {
31
31
}
32
32
33
33
GLboolean GLSharingFunctions::initGLFunctions () {
34
- glLibrary.reset (OsLibrary::load (Os::openglDllName));
35
- if (glLibrary->isLoaded ()) {
36
- GLGetCurrentContext = (*glLibrary)[" wglGetCurrentContext" ];
37
- GLGetCurrentDisplay = (*glLibrary)[" wglGetCurrentDC" ];
38
- glGetString = (*glLibrary)[" glGetString" ];
39
- glGetIntegerv = (*glLibrary)[" glGetIntegerv" ];
40
- pfnWglCreateContext = (*glLibrary)[" wglCreateContext" ];
41
- pfnWglDeleteContext = (*glLibrary)[" wglDeleteContext" ];
42
- pfnWglShareLists = (*glLibrary)[" wglShareLists" ];
43
- GLSetSharedOCLContextState = (*glLibrary)[" wglSetSharedOCLContextStateINTEL" ];
44
- GLAcquireSharedBuffer = (*glLibrary)[" wglAcquireSharedBufferINTEL" ];
45
- GLReleaseSharedBuffer = (*glLibrary)[" wglReleaseSharedBufferINTEL" ];
46
- GLAcquireSharedRenderBuffer = (*glLibrary)[" wglAcquireSharedRenderBufferINTEL" ];
47
- GLReleaseSharedRenderBuffer = (*glLibrary)[" wglReleaseSharedRenderBufferINTEL" ];
48
- GLAcquireSharedTexture = (*glLibrary)[" wglAcquireSharedTextureINTEL" ];
49
- GLReleaseSharedTexture = (*glLibrary)[" wglReleaseSharedTextureINTEL" ];
50
- GLRetainSync = (*glLibrary)[" wglRetainSyncINTEL" ];
51
- GLReleaseSync = (*glLibrary)[" wglReleaseSyncINTEL" ];
52
- GLGetSynciv = (*glLibrary)[" wglGetSyncivINTEL" ];
53
- glGetStringi = (*glLibrary)[" glGetStringi" ];
54
- this ->wglMakeCurrent = (*glLibrary)[" wglMakeCurrent" ];
55
- }
34
+ GLGetCurrentContext = reinterpret_cast <PFNOGLGetCurrentContext>(loadGlFunction (" wglGetCurrentContext" , GLHDCType));
35
+ GLGetCurrentDisplay = reinterpret_cast <PFNOGLGetCurrentDisplay>(loadGlFunction (" wglGetCurrentDC" , GLHDCType));
36
+ glGetString = reinterpret_cast <PFNglGetString>(loadGlFunction (" glGetString" , GLHDCType));
37
+ glGetIntegerv = reinterpret_cast <PFNglGetIntegerv>(loadGlFunction (" glGetIntegerv" , GLHDCType));
38
+
39
+ pfnWglCreateContext = reinterpret_cast <PFNwglCreateContext>(loadGlFunction (" wglCreateContext" , GLHDCType));
40
+ pfnWglDeleteContext = reinterpret_cast <PFNwglDeleteContext>(loadGlFunction (" wglDeleteContext" , GLHDCType));
41
+
42
+ pfnWglShareLists = reinterpret_cast <PFNwglShareLists>(loadGlFunction (" wglShareLists" , GLHDCType));
43
+
44
+ auto wglGetProcAddressFuncPtr = reinterpret_cast <PROC (WINAPI *)(LPCSTR)>(loadGlFunction (" wglGetProcAddress" , GLHDCType));
45
+ GLSetSharedOCLContextState = reinterpret_cast <PFNOGLSetSharedOCLContextStateINTEL>(wglGetProcAddressFuncPtr (" wglSetSharedOCLContextStateINTEL" ));
46
+ GLAcquireSharedBuffer = reinterpret_cast <PFNOGLAcquireSharedBufferINTEL>(wglGetProcAddressFuncPtr (" wglAcquireSharedBufferINTEL" ));
47
+ GLReleaseSharedBuffer = reinterpret_cast <PFNOGLReleaseSharedBufferINTEL>(wglGetProcAddressFuncPtr (" wglReleaseSharedBufferINTEL" ));
48
+ GLAcquireSharedRenderBuffer = reinterpret_cast <PFNOGLAcquireSharedRenderBufferINTEL>(wglGetProcAddressFuncPtr (" wglAcquireSharedRenderBufferINTEL" ));
49
+ GLReleaseSharedRenderBuffer = reinterpret_cast <PFNOGLReleaseSharedRenderBufferINTEL>(wglGetProcAddressFuncPtr (" wglReleaseSharedRenderBufferINTEL" ));
50
+ GLAcquireSharedTexture = reinterpret_cast <PFNOGLAcquireSharedTextureINTEL>(wglGetProcAddressFuncPtr (" wglAcquireSharedTextureINTEL" ));
51
+ GLReleaseSharedTexture = reinterpret_cast <PFNOGLReleaseSharedTextureINTEL>(wglGetProcAddressFuncPtr (" wglReleaseSharedTextureINTEL" ));
52
+ GLRetainSync = reinterpret_cast <PFNOGLRetainSyncINTEL>(wglGetProcAddressFuncPtr (" wglRetainSyncINTEL" ));
53
+ GLReleaseSync = reinterpret_cast <PFNOGLReleaseSyncINTEL>(wglGetProcAddressFuncPtr (" wglReleaseSyncINTEL" ));
54
+ GLGetSynciv = reinterpret_cast <PFNOGLGetSyncivINTEL>(wglGetProcAddressFuncPtr (" wglGetSyncivINTEL" ));
55
+ glGetStringi = reinterpret_cast <PFNglGetStringi>(wglGetProcAddressFuncPtr (" glGetStringi" ));
56
+ this ->wglMakeCurrent = reinterpret_cast <PFNwglMakeCurrent>(loadGlFunction (" wglMakeCurrent" , GLHDCType));
57
+
56
58
this ->pfnGlArbSyncObjectCleanup = cleanupArbSyncObject;
57
59
this ->pfnGlArbSyncObjectSetup = setupArbSyncObject;
58
60
this ->pfnGlArbSyncObjectSignal = signalArbSyncObject;
@@ -117,6 +119,12 @@ bool GLSharingFunctions::isOpenGlSharingSupported() {
117
119
return true ;
118
120
}
119
121
122
+ void *GLSharingFunctions::loadGlFunction (const char *functionName, uint32_t hdc) {
123
+
124
+ HMODULE module = LoadLibraryA (Os::openglDllName);
125
+ return reinterpret_cast <PFNglGetString>(GetProcAddress (module, functionName));
126
+ }
127
+
120
128
void GLSharingFunctions::createBackupContext () {
121
129
if (pfnWglCreateContext) {
122
130
GLHGLRCHandleBkpCtx = pfnWglCreateContext (GLHDCHandle);
0 commit comments