WGL: Skip context initialization when window is not set.

This commit is contained in:
bkaradzic 2013-08-10 21:26:56 -07:00
parent d265b9b0d4
commit e047232292

View File

@ -78,6 +78,15 @@ namespace bgfx
wglGetProcAddress = (PFNWGLGETPROCADDRESSPROC)bx::dlsym(m_opengl32dll, "wglGetProcAddress");
BGFX_FATAL(NULL != wglGetProcAddress, Fatal::UnableToInitialize, "Failed get wglGetProcAddress.");
// If g_bgfxHwnd is NULL, the assumption is that GL context was created
// by user (for example, using SDL, GLFW, etc.)
BX_WARN(NULL != g_bgfxHwnd
, "bgfx::winSetHwnd with valid window is not called. This might "
"be intentional when GL context is created by the user."
);
if (NULL != g_bgfxHwnd)
{
wglMakeCurrent = (PFNWGLMAKECURRENTPROC)bx::dlsym(m_opengl32dll, "wglMakeCurrent");
BGFX_FATAL(NULL != wglMakeCurrent, Fatal::UnableToInitialize, "Failed get wglMakeCurrent.");
@ -220,11 +229,14 @@ namespace bgfx
{
wglSwapIntervalEXT(0);
}
}
import();
}
void GlContext::destroy()
{
if (NULL != g_bgfxHwnd)
{
wglMakeCurrent(NULL, NULL);
@ -233,6 +245,7 @@ namespace bgfx
ReleaseDC(g_bgfxHwnd, m_hdc);
m_hdc = NULL;
}
bx::dlclose(m_opengl32dll);
m_opengl32dll = NULL;
@ -247,10 +260,13 @@ namespace bgfx
}
void GlContext::swap()
{
if (NULL != g_bgfxHwnd)
{
wglMakeCurrent(m_hdc, m_context);
SwapBuffers(m_hdc);
}
}
void GlContext::import()
{