This commit is contained in:
Branimir Karadžić 2020-09-08 07:42:03 -07:00
parent 73508ac80f
commit 2996246a90
3 changed files with 28 additions and 23 deletions

View File

@ -86,7 +86,7 @@ namespace bgfx { namespace gl
template<typename ProtoT>
static ProtoT glXGetProcAddress(const char* _name)
{
return bx::functionCast<ProtoT>( (void*)::glXGetProcAddress( (const GLubyte*)_name) );
return reinterpret_cast<ProtoT>( (void*)::glXGetProcAddress( (const GLubyte*)_name) );
}
void GlContext::create(uint32_t _width, uint32_t _height)

View File

@ -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<ProtoT><_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"

View File

@ -23,6 +23,13 @@ namespace bgfx { namespace gl
# define GL_IMPORT(_optional, _proto, _func, _import) _proto _func
# include "glimports.h"
# undef GL_IMPORT
template<typename ProtoT>
static ProtoT wglGetProc(const char* _name)
{
return reinterpret_cast<ProtoT>( (void*)wglGetProcAddress(_name) );
}
struct SwapChainGL
{
@ -109,8 +116,6 @@ namespace bgfx { namespace gl
wglGetProcAddress = bx::dlsym<PFNWGLGETPROCADDRESSPROC>(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<PFNWGLGETEXTENSIONSSTRINGARBPROC >(wglGetProcAddress("wglGetExtensionsStringARB") );
wglChoosePixelFormatARB = bx::functionCast<PFNWGLCHOOSEPIXELFORMATARBPROC >(wglGetProcAddress("wglChoosePixelFormatARB") );
wglCreateContextAttribsARB = bx::functionCast<PFNWGLCREATECONTEXTATTRIBSARBPROC>(wglGetProcAddress("wglCreateContextAttribsARB") );
wglSwapIntervalEXT = bx::functionCast<PFNWGLSWAPINTERVALEXTPROC >(wglGetProcAddress("wglSwapIntervalEXT") );
wglGetExtensionsStringARB = wglGetProc<PFNWGLGETEXTENSIONSSTRINGARBPROC >("wglGetExtensionsStringARB");
wglChoosePixelFormatARB = wglGetProc<PFNWGLCHOOSEPIXELFORMATARBPROC >("wglChoosePixelFormatARB");
wglCreateContextAttribsARB = wglGetProc<PFNWGLCREATECONTEXTATTRIBSARBPROC>("wglCreateContextAttribsARB");
wglSwapIntervalEXT = wglGetProc<PFNWGLSWAPINTERVALEXTPROC >("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); \