diff --git a/include/GL/glfw3.h b/include/GL/glfw3.h
index cba9e9b7..1836d134 100644
--- a/include/GL/glfw3.h
+++ b/include/GL/glfw3.h
@@ -537,9 +537,7 @@ GLFWAPI void glfwSetGammaRamp(const GLFWgammaramp* ramp);
/* Window handling */
GLFWAPI GLFWwindow glfwOpenWindow(int width, int height, int mode, const char* title, GLFWwindow share);
GLFWAPI void glfwOpenWindowHint(int target, int hint);
-GLFWAPI void glfwMakeWindowCurrent(GLFWwindow window);
GLFWAPI int glfwIsWindow(GLFWwindow window);
-GLFWAPI GLFWwindow glfwGetCurrentWindow(void);
GLFWAPI void glfwCloseWindow(GLFWwindow window);
GLFWAPI void glfwSetWindowTitle(GLFWwindow, const char* title);
GLFWAPI void glfwGetWindowSize(GLFWwindow, int* width, int* height);
@@ -583,11 +581,13 @@ GLFWAPI double glfwGetTime(void);
GLFWAPI void glfwSetTime(double time);
/* OpenGL support */
+GLFWAPI void glfwMakeContextCurrent(GLFWwindow window);
+GLFWAPI GLFWwindow glfwGetCurrentContext(void);
GLFWAPI void glfwSwapBuffers(void);
GLFWAPI void glfwSwapInterval(int interval);
GLFWAPI int glfwExtensionSupported(const char* extension);
GLFWAPI void* glfwGetProcAddress(const char* procname);
-GLFWAPI void glfwCopyGLState(GLFWwindow src, GLFWwindow dst, unsigned long mask);
+GLFWAPI void glfwCopyContext(GLFWwindow src, GLFWwindow dst, unsigned long mask);
/* Enable/disable functions */
GLFWAPI void glfwEnable(GLFWwindow window, int token);
diff --git a/readme.html b/readme.html
index d1d4b031..481444d0 100644
--- a/readme.html
+++ b/readme.html
@@ -263,7 +263,7 @@ version of GLFW.
- Added
GLFWwindow
window handle type and updated window-related functions and callbacks to take a window handle
- Added
glfwIsWindow
function for verifying that a given window handle is (still) valid
- - Added
glfwMakeWindowCurrent
function for making the context of the specified window current
+ - Added
glfwMakeContextCurrent
function for making the context of the specified window current
- Added
glfwGetError
and glfwErrorString
error reporting functions and a number of error tokens
- Added
glfwSetErrorCallback
function and GLFWerrorfun
type for receiving more specific and/or nested errors
- Added
glfwSetWindowUserPointer
and glfwGetWindowUserPointer
functions for per-window user pointers
@@ -271,9 +271,9 @@ version of GLFW.
- Added
glfwGetWindowPos
function for querying the position of the specified window
- Added
glfwSetWindowFocusCallback
function and GLFWwindowfocusfun
type for receiving window focus events
- Added
glfwSetWindowIconifyCallback
function and GLFWwindowiconifyfun
type for receiving window iconification events
- - Added
glfwGetCurrentWindow
function for retrieving the window whose OpenGL context is current
+ - Added
glfwGetCurrentContext
function for retrieving the window whose OpenGL context is current
- Added
glfwInitWithModels
function and GLFWallocator
and GLFWthreadmodel
types for pluggable memory allocation and threading models
- - Added
glfwCopyGLState
function for copying OpenGL state categories between contexts
+ - Added
glfwCopyContext
function for copying OpenGL state categories between contexts
- Added
GLFW_OPENGL_ES2_PROFILE
profile for creating OpenGL ES 2.0 contexts using the GLX_EXT_create_context_es2_profile
and WGL_EXT_create_context_es2_profile
extensions
- Added
GLFW_OPENGL_ROBUSTNESS
window hint and associated strategy tokens for GL_ARB_robustness
support
- Added
GLFW_OPENGL_REVISION
window parameter to make up for removal of glfwGetGLVersion
diff --git a/src/cocoa_opengl.m b/src/cocoa_opengl.m
index 6d93ed9f..bd3827fc 100644
--- a/src/cocoa_opengl.m
+++ b/src/cocoa_opengl.m
@@ -34,6 +34,19 @@
////// GLFW platform API //////
//////////////////////////////////////////////////////////////////////////
+//========================================================================
+// Make the OpenGL context associated with the specified window current
+//========================================================================
+
+void _glfwPlatformMakeContextCurrent(_GLFWwindow* window)
+{
+ if (window)
+ [window->NSGL.context makeCurrentContext];
+ else
+ [NSOpenGLContext clearCurrentContext];
+}
+
+
//========================================================================
// Swap buffers
//========================================================================
@@ -90,7 +103,7 @@ void* _glfwPlatformGetProcAddress(const char* procname)
// Copies the specified OpenGL state categories from src to dst
//========================================================================
-void _glfwPlatformCopyGLState(_GLFWwindow* src, _GLFWwindow* dst, unsigned long mask)
+void _glfwPlatformCopyContext(_GLFWwindow* src, _GLFWwindow* dst, unsigned long mask)
{
[dst->NSGL.context copyAttributesFromContext:src->NSGL.context withMask:mask];
}
diff --git a/src/cocoa_window.m b/src/cocoa_window.m
index 283eae32..df2f708f 100644
--- a/src/cocoa_window.m
+++ b/src/cocoa_window.m
@@ -675,7 +675,7 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
withOptions:nil];
}
- glfwMakeWindowCurrent(window);
+ glfwMakeContextCurrent(window);
NSPoint point = [[NSCursor currentCursor] hotSpot];
window->mousePosX = point.x;
@@ -686,18 +686,6 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
return GL_TRUE;
}
-//========================================================================
-// Make the OpenGL context associated with the specified window current
-//========================================================================
-
-void _glfwPlatformMakeWindowCurrent(_GLFWwindow* window)
-{
- if (window)
- [window->NSGL.context makeCurrentContext];
- else
- [NSOpenGLContext clearCurrentContext];
-}
-
//========================================================================
// Properly kill the window / video display
diff --git a/src/internal.h b/src/internal.h
index 2c49aa2b..19bf299a 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -296,7 +296,6 @@ void _glfwPlatformSetTime(double time);
// Window management
int _glfwPlatformOpenWindow(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWfbconfig* fbconfig);
-void _glfwPlatformMakeWindowCurrent(_GLFWwindow* window);
void _glfwPlatformCloseWindow(_GLFWwindow* window);
void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title);
void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height);
@@ -312,12 +311,13 @@ void _glfwPlatformPollEvents(void);
void _glfwPlatformWaitEvents(void);
// OpenGL context management
+void _glfwPlatformMakeContextCurrent(_GLFWwindow* window);
void _glfwPlatformSwapBuffers(void);
void _glfwPlatformSwapInterval(int interval);
void _glfwPlatformRefreshWindowParams(void);
int _glfwPlatformExtensionSupported(const char* extension);
void* _glfwPlatformGetProcAddress(const char* procname);
-void _glfwPlatformCopyGLState(_GLFWwindow* src, _GLFWwindow* dst, unsigned long mask);
+void _glfwPlatformCopyContext(_GLFWwindow* src, _GLFWwindow* dst, unsigned long mask);
//========================================================================
diff --git a/src/opengl.c b/src/opengl.c
index 5e465f4a..9b39d0e7 100644
--- a/src/opengl.c
+++ b/src/opengl.c
@@ -423,6 +423,44 @@ int _glfwStringInExtensionString(const char* string,
////// GLFW public API //////
//////////////////////////////////////////////////////////////////////////
+//========================================================================
+// Make the OpenGL context associated with the specified window current
+//========================================================================
+
+GLFWAPI void glfwMakeContextCurrent(GLFWwindow handle)
+{
+ _GLFWwindow* window = (_GLFWwindow*) handle;
+
+ if (!_glfwInitialized)
+ {
+ _glfwSetError(GLFW_NOT_INITIALIZED, NULL);
+ return;
+ }
+
+ if (_glfwLibrary.currentWindow == window)
+ return;
+
+ _glfwPlatformMakeContextCurrent(window);
+ _glfwLibrary.currentWindow = window;
+}
+
+
+//========================================================================
+// Returns the window whose OpenGL context is current
+//========================================================================
+
+GLFWAPI GLFWwindow glfwGetCurrentContext(void)
+{
+ if (!_glfwInitialized)
+ {
+ _glfwSetError(GLFW_NOT_INITIALIZED, NULL);
+ return GL_FALSE;
+ }
+
+ return _glfwLibrary.currentWindow;
+}
+
+
//========================================================================
// Swap buffers (double-buffering)
//========================================================================
@@ -560,7 +598,7 @@ GLFWAPI void* glfwGetProcAddress(const char* procname)
// Copies the specified OpenGL state categories from src to dst
//========================================================================
-GLFWAPI void glfwCopyGLState(GLFWwindow hsrc, GLFWwindow hdst, unsigned long mask)
+GLFWAPI void glfwCopyContext(GLFWwindow hsrc, GLFWwindow hdst, unsigned long mask)
{
_GLFWwindow* src;
_GLFWwindow* dst;
@@ -580,6 +618,6 @@ GLFWAPI void glfwCopyGLState(GLFWwindow hsrc, GLFWwindow hdst, unsigned long mas
return;
}
- _glfwPlatformCopyGLState(src, dst, mask);
+ _glfwPlatformCopyContext(src, dst, mask);
}
diff --git a/src/win32_opengl.c b/src/win32_opengl.c
index d729fb51..e60d1e70 100644
--- a/src/win32_opengl.c
+++ b/src/win32_opengl.c
@@ -35,6 +35,19 @@
////// GLFW platform API //////
//////////////////////////////////////////////////////////////////////////
+//========================================================================
+// Make the OpenGL context associated with the specified window current
+//========================================================================
+
+void _glfwPlatformMakeContextCurrent(_GLFWwindow* window)
+{
+ if (window)
+ wglMakeCurrent(window->WGL.DC, window->WGL.context);
+ else
+ wglMakeCurrent(NULL, NULL);
+}
+
+
//========================================================================
// Swap buffers (double-buffering)
//========================================================================
@@ -108,7 +121,7 @@ void* _glfwPlatformGetProcAddress(const char* procname)
// Copies the specified OpenGL state categories from src to dst
//========================================================================
-void _glfwPlatformCopyGLState(_GLFWwindow* src, _GLFWwindow* dst, unsigned long mask)
+void _glfwPlatformCopyContext(_GLFWwindow* src, _GLFWwindow* dst, unsigned long mask)
{
if (!wglCopyContext(src->WGL.context, dst->WGL.context, mask))
_glfwSetError(GLFW_PLATFORM_ERROR, "Win32/WGL: Failed to copy OpenGL context attributes");
diff --git a/src/win32_window.c b/src/win32_window.c
index 23633105..56b5908e 100644
--- a/src/win32_window.c
+++ b/src/win32_window.c
@@ -1342,7 +1342,7 @@ static int createWindow(_GLFWwindow* window,
if (!createContext(window, wndconfig, pixelFormat))
return GL_FALSE;
- glfwMakeWindowCurrent(window);
+ glfwMakeContextCurrent(window);
initWGLExtensions(window);
@@ -1365,7 +1365,7 @@ static void destroyWindow(_GLFWwindow* window)
// This is duplicated from glfwCloseWindow
// TODO: Stop duplicating code
if (window == _glfwLibrary.currentWindow)
- glfwMakeWindowCurrent(NULL);
+ glfwMakeContextCurrent(NULL);
// This is duplicated from glfwCloseWindow
// TODO: Stop duplicating code
@@ -1521,19 +1521,6 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
}
-//========================================================================
-// Make the OpenGL context associated with the specified window current
-//========================================================================
-
-void _glfwPlatformMakeWindowCurrent(_GLFWwindow* window)
-{
- if (window)
- wglMakeCurrent(window->WGL.DC, window->WGL.context);
- else
- wglMakeCurrent(NULL, NULL);
-}
-
-
//========================================================================
// Properly kill the window / video display
//========================================================================
diff --git a/src/window.c b/src/window.c
index 156460d0..9c985b13 100644
--- a/src/window.c
+++ b/src/window.c
@@ -336,7 +336,7 @@ GLFWAPI GLFWwindow glfwOpenWindow(int width, int height,
}
// Cache the actual (as opposed to desired) window parameters
- glfwMakeWindowCurrent(window);
+ glfwMakeContextCurrent(window);
_glfwPlatformRefreshWindowParams();
if (!_glfwIsValidContext(window, &wndconfig))
@@ -359,28 +359,6 @@ GLFWAPI GLFWwindow glfwOpenWindow(int width, int height,
}
-//========================================================================
-// Make the OpenGL context associated with the specified window current
-//========================================================================
-
-GLFWAPI void glfwMakeWindowCurrent(GLFWwindow handle)
-{
- _GLFWwindow* window = (_GLFWwindow*) handle;
-
- if (!_glfwInitialized)
- {
- _glfwSetError(GLFW_NOT_INITIALIZED, NULL);
- return;
- }
-
- if (_glfwLibrary.currentWindow == window)
- return;
-
- _glfwPlatformMakeWindowCurrent(window);
- _glfwLibrary.currentWindow = window;
-}
-
-
//========================================================================
// Returns GL_TRUE if the specified window handle is an actual window
//========================================================================
@@ -409,22 +387,6 @@ GLFWAPI int glfwIsWindow(GLFWwindow handle)
}
-//========================================================================
-// Returns GL_TRUE if the specified window handle is an actual window
-//========================================================================
-
-GLFWAPI GLFWwindow glfwGetCurrentWindow(void)
-{
- if (!_glfwInitialized)
- {
- _glfwSetError(GLFW_NOT_INITIALIZED, NULL);
- return GL_FALSE;
- }
-
- return _glfwLibrary.currentWindow;
-}
-
-
//========================================================================
// Set hints for opening the window
//========================================================================
@@ -532,7 +494,7 @@ GLFWAPI void glfwCloseWindow(GLFWwindow handle)
// Clear the current context if this window's context is current
if (window == _glfwLibrary.currentWindow)
- glfwMakeWindowCurrent(NULL);
+ glfwMakeContextCurrent(NULL);
// Clear the active window pointer if this is the active window
if (window == _glfwLibrary.activeWindow)
diff --git a/src/x11_opengl.c b/src/x11_opengl.c
index 0442209b..a261d616 100644
--- a/src/x11_opengl.c
+++ b/src/x11_opengl.c
@@ -56,6 +56,23 @@ void (*glXGetProcAddressEXT(const GLubyte* procName))();
////// GLFW internal API //////
//////////////////////////////////////////////////////////////////////////
+//========================================================================
+// Make the OpenGL context associated with the specified window current
+//========================================================================
+
+void _glfwPlatformMakeContextCurrent(_GLFWwindow* window)
+{
+ if (window)
+ {
+ glXMakeCurrent(_glfwLibrary.X11.display,
+ window->X11.handle,
+ window->GLX.context);
+ }
+ else
+ glXMakeCurrent(_glfwLibrary.X11.display, None, NULL);
+}
+
+
//========================================================================
// Swap OpenGL buffers
//========================================================================
@@ -121,7 +138,7 @@ void* _glfwPlatformGetProcAddress(const char* procname)
// Copies the specified OpenGL state categories from src to dst
//========================================================================
-void _glfwPlatformCopyGLState(_GLFWwindow* src, _GLFWwindow* dst, unsigned long mask)
+void _glfwPlatformCopyContext(_GLFWwindow* src, _GLFWwindow* dst, unsigned long mask)
{
glXCopyContext(_glfwLibrary.X11.display,
src->GLX.context,
diff --git a/src/x11_window.c b/src/x11_window.c
index e3e291ff..5a54f389 100644
--- a/src/x11_window.c
+++ b/src/x11_window.c
@@ -1448,23 +1448,6 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
}
-//========================================================================
-// Make the OpenGL context associated with the specified window current
-//========================================================================
-
-void _glfwPlatformMakeWindowCurrent(_GLFWwindow* window)
-{
- if (window)
- {
- glXMakeCurrent(_glfwLibrary.X11.display,
- window->X11.handle,
- window->GLX.context);
- }
- else
- glXMakeCurrent(_glfwLibrary.X11.display, None, NULL);
-}
-
-
//========================================================================
// Properly kill the window/video display
//========================================================================
diff --git a/tests/sharing.c b/tests/sharing.c
index 16e6eaf4..942ec2c6 100644
--- a/tests/sharing.c
+++ b/tests/sharing.c
@@ -80,7 +80,7 @@ static GLuint create_texture(void)
static void draw_quad(GLuint texture)
{
int width, height;
- glfwGetWindowSize(glfwGetCurrentWindow(), &width, &height);
+ glfwGetWindowSize(glfwGetCurrentContext(), &width, &height);
glViewport(0, 0, width, height);
@@ -148,11 +148,11 @@ int main(int argc, char** argv)
while (glfwIsWindow(windows[0]) && glfwIsWindow(windows[1]))
{
- glfwMakeWindowCurrent(windows[0]);
+ glfwMakeContextCurrent(windows[0]);
draw_quad(texture);
glfwSwapBuffers();
- glfwMakeWindowCurrent(windows[1]);
+ glfwMakeContextCurrent(windows[1]);
draw_quad(texture);
glfwSwapBuffers();
diff --git a/tests/windows.c b/tests/windows.c
index 13c76cbe..b84c9262 100644
--- a/tests/windows.c
+++ b/tests/windows.c
@@ -73,7 +73,7 @@ int main(void)
{
for (i = 0; i < 4; i++)
{
- glfwMakeWindowCurrent(windows[i]);
+ glfwMakeContextCurrent(windows[i]);
glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers();
}