Initial TLS implementation (Cocoa broken).

This commit is contained in:
Camilla Berglund
2012-08-12 14:13:18 +02:00
parent d0c7a7a2c4
commit 9e4bc36dd8
6 changed files with 78 additions and 20 deletions
+23 -5
View File
@@ -31,6 +31,12 @@
#include "internal.h"
//========================================================================
// The per-thread current context/window pointer
//========================================================================
__declspec(thread) _GLFWwindow* _glfwCurrentWindow = NULL;
//========================================================================
// Initialize WGL-specific extensions
// This function is called once before initial context creation, i.e. before
@@ -438,7 +444,7 @@ static GLboolean createContext(_GLFWwindow* window,
}
}
glfwMakeContextCurrent(window);
_glfwPlatformMakeContextCurrent(window);
initWGLExtensions(window);
return GL_TRUE;
@@ -507,8 +513,8 @@ void _glfwDestroyContext(_GLFWwindow* window)
{
// This is duplicated from glfwDestroyWindow
// TODO: Stop duplicating code
if (window == _glfwLibrary.currentWindow)
glfwMakeContextCurrent(NULL);
if (window == _glfwCurrentWindow)
_glfwPlatformMakeContextCurrent(NULL);
if (window->WGL.context)
{
@@ -538,6 +544,18 @@ void _glfwPlatformMakeContextCurrent(_GLFWwindow* window)
wglMakeCurrent(window->WGL.DC, window->WGL.context);
else
wglMakeCurrent(NULL, NULL);
_glfwCurrentWindow = window;
}
//========================================================================
// Return the window object whose context is current
//========================================================================
_GLFWwindow* _glfwPlatformGetCurrentContext(void)
{
return _glfwCurrentWindow;
}
@@ -557,7 +575,7 @@ void _glfwPlatformSwapBuffers(_GLFWwindow* window)
void _glfwPlatformSwapInterval(int interval)
{
_GLFWwindow* window = _glfwLibrary.currentWindow;
_GLFWwindow* window = _glfwCurrentWindow;
if (window->WGL.EXT_swap_control)
window->WGL.SwapIntervalEXT(interval);
@@ -572,7 +590,7 @@ int _glfwPlatformExtensionSupported(const char* extension)
{
const GLubyte* extensions;
_GLFWwindow* window = _glfwLibrary.currentWindow;
_GLFWwindow* window = _glfwCurrentWindow;
if (window->WGL.GetExtensionsStringEXT != NULL)
{