Renamed context-related functions to more closely match underlying APIs.

This commit is contained in:
Camilla Berglund
2011-07-27 16:01:27 +02:00
parent 7268fc18b4
commit c1ab73b979
13 changed files with 103 additions and 102 deletions
+14 -1
View File
@@ -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];
}
+1 -13
View File
@@ -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
+2 -2
View File
@@ -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);
//========================================================================
+40 -2
View File
@@ -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);
}
+14 -1
View File
@@ -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");
+2 -15
View File
@@ -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
//========================================================================
+2 -40
View File
@@ -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)
+18 -1
View File
@@ -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,
-17
View File
@@ -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
//========================================================================