Branimir Karadžić hace 5 años
padre
commit
2996246a90
Se han modificado 3 ficheros con 28 adiciones y 23 borrados
  1. 1 1
      src/glcontext_glx.cpp
  2. 15 15
      src/glcontext_html5.cpp
  3. 12 7
      src/glcontext_wgl.cpp

+ 1 - 1
src/glcontext_glx.cpp

@@ -86,7 +86,7 @@ namespace bgfx { namespace gl
 	template<typename ProtoT>
 	template<typename ProtoT>
 	static ProtoT glXGetProcAddress(const char* _name)
 	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)
 	void GlContext::create(uint32_t _width, uint32_t _height)

+ 15 - 15
src/glcontext_html5.cpp

@@ -183,21 +183,21 @@ namespace bgfx { namespace gl
 	{
 	{
 		BX_TRACE("Import:");
 		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"
 #	include "glimports.h"

+ 12 - 7
src/glcontext_wgl.cpp

@@ -23,6 +23,13 @@ namespace bgfx { namespace gl
 
 
 #	define GL_IMPORT(_optional, _proto, _func, _import) _proto _func
 #	define GL_IMPORT(_optional, _proto, _func, _import) _proto _func
 #	include "glimports.h"
 #	include "glimports.h"
+#	undef GL_IMPORT
+
+	template<typename ProtoT>
+	static ProtoT wglGetProc(const char* _name)
+	{
+		return reinterpret_cast<ProtoT>( (void*)wglGetProcAddress(_name) );
+	}
 
 
 	struct SwapChainGL
 	struct SwapChainGL
 	{
 	{
@@ -109,8 +116,6 @@ namespace bgfx { namespace gl
 		wglGetProcAddress = bx::dlsym<PFNWGLGETPROCADDRESSPROC>(m_opengl32dll, "wglGetProcAddress");
 		wglGetProcAddress = bx::dlsym<PFNWGLGETPROCADDRESSPROC>(m_opengl32dll, "wglGetProcAddress");
 		BGFX_FATAL(NULL != wglGetProcAddress, Fatal::UnableToInitialize, "Failed get wglGetProcAddress.");
 		BGFX_FATAL(NULL != wglGetProcAddress, Fatal::UnableToInitialize, "Failed get wglGetProcAddress.");
 
 
-
-
 		// If g_platformHooks.nwh is NULL, the assumption is that GL context was created
 		// If g_platformHooks.nwh is NULL, the assumption is that GL context was created
 		// by user (for example, using SDL, GLFW, etc.)
 		// by user (for example, using SDL, GLFW, etc.)
 		BX_WARN(NULL != g_platformData.nwh
 		BX_WARN(NULL != g_platformData.nwh
@@ -171,10 +176,10 @@ namespace bgfx { namespace gl
 
 
 			HGLRC context = createContext(hdc);
 			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)
 			if (NULL != wglGetExtensionsStringARB)
 			{
 			{
@@ -392,7 +397,7 @@ namespace bgfx { namespace gl
 		{                                                                                      \
 		{                                                                                      \
 			if (NULL == _func)                                                                 \
 			if (NULL == _func)                                                                 \
 			{                                                                                  \
 			{                                                                                  \
-				_func = bx::functionCast<_proto>(wglGetProcAddress(#_import) );                \
+				_func = wglGetProc<_proto>(#_import);                                          \
 				if (NULL == _func)                                                             \
 				if (NULL == _func)                                                             \
 				{                                                                              \
 				{                                                                              \
 					_func = bx::dlsym<_proto>(m_opengl32dll, #_import);                        \
 					_func = bx::dlsym<_proto>(m_opengl32dll, #_import);                        \