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