Initialize context creation APIs on demand
This commit is contained in:
parent
52d801bd19
commit
d5e00e6b0f
@ -325,9 +325,6 @@ int _glfwPlatformInit(void)
|
|||||||
if (!_glfwInitThreadLocalStoragePOSIX())
|
if (!_glfwInitThreadLocalStoragePOSIX())
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
|
|
||||||
if (!_glfwInitNSGL())
|
|
||||||
return GLFW_FALSE;
|
|
||||||
|
|
||||||
_glfwInitTimerNS();
|
_glfwInitTimerNS();
|
||||||
_glfwInitJoysticksNS();
|
_glfwInitJoysticksNS();
|
||||||
|
|
||||||
|
@ -1034,6 +1034,8 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
|||||||
{
|
{
|
||||||
if (ctxconfig->source == GLFW_NATIVE_CONTEXT_API)
|
if (ctxconfig->source == GLFW_NATIVE_CONTEXT_API)
|
||||||
{
|
{
|
||||||
|
if (!_glfwInitNSGL())
|
||||||
|
return GLFW_FALSE;
|
||||||
if (!_glfwCreateContextNSGL(window, ctxconfig, fbconfig))
|
if (!_glfwCreateContextNSGL(window, ctxconfig, fbconfig))
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
@ -296,6 +296,9 @@ GLFWbool _glfwInitEGL(void)
|
|||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (_glfw.egl.handle)
|
||||||
|
return GLFW_TRUE;
|
||||||
|
|
||||||
for (i = 0; sonames[i]; i++)
|
for (i = 0; sonames[i]; i++)
|
||||||
{
|
{
|
||||||
_glfw.egl.handle = _glfw_dlopen(sonames[i]);
|
_glfw.egl.handle = _glfw_dlopen(sonames[i]);
|
||||||
@ -358,6 +361,8 @@ GLFWbool _glfwInitEGL(void)
|
|||||||
{
|
{
|
||||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
"EGL: Failed to load required entry points");
|
"EGL: Failed to load required entry points");
|
||||||
|
|
||||||
|
_glfwTerminateEGL();
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,6 +253,9 @@ GLFWbool _glfwInitGLX(void)
|
|||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (_glfw.glx.handle)
|
||||||
|
return GLFW_TRUE;
|
||||||
|
|
||||||
for (i = 0; sonames[i]; i++)
|
for (i = 0; sonames[i]; i++)
|
||||||
{
|
{
|
||||||
_glfw.glx.handle = dlopen(sonames[i], RTLD_LAZY | RTLD_GLOBAL);
|
_glfw.glx.handle = dlopen(sonames[i], RTLD_LAZY | RTLD_GLOBAL);
|
||||||
|
@ -183,9 +183,6 @@ int _glfwPlatformInit(void)
|
|||||||
if (!_glfwInitThreadLocalStoragePOSIX())
|
if (!_glfwInitThreadLocalStoragePOSIX())
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
|
|
||||||
if (!_glfwInitEGL())
|
|
||||||
return GLFW_FALSE;
|
|
||||||
|
|
||||||
if (!_glfwInitJoysticksLinux())
|
if (!_glfwInitJoysticksLinux())
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
|
|
||||||
|
@ -379,6 +379,8 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
|||||||
|
|
||||||
if (ctxconfig->client != GLFW_NO_API)
|
if (ctxconfig->client != GLFW_NO_API)
|
||||||
{
|
{
|
||||||
|
if (!_glfwInitEGL())
|
||||||
|
return GLFW_FALSE;
|
||||||
if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig))
|
if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig))
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
@ -92,6 +92,9 @@ static void destroyContextNSGL(_GLFWwindow* window)
|
|||||||
//
|
//
|
||||||
GLFWbool _glfwInitNSGL(void)
|
GLFWbool _glfwInitNSGL(void)
|
||||||
{
|
{
|
||||||
|
if (_glfw.nsgl.framework)
|
||||||
|
return GLFW_TRUE;
|
||||||
|
|
||||||
_glfw.nsgl.framework =
|
_glfw.nsgl.framework =
|
||||||
CFBundleGetBundleWithIdentifier(CFSTR("com.apple.opengl"));
|
CFBundleGetBundleWithIdentifier(CFSTR("com.apple.opengl"));
|
||||||
if (_glfw.nsgl.framework == NULL)
|
if (_glfw.nsgl.framework == NULL)
|
||||||
|
@ -424,6 +424,9 @@ static void loadWGLExtensions(void)
|
|||||||
//
|
//
|
||||||
GLFWbool _glfwInitWGL(void)
|
GLFWbool _glfwInitWGL(void)
|
||||||
{
|
{
|
||||||
|
if (_glfw.wgl.instance)
|
||||||
|
return GLFW_TRUE;
|
||||||
|
|
||||||
_glfw.wgl.instance = LoadLibraryA("opengl32.dll");
|
_glfw.wgl.instance = LoadLibraryA("opengl32.dll");
|
||||||
if (!_glfw.wgl.instance)
|
if (!_glfw.wgl.instance)
|
||||||
{
|
{
|
||||||
|
@ -425,10 +425,6 @@ int _glfwPlatformInit(void)
|
|||||||
|
|
||||||
_glfwPlatformPollEvents();
|
_glfwPlatformPollEvents();
|
||||||
|
|
||||||
if (!_glfwInitWGL())
|
|
||||||
return GLFW_FALSE;
|
|
||||||
|
|
||||||
_glfwInitEGL();
|
|
||||||
_glfwInitTimerWin32();
|
_glfwInitTimerWin32();
|
||||||
_glfwInitJoysticksWin32();
|
_glfwInitJoysticksWin32();
|
||||||
|
|
||||||
|
@ -993,11 +993,15 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
|||||||
{
|
{
|
||||||
if (ctxconfig->source == GLFW_NATIVE_CONTEXT_API)
|
if (ctxconfig->source == GLFW_NATIVE_CONTEXT_API)
|
||||||
{
|
{
|
||||||
|
if (!_glfwInitWGL())
|
||||||
|
return GLFW_FALSE;
|
||||||
if (!_glfwCreateContextWGL(window, ctxconfig, fbconfig))
|
if (!_glfwCreateContextWGL(window, ctxconfig, fbconfig))
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (!_glfwInitEGL())
|
||||||
|
return GLFW_FALSE;
|
||||||
if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig))
|
if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig))
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
@ -600,9 +600,6 @@ int _glfwPlatformInit(void)
|
|||||||
if (!_glfwInitThreadLocalStoragePOSIX())
|
if (!_glfwInitThreadLocalStoragePOSIX())
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
|
|
||||||
if (!_glfwInitEGL())
|
|
||||||
return GLFW_FALSE;
|
|
||||||
|
|
||||||
if (!_glfwInitJoysticksLinux())
|
if (!_glfwInitJoysticksLinux())
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
|
|
||||||
|
@ -393,6 +393,8 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
|||||||
|
|
||||||
if (ctxconfig->client != GLFW_NO_API)
|
if (ctxconfig->client != GLFW_NO_API)
|
||||||
{
|
{
|
||||||
|
if (!_glfwInitEGL())
|
||||||
|
return GLFW_FALSE;
|
||||||
if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig))
|
if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig))
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
@ -765,13 +765,9 @@ int _glfwPlatformInit(void)
|
|||||||
if (!_glfwInitThreadLocalStoragePOSIX())
|
if (!_glfwInitThreadLocalStoragePOSIX())
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
|
|
||||||
if (!_glfwInitGLX())
|
|
||||||
return GLFW_FALSE;
|
|
||||||
|
|
||||||
if (!_glfwInitJoysticksLinux())
|
if (!_glfwInitJoysticksLinux())
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
|
|
||||||
_glfwInitEGL();
|
|
||||||
_glfwInitTimerPOSIX();
|
_glfwInitTimerPOSIX();
|
||||||
|
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
|
@ -1514,11 +1514,15 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
|||||||
{
|
{
|
||||||
if (ctxconfig->source == GLFW_NATIVE_CONTEXT_API)
|
if (ctxconfig->source == GLFW_NATIVE_CONTEXT_API)
|
||||||
{
|
{
|
||||||
|
if (!_glfwInitGLX())
|
||||||
|
return GLFW_FALSE;
|
||||||
if (!_glfwChooseVisualGLX(ctxconfig, fbconfig, &visual, &depth))
|
if (!_glfwChooseVisualGLX(ctxconfig, fbconfig, &visual, &depth))
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (!_glfwInitEGL())
|
||||||
|
return GLFW_FALSE;
|
||||||
if (!_glfwChooseVisualEGL(ctxconfig, fbconfig, &visual, &depth))
|
if (!_glfwChooseVisualEGL(ctxconfig, fbconfig, &visual, &depth))
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user