diff --git a/src/glcontext_glx.cpp b/src/glcontext_glx.cpp index 9afd42345..ac045782f 100644 --- a/src/glcontext_glx.cpp +++ b/src/glcontext_glx.cpp @@ -86,7 +86,7 @@ namespace bgfx { namespace gl template static ProtoT glXGetProcAddress(const char* _name) { - return bx::functionCast( (void*)::glXGetProcAddress( (const GLubyte*)_name) ); + return reinterpret_cast( (void*)::glXGetProcAddress( (const GLubyte*)_name) ); } void GlContext::create(uint32_t _width, uint32_t _height) diff --git a/src/glcontext_html5.cpp b/src/glcontext_html5.cpp index 473512d95..3a6475e6a 100644 --- a/src/glcontext_html5.cpp +++ b/src/glcontext_html5.cpp @@ -183,21 +183,21 @@ namespace bgfx { namespace gl { BX_TRACE("Import:"); -# define GL_EXTENSION(_optional, _proto, _func, _import) \ - { \ - if (NULL == _func) \ - { \ - _func = (_proto)emscripten_webgl1_get_proc_address(#_import); \ - if (!_func && webGLVersion >= 2) \ - { \ - _func = bx::functionCast<_proto>(emscripten_webgl2_get_proc_address(#_import); \ - } \ - BX_TRACE("\t%p " #_func " (" #_import ")", _func); \ - BGFX_FATAL(_optional || NULL != _func, Fatal::UnableToInitialize \ - , "Failed to create WebGL/OpenGLES context. GetProcAddress(\"%s\")" \ - , #_import \ - ); \ - } \ +# define GL_EXTENSION(_optional, _proto, _func, _import) \ + { \ + if (NULL == _func) \ + { \ + _func = (_proto)emscripten_webgl1_get_proc_address(#_import); \ + if (!_func && webGLVersion >= 2) \ + { \ + _func = reinterpret_cast<_proto>(emscripten_webgl2_get_proc_address(#_import); \ + } \ + BX_TRACE("\t%p " #_func " (" #_import ")", _func); \ + BGFX_FATAL(_optional || NULL != _func, Fatal::UnableToInitialize \ + , "Failed to create WebGL/OpenGLES context. GetProcAddress(\"%s\")" \ + , #_import \ + ); \ + } \ } # include "glimports.h" diff --git a/src/glcontext_wgl.cpp b/src/glcontext_wgl.cpp index 6fa51cad2..10a9a6fbc 100644 --- a/src/glcontext_wgl.cpp +++ b/src/glcontext_wgl.cpp @@ -23,6 +23,13 @@ namespace bgfx { namespace gl # define GL_IMPORT(_optional, _proto, _func, _import) _proto _func # include "glimports.h" +# undef GL_IMPORT + + template + static ProtoT wglGetProc(const char* _name) + { + return reinterpret_cast( (void*)wglGetProcAddress(_name) ); + } struct SwapChainGL { @@ -109,8 +116,6 @@ namespace bgfx { namespace gl wglGetProcAddress = bx::dlsym(m_opengl32dll, "wglGetProcAddress"); BGFX_FATAL(NULL != wglGetProcAddress, Fatal::UnableToInitialize, "Failed get wglGetProcAddress."); - - // If g_platformHooks.nwh is NULL, the assumption is that GL context was created // by user (for example, using SDL, GLFW, etc.) BX_WARN(NULL != g_platformData.nwh @@ -171,10 +176,10 @@ namespace bgfx { namespace gl HGLRC context = createContext(hdc); - wglGetExtensionsStringARB = bx::functionCast(wglGetProcAddress("wglGetExtensionsStringARB") ); - wglChoosePixelFormatARB = bx::functionCast(wglGetProcAddress("wglChoosePixelFormatARB") ); - wglCreateContextAttribsARB = bx::functionCast(wglGetProcAddress("wglCreateContextAttribsARB") ); - wglSwapIntervalEXT = bx::functionCast(wglGetProcAddress("wglSwapIntervalEXT") ); + wglGetExtensionsStringARB = wglGetProc("wglGetExtensionsStringARB"); + wglChoosePixelFormatARB = wglGetProc("wglChoosePixelFormatARB"); + wglCreateContextAttribsARB = wglGetProc("wglCreateContextAttribsARB"); + wglSwapIntervalEXT = wglGetProc("wglSwapIntervalEXT"); if (NULL != wglGetExtensionsStringARB) { @@ -392,7 +397,7 @@ namespace bgfx { namespace gl { \ if (NULL == _func) \ { \ - _func = bx::functionCast<_proto>(wglGetProcAddress(#_import) ); \ + _func = wglGetProc<_proto>(#_import); \ if (NULL == _func) \ { \ _func = bx::dlsym<_proto>(m_opengl32dll, #_import); \