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:
Camilla Berglund
2014-03-30 14:37:20 +02:00
parent 2889f484f4
commit 78efc18079
16 changed files with 278 additions and 88 deletions
+6 -19
View File
@@ -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)