mirror of
https://github.com/glfw/glfw.git
synced 2026-09-17 22:32:50 +00:00
Split out TLS code into separate modules.
This allows the TLS code to be re-used by partial ports like EGL.
This commit is contained in:
+6
-19
@@ -306,6 +306,9 @@ static GLboolean choosePixelFormat(_GLFWwindow* window,
|
||||
//
|
||||
int _glfwInitContextAPI(void)
|
||||
{
|
||||
if (!_glfwInitTLS())
|
||||
return GL_FALSE;
|
||||
|
||||
_glfw.wgl.opengl32.instance = LoadLibraryW(L"opengl32.dll");
|
||||
if (!_glfw.wgl.opengl32.instance)
|
||||
{
|
||||
@@ -313,16 +316,6 @@ int _glfwInitContextAPI(void)
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
_glfw.wgl.current = TlsAlloc();
|
||||
if (_glfw.wgl.current == TLS_OUT_OF_INDEXES)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"WGL: Failed to allocate TLS index");
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
_glfw.wgl.hasTLS = GL_TRUE;
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
@@ -330,11 +323,10 @@ int _glfwInitContextAPI(void)
|
||||
//
|
||||
void _glfwTerminateContextAPI(void)
|
||||
{
|
||||
if (_glfw.wgl.hasTLS)
|
||||
TlsFree(_glfw.wgl.current);
|
||||
|
||||
if (_glfw.wgl.opengl32.instance)
|
||||
FreeLibrary(_glfw.wgl.opengl32.instance);
|
||||
|
||||
_glfwTerminateTLS();
|
||||
}
|
||||
|
||||
#define setWGLattrib(attribName, attribValue) \
|
||||
@@ -588,12 +580,7 @@ void _glfwPlatformMakeContextCurrent(_GLFWwindow* window)
|
||||
else
|
||||
wglMakeCurrent(NULL, NULL);
|
||||
|
||||
TlsSetValue(_glfw.wgl.current, window);
|
||||
}
|
||||
|
||||
_GLFWwindow* _glfwPlatformGetCurrentContext(void)
|
||||
{
|
||||
return TlsGetValue(_glfw.wgl.current);
|
||||
_glfwSetCurrentContext(window);
|
||||
}
|
||||
|
||||
void _glfwPlatformSwapBuffers(_GLFWwindow* window)
|
||||
|
||||
Reference in New Issue
Block a user