@@ -31,28 +31,30 @@ GLSharingFunctions::~GLSharingFunctions() {
3131}
3232
3333GLboolean 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+
5658 this ->pfnGlArbSyncObjectCleanup = cleanupArbSyncObject;
5759 this ->pfnGlArbSyncObjectSetup = setupArbSyncObject;
5860 this ->pfnGlArbSyncObjectSignal = signalArbSyncObject;
@@ -117,6 +119,12 @@ bool GLSharingFunctions::isOpenGlSharingSupported() {
117119 return true ;
118120}
119121
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+
120128void GLSharingFunctions::createBackupContext () {
121129 if (pfnWglCreateContext) {
122130 GLHGLRCHandleBkpCtx = pfnWglCreateContext (GLHDCHandle);
0 commit comments