00001 //======================================================================== 00002 // GLFW 3.1 Win32 - www.glfw.org 00003 //------------------------------------------------------------------------ 00004 // Copyright (c) 2002-2006 Marcus Geelnard 00005 // Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org> 00006 // 00007 // This software is provided 'as-is', without any express or implied 00008 // warranty. In no event will the authors be held liable for any damages 00009 // arising from the use of this software. 00010 // 00011 // Permission is granted to anyone to use this software for any purpose, 00012 // including commercial applications, and to alter it and redistribute it 00013 // freely, subject to the following restrictions: 00014 // 00015 // 1. The origin of this software must not be misrepresented; you must not 00016 // claim that you wrote the original software. If you use this software 00017 // in a product, an acknowledgment in the product documentation would 00018 // be appreciated but is not required. 00019 // 00020 // 2. Altered source versions must be plainly marked as such, and must not 00021 // be misrepresented as being the original software. 00022 // 00023 // 3. This notice may not be removed or altered from any source 00024 // distribution. 00025 // 00026 //======================================================================== 00027 00028 #include "internal.h" 00029 00030 00034 00035 int _glfwCreateContextTLS(void) 00036 { 00037 _glfw.win32_tls.context = TlsAlloc(); 00038 if (_glfw.win32_tls.context == TLS_OUT_OF_INDEXES) 00039 { 00040 _glfwInputError(GLFW_PLATFORM_ERROR, 00041 "Win32: Failed to allocate TLS index"); 00042 return GL_FALSE; 00043 } 00044 00045 _glfw.win32_tls.allocated = GL_TRUE; 00046 return GL_TRUE; 00047 } 00048 00049 void _glfwDestroyContextTLS(void) 00050 { 00051 if (_glfw.win32_tls.allocated) 00052 TlsFree(_glfw.win32_tls.context); 00053 } 00054 00055 void _glfwSetContextTLS(_GLFWwindow* context) 00056 { 00057 TlsSetValue(_glfw.win32_tls.context, context); 00058 } 00059 00060 00064 00065 _GLFWwindow* _glfwPlatformGetCurrentContext(void) 00066 { 00067 return TlsGetValue(_glfw.win32_tls.context); 00068 } 00069