mirror of
https://github.com/glfw/glfw.git
synced 2026-09-18 22:55:46 +00:00
Initial TLS implementation (Cocoa broken).
This commit is contained in:
+23
-5
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user