From 8aa8b7c2e46c8988d93fd94e08921c6d14b03b83 Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Sun, 8 May 2011 15:29:36 +0200
Subject: [PATCH 01/11] Added glfwCopyGLState.
---
include/GL/glfw3.h | 1 +
readme.html | 1 +
src/cocoa/cocoa_opengl.m | 9 +++++++++
src/internal.h | 1 +
src/opengl.c | 22 ++++++++++++++++++++++
src/win32/win32_opengl.c | 11 +++++++++++
src/x11/x11_opengl.c | 13 +++++++++++++
7 files changed, 58 insertions(+)
diff --git a/include/GL/glfw3.h b/include/GL/glfw3.h
index 1c8c4e1c..6e70e59c 100644
--- a/include/GL/glfw3.h
+++ b/include/GL/glfw3.h
@@ -583,6 +583,7 @@ GLFWAPI void glfwSwapInterval(int interval);
GLFWAPI int glfwExtensionSupported(const char* extension);
GLFWAPI void* glfwGetProcAddress(const char* procname);
GLFWAPI void glfwGetGLVersion(int* major, int* minor, int* rev);
+GLFWAPI void glfwCopyGLState(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 314b1cdd..31cc03ed 100644
--- a/readme.html
+++ b/readme.html
@@ -273,6 +273,7 @@ version of GLFW.
Added glfwSetWindowIconifyCallback
function and GLFWwindowiconifyfun
type for receiving window iconification events
Added glfwGetCurrentWindow
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 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 windows
simple multi-window test program
diff --git a/src/cocoa/cocoa_opengl.m b/src/cocoa/cocoa_opengl.m
index b633d472..6d93ed9f 100644
--- a/src/cocoa/cocoa_opengl.m
+++ b/src/cocoa/cocoa_opengl.m
@@ -86,3 +86,12 @@ void* _glfwPlatformGetProcAddress(const char* procname)
return symbol;
}
+//========================================================================
+// Copies the specified OpenGL state categories from src to dst
+//========================================================================
+
+void _glfwPlatformCopyGLState(_GLFWwindow* src, _GLFWwindow* dst, unsigned long mask)
+{
+ [dst->NSGL.context copyAttributesFromContext:src->NSGL.context withMask:mask];
+}
+
diff --git a/src/internal.h b/src/internal.h
index c942707b..4a39b9c9 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -310,6 +310,7 @@ 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);
//========================================================================
diff --git a/src/opengl.c b/src/opengl.c
index a08f97f9..2e5e287d 100644
--- a/src/opengl.c
+++ b/src/opengl.c
@@ -587,3 +587,25 @@ GLFWAPI void glfwGetGLVersion(int* major, int* minor, int* rev)
*rev = window->glRevision;
}
+
+//========================================================================
+// Copies the specified OpenGL state categories from src to dst
+//========================================================================
+
+GLFWAPI void glfwCopyGLState(GLFWwindow hsrc, GLFWwindow hdst, unsigned long mask)
+{
+ _GLFWwindow* src;
+ _GLFWwindow* dst;
+
+ if (!_glfwInitialized)
+ {
+ _glfwSetError(GLFW_NOT_INITIALIZED, NULL);
+ return;
+ }
+
+ src = (_GLFWwindow*) hsrc;
+ dst = (_GLFWwindow*) hdst;
+
+ _glfwPlatformCopyGLState(src, dst, mask);
+}
+
diff --git a/src/win32/win32_opengl.c b/src/win32/win32_opengl.c
index efce1531..d729fb51 100644
--- a/src/win32/win32_opengl.c
+++ b/src/win32/win32_opengl.c
@@ -103,3 +103,14 @@ void* _glfwPlatformGetProcAddress(const char* procname)
return (void*) wglGetProcAddress(procname);
}
+
+//========================================================================
+// Copies the specified OpenGL state categories from src to dst
+//========================================================================
+
+void _glfwPlatformCopyGLState(_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/x11/x11_opengl.c b/src/x11/x11_opengl.c
index 33b19ff9..0442209b 100644
--- a/src/x11/x11_opengl.c
+++ b/src/x11/x11_opengl.c
@@ -116,3 +116,16 @@ void* _glfwPlatformGetProcAddress(const char* procname)
return (void*) _glfw_glXGetProcAddress((const GLubyte*) procname);
}
+
+//========================================================================
+// Copies the specified OpenGL state categories from src to dst
+//========================================================================
+
+void _glfwPlatformCopyGLState(_GLFWwindow* src, _GLFWwindow* dst, unsigned long mask)
+{
+ glXCopyContext(_glfwLibrary.X11.display,
+ src->GLX.context,
+ dst->GLX.context,
+ mask);
+}
+
From 44035f5ef17d30f4f383603dd299c89ff61889d6 Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Sun, 8 May 2011 16:29:33 +0200
Subject: [PATCH 02/11] Added error check.
---
src/opengl.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/opengl.c b/src/opengl.c
index 2e5e287d..7621b438 100644
--- a/src/opengl.c
+++ b/src/opengl.c
@@ -606,6 +606,12 @@ GLFWAPI void glfwCopyGLState(GLFWwindow hsrc, GLFWwindow hdst, unsigned long mas
src = (_GLFWwindow*) hsrc;
dst = (_GLFWwindow*) hdst;
+ if (_glfwLibrary.currentWindow == dst)
+ {
+ _glfwSetError(GLFW_INVALID_VALUE, "Cannot copy OpenGL state to a current context");
+ return;
+ }
+
_glfwPlatformCopyGLState(src, dst, mask);
}
From d25f9db752bf577d5f6203dbfc4245ea99dd78d8 Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Sat, 21 May 2011 17:16:32 +0200
Subject: [PATCH 03/11] Removed glfwGetGLVersion, added GLFW_OPENGL_REVISION.
---
include/GL/glfw3.h | 10 +++++-----
readme.html | 2 ++
src/opengl.c | 32 --------------------------------
src/window.c | 2 ++
tests/version.c | 4 +++-
5 files changed, 12 insertions(+), 38 deletions(-)
diff --git a/include/GL/glfw3.h b/include/GL/glfw3.h
index 6e70e59c..63e5f17f 100644
--- a/include/GL/glfw3.h
+++ b/include/GL/glfw3.h
@@ -409,10 +409,11 @@ extern "C" {
#define GLFW_FSAA_SAMPLES 0x00020012
#define GLFW_OPENGL_VERSION_MAJOR 0x00020013
#define GLFW_OPENGL_VERSION_MINOR 0x00020014
-#define GLFW_OPENGL_FORWARD_COMPAT 0x00020015
-#define GLFW_OPENGL_DEBUG_CONTEXT 0x00020016
-#define GLFW_OPENGL_PROFILE 0x00020017
-#define GLFW_OPENGL_ROBUSTNESS 0x00020018
+#define GLFW_OPENGL_REVISION 0x00020015
+#define GLFW_OPENGL_FORWARD_COMPAT 0x00020016
+#define GLFW_OPENGL_DEBUG_CONTEXT 0x00020017
+#define GLFW_OPENGL_PROFILE 0x00020018
+#define GLFW_OPENGL_ROBUSTNESS 0x00020019
/* GLFW_OPENGL_ROBUSTNESS mode tokens */
#define GLFW_OPENGL_NO_ROBUSTNESS 0x00000000
@@ -582,7 +583,6 @@ GLFWAPI void glfwSwapBuffers(void);
GLFWAPI void glfwSwapInterval(int interval);
GLFWAPI int glfwExtensionSupported(const char* extension);
GLFWAPI void* glfwGetProcAddress(const char* procname);
-GLFWAPI void glfwGetGLVersion(int* major, int* minor, int* rev);
GLFWAPI void glfwCopyGLState(GLFWwindow src, GLFWwindow dst, unsigned long mask);
/* Enable/disable functions */
diff --git a/readme.html b/readme.html
index 31cc03ed..d1d4b031 100644
--- a/readme.html
+++ b/readme.html
@@ -276,6 +276,7 @@ version of GLFW.
Added glfwCopyGLState
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
Added windows
simple multi-window test program
Added sharing
simple OpenGL object sharing test program
Added a parameter to glfwOpenWindow
for specifying a context the new window's context will share objects with
@@ -295,6 +296,7 @@ version of GLFW.
Removed deprecated Carbon port
Removed glfwSleep
function
Removed glfwGetNumberOfProcessors
function
+ Removed glfwGetGLVersion
function
Removed GLFW_OPENED
window parameter
Removed nonsensical key actions for Unicode character input
Removed GLFWCALL
and GLFWAPIENTRY
macros for stdcall calling convention
diff --git a/src/opengl.c b/src/opengl.c
index 7621b438..5e465f4a 100644
--- a/src/opengl.c
+++ b/src/opengl.c
@@ -556,38 +556,6 @@ GLFWAPI void* glfwGetProcAddress(const char* procname)
}
-//========================================================================
-// Returns the OpenGL version
-//========================================================================
-
-GLFWAPI void glfwGetGLVersion(int* major, int* minor, int* rev)
-{
- _GLFWwindow* window;
-
- if (!_glfwInitialized)
- {
- _glfwSetError(GLFW_NOT_INITIALIZED, NULL);
- return;
- }
-
- window = _glfwLibrary.currentWindow;
- if (!window)
- {
- _glfwSetError(GLFW_NO_CURRENT_WINDOW, NULL);
- return;
- }
-
- if (major != NULL)
- *major = window->glMajor;
-
- if (minor != NULL)
- *minor = window->glMinor;
-
- if (rev != NULL)
- *rev = window->glRevision;
-}
-
-
//========================================================================
// Copies the specified OpenGL state categories from src to dst
//========================================================================
diff --git a/src/window.c b/src/window.c
index 086b9188..156460d0 100644
--- a/src/window.c
+++ b/src/window.c
@@ -777,6 +777,8 @@ GLFWAPI int glfwGetWindowParam(GLFWwindow handle, int param)
return window->glMajor;
case GLFW_OPENGL_VERSION_MINOR:
return window->glMinor;
+ case GLFW_OPENGL_REVISION:
+ return window->glRevision;
case GLFW_OPENGL_FORWARD_COMPAT:
return window->glForward;
case GLFW_OPENGL_DEBUG_CONTEXT:
diff --git a/tests/version.c b/tests/version.c
index e473ef55..c36fa387 100644
--- a/tests/version.c
+++ b/tests/version.c
@@ -229,7 +229,9 @@ int main(int argc, char** argv)
printf("OpenGL context version string: \"%s\"\n", glGetString(GL_VERSION));
- glfwGetGLVersion(&major, &minor, &revision);
+ major = glfwGetWindowParam(window, GLFW_OPENGL_VERSION_MAJOR);
+ minor = glfwGetWindowParam(window, GLFW_OPENGL_VERSION_MINOR);
+ revision = glfwGetWindowParam(window, GLFW_OPENGL_REVISION);
printf("OpenGL context version parsed by GLFW: %u.%u.%u\n", major, minor, revision);
From f9e0f6f78299826e775e53f0c16ae3f8e26527da Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Sat, 21 May 2011 17:34:17 +0200
Subject: [PATCH 04/11] Formatting.
---
src/x11/x11_window.c | 62 +++++++++++++++++++++++++++++++-------------
1 file changed, 44 insertions(+), 18 deletions(-)
diff --git a/src/x11/x11_window.c b/src/x11/x11_window.c
index 47af01f6..e3e291ff 100644
--- a/src/x11/x11_window.c
+++ b/src/x11/x11_window.c
@@ -277,7 +277,8 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found)
{
if (!window->GLX.has_GLX_SGIX_fbconfig)
{
- _glfwSetError(GLFW_OPENGL_UNAVAILABLE, "X11/GLX: GLXFBConfig support not found");
+ _glfwSetError(GLFW_OPENGL_UNAVAILABLE,
+ "X11/GLX: GLXFBConfig support not found");
return NULL;
}
}
@@ -290,16 +291,20 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found)
&count);
if (!count)
{
- _glfwSetError(GLFW_OPENGL_UNAVAILABLE, "X11/GLX: No GLXFBConfigs returned");
+ _glfwSetError(GLFW_OPENGL_UNAVAILABLE,
+ "X11/GLX: No GLXFBConfigs returned");
return NULL;
}
}
else
{
- fbconfigs = glXGetFBConfigs(_glfwLibrary.X11.display, _glfwLibrary.X11.screen, &count);
+ fbconfigs = glXGetFBConfigs(_glfwLibrary.X11.display,
+ _glfwLibrary.X11.screen,
+ &count);
if (!count)
{
- _glfwSetError(GLFW_OPENGL_UNAVAILABLE, "X11/GLX: No GLXFBConfigs returned");
+ _glfwSetError(GLFW_OPENGL_UNAVAILABLE,
+ "X11/GLX: No GLXFBConfigs returned");
return NULL;
}
}
@@ -307,7 +312,8 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found)
result = (_GLFWfbconfig*) _glfwMalloc(sizeof(_GLFWfbconfig) * count);
if (!result)
{
- _glfwSetError(GLFW_OUT_OF_MEMORY, "X11/GLX: Failed to allocate _GLFWfbconfig array");
+ _glfwSetError(GLFW_OUT_OF_MEMORY,
+ "X11/GLX: Failed to allocate _GLFWfbconfig array");
return NULL;
}
@@ -320,7 +326,9 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found)
continue;
}
- if (!(getFBConfigAttrib(window, fbconfigs[i], GLX_RENDER_TYPE) & GLX_RGBA_BIT))
+ if (!(getFBConfigAttrib(window,
+ fbconfigs[i],
+ GLX_RENDER_TYPE) & GLX_RGBA_BIT))
{
// Only consider RGBA GLXFBConfigs
continue;
@@ -408,7 +416,8 @@ static int createContext(_GLFWwindow* window,
if (fbconfig == NULL)
{
- _glfwSetError(GLFW_PLATFORM_ERROR, "X11/GLX: Failed to retrieve the selected GLXFBConfig");
+ _glfwSetError(GLFW_PLATFORM_ERROR,
+ "X11/GLX: Failed to retrieve the selected GLXFBConfig");
return GL_FALSE;
}
}
@@ -429,7 +438,8 @@ static int createContext(_GLFWwindow* window,
{
XFree(fbconfig);
- _glfwSetError(GLFW_PLATFORM_ERROR, "X11/GLX: Failed to retrieve visual for GLXFBConfig");
+ _glfwSetError(GLFW_PLATFORM_ERROR,
+ "X11/GLX: Failed to retrieve visual for GLXFBConfig");
return GL_FALSE;
}
@@ -467,14 +477,18 @@ static int createContext(_GLFWwindow* window,
if (!window->GLX.has_GLX_ARB_create_context_profile)
{
- _glfwSetError(GLFW_VERSION_UNAVAILABLE, "X11/GLX: An OpenGL profile requested but GLX_ARB_create_context_profile is unavailable");
+ _glfwSetError(GLFW_VERSION_UNAVAILABLE,
+ "X11/GLX: An OpenGL profile requested but "
+ "GLX_ARB_create_context_profile is unavailable");
return GL_FALSE;
}
if (wndconfig->glProfile == GLFW_OPENGL_ES2_PROFILE &&
!window->GLX.has_GLX_EXT_create_context_es2_profile)
{
- _glfwSetError(GLFW_VERSION_UNAVAILABLE, "X11/GLX: OpenGL ES 2.x profile requested but GLX_EXT_create_context_es2_profile is unavailable");
+ _glfwSetError(GLFW_VERSION_UNAVAILABLE,
+ "X11/GLX: OpenGL ES 2.x profile requested but "
+ "GLX_EXT_create_context_es2_profile is unavailable");
return GL_FALSE;
}
@@ -494,7 +508,10 @@ static int createContext(_GLFWwindow* window,
if (!window->GLX.has_GLX_ARB_create_context_robustness)
{
- _glfwSetError(GLFW_VERSION_UNAVAILABLE, "X11/GLX: An OpenGL robustness strategy was requested but GLX_ARB_create_context_robustness is unavailable");
+ _glfwSetError(GLFW_VERSION_UNAVAILABLE,
+ "X11/GLX: An OpenGL robustness strategy was "
+ "requested but GLX_ARB_create_context_robustness "
+ "is unavailable");
return GL_FALSE;
}
@@ -503,7 +520,10 @@ static int createContext(_GLFWwindow* window,
else if (wndconfig->glRobustness == GLFW_OPENGL_LOSE_CONTEXT_ON_RESET)
strategy = GLX_LOSE_CONTEXT_ON_RESET_ARB;
- setGLXattrib(attribs, index, GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, strategy);
+ setGLXattrib(attribs,
+ index,
+ GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB,
+ strategy);
}
setGLXattrib(attribs, index, None, None);
@@ -551,7 +571,8 @@ static int createContext(_GLFWwindow* window,
{
// TODO: Handle all the various error codes here
- _glfwSetError(GLFW_PLATFORM_ERROR, "X11/GLX: Failed to create OpenGL context");
+ _glfwSetError(GLFW_PLATFORM_ERROR,
+ "X11/GLX: Failed to create OpenGL context");
return GL_FALSE;
}
@@ -699,7 +720,8 @@ static GLboolean createWindow(_GLFWwindow* window,
{
// TODO: Handle all the various error codes here
- _glfwSetError(GLFW_PLATFORM_ERROR, "X11/GLX: Failed to create window");
+ _glfwSetError(GLFW_PLATFORM_ERROR,
+ "X11/GLX: Failed to create window");
return GL_FALSE;
}
}
@@ -760,7 +782,8 @@ static GLboolean createWindow(_GLFWwindow* window,
XWMHints* hints = XAllocWMHints();
if (!hints)
{
- _glfwSetError(GLFW_OUT_OF_MEMORY, "X11/GLX: Failed to allocate WM hints");
+ _glfwSetError(GLFW_OUT_OF_MEMORY,
+ "X11/GLX: Failed to allocate WM hints");
return GL_FALSE;
}
@@ -776,7 +799,8 @@ static GLboolean createWindow(_GLFWwindow* window,
XSizeHints* hints = XAllocSizeHints();
if (!hints)
{
- _glfwSetError(GLFW_OUT_OF_MEMORY, "X11/GLX: Failed to allocate size hints");
+ _glfwSetError(GLFW_OUT_OF_MEMORY,
+ "X11/GLX: Failed to allocate size hints");
return GL_FALSE;
}
@@ -1505,7 +1529,8 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
if (window->mode == GLFW_FULLSCREEN)
{
// Get the closest matching video mode for the specified window size
- mode = _glfwGetClosestVideoMode(_glfwLibrary.X11.screen, &width, &height, &rate);
+ mode = _glfwGetClosestVideoMode(_glfwLibrary.X11.screen,
+ &width, &height, &rate);
}
if (window->windowNoResize)
@@ -1670,7 +1695,8 @@ void _glfwPlatformRefreshWindowParams(void)
{
#if defined(_GLFW_HAS_XF86VIDMODE)
// Use the XF86VidMode extension to get current video mode
- XF86VidModeGetModeLine(_glfwLibrary.X11.display, _glfwLibrary.X11.screen,
+ XF86VidModeGetModeLine(_glfwLibrary.X11.display,
+ _glfwLibrary.X11.screen,
&dotclock, &modeline);
pixels_per_second = 1000.0f * (float) dotclock;
pixels_per_frame = (float) modeline.htotal * modeline.vtotal;
From b2e8807440e1830bc42bc263f1d494322414cc02 Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Sat, 21 May 2011 22:50:25 +0200
Subject: [PATCH 05/11] Formatting.
---
src/cocoa/cocoa_window.m | 27 ++++++++++++++++++++-------
1 file changed, 20 insertions(+), 7 deletions(-)
diff --git a/src/cocoa/cocoa_window.m b/src/cocoa/cocoa_window.m
index b6c97fbd..283eae32 100644
--- a/src/cocoa/cocoa_window.m
+++ b/src/cocoa/cocoa_window.m
@@ -363,7 +363,11 @@ static int convertMacKeyCode(unsigned int macKeyCode)
}
if (_glfwLibrary.mousePosCallback)
- _glfwLibrary.mousePosCallback(window, window->mousePosX, window->mousePosY);
+ {
+ _glfwLibrary.mousePosCallback(window,
+ window->mousePosX,
+ window->mousePosY);
+ }
}
- (void)rightMouseDown:(NSEvent *)event
@@ -475,14 +479,18 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
// Fail if OpenGL 3.0 or above was requested
if (wndconfig->glMajor > 2)
{
- _glfwSetError(GLFW_VERSION_UNAVAILABLE, "Cocoa/NSOpenGL: Mac OS X does not support OpenGL version 3.0 or above");
+ _glfwSetError(GLFW_VERSION_UNAVAILABLE,
+ "Cocoa/NSOpenGL: Mac OS X does not support OpenGL "
+ "version 3.0 or above");
return GL_FALSE;
}
// Fail if a robustness strategy was requested
if (wndconfig->glRobustness)
{
- _glfwSetError(GLFW_VERSION_UNAVAILABLE, "Cocoa/NSOpenGL: Mac OS X does not support OpenGL robustness strategies");
+ _glfwSetError(GLFW_VERSION_UNAVAILABLE,
+ "Cocoa/NSOpenGL: Mac OS X does not support OpenGL "
+ "robustness strategies");
return GL_FALSE;
}
@@ -493,7 +501,9 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
_glfwLibrary.NS.delegate = [[GLFWApplicationDelegate alloc] init];
if (_glfwLibrary.NS.delegate == nil)
{
- _glfwSetError(GLFW_PLATFORM_ERROR, "Cocoa/NSOpenGL: Failed to create application delegate");
+ _glfwSetError(GLFW_PLATFORM_ERROR,
+ "Cocoa/NSOpenGL: Failed to create application "
+ "delegate");
return GL_FALSE;
}
@@ -503,7 +513,8 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
window->NS.delegate = [[GLFWWindowDelegate alloc] initWithGlfwWindow:window];
if (window->NS.delegate == nil)
{
- _glfwSetError(GLFW_PLATFORM_ERROR, "Cocoa/NSOpenGL: Failed to create window delegate");
+ _glfwSetError(GLFW_PLATFORM_ERROR,
+ "Cocoa/NSOpenGL: Failed to create window delegate");
return GL_FALSE;
}
@@ -634,7 +645,8 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
[[NSOpenGLPixelFormat alloc] initWithAttributes:attributes];
if (window->NSGL.pixelFormat == nil)
{
- _glfwSetError(GLFW_PLATFORM_ERROR, "Cocoa/NSOpenGL: Failed to create pixel format");
+ _glfwSetError(GLFW_PLATFORM_ERROR,
+ "Cocoa/NSOpenGL: Failed to create pixel format");
return GL_FALSE;
}
@@ -648,7 +660,8 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
shareContext:share];
if (window->NSGL.context == nil)
{
- _glfwSetError(GLFW_PLATFORM_ERROR, "Cocoa/NSOpenGL: Failed to create OpenGL context");
+ _glfwSetError(GLFW_PLATFORM_ERROR,
+ "Cocoa/NSOpenGL: Failed to create OpenGL context");
return GL_FALSE;
}
From 71f4adc3ec563e96a0e36b9366399d4b2c349123 Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Sat, 21 May 2011 23:13:48 +0200
Subject: [PATCH 06/11] Formatting.
---
src/win32/win32_window.c | 71 ++++++++++++++++++++++++++++++----------
1 file changed, 54 insertions(+), 17 deletions(-)
diff --git a/src/win32/win32_window.c b/src/win32/win32_window.c
index 183f08e7..23633105 100644
--- a/src/win32/win32_window.c
+++ b/src/win32/win32_window.c
@@ -155,7 +155,9 @@ static int getPixelFormatAttrib(_GLFWwindow* window, int pixelFormat, int attrib
{
int value = 0;
- if (!window->WGL.GetPixelFormatAttribivARB(window->WGL.DC, pixelFormat, 0, 1, &attrib, &value))
+ if (!window->WGL.GetPixelFormatAttribivARB(window->WGL.DC,
+ pixelFormat,
+ 0, 1, &attrib, &value))
{
// NOTE: We should probably handle this error somehow
return 0;
@@ -180,7 +182,12 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found)
if (window->WGL.has_WGL_ARB_pixel_format)
count = getPixelFormatAttrib(window, 1, WGL_NUMBER_PIXEL_FORMATS_ARB);
else
- count = _glfw_DescribePixelFormat(window->WGL.DC, 1, sizeof(PIXELFORMATDESCRIPTOR), NULL);
+ {
+ count = _glfw_DescribePixelFormat(window->WGL.DC,
+ 1,
+ sizeof(PIXELFORMATDESCRIPTOR),
+ NULL);
+ }
if (!count)
{
@@ -191,7 +198,8 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found)
result = (_GLFWfbconfig*) _glfwMalloc(sizeof(_GLFWfbconfig) * count);
if (!result)
{
- _glfwSetError(GLFW_OUT_OF_MEMORY, "Win32/WGL: Failed to allocate _GLFWfbconfig array");
+ _glfwSetError(GLFW_OUT_OF_MEMORY,
+ "Win32/WGL: Failed to allocate _GLFWfbconfig array");
return NULL;
}
@@ -259,8 +267,13 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found)
{
// Get pixel format attributes through old-fashioned PFDs
- if (!_glfw_DescribePixelFormat(window->WGL.DC, i, sizeof(PIXELFORMATDESCRIPTOR), &pfd))
+ if (!_glfw_DescribePixelFormat(window->WGL.DC,
+ i,
+ sizeof(PIXELFORMATDESCRIPTOR),
+ &pfd))
+ {
continue;
+ }
if (!(pfd.dwFlags & PFD_DRAW_TO_WINDOW) ||
!(pfd.dwFlags & PFD_SUPPORT_OPENGL) ||
@@ -324,13 +337,15 @@ static GLboolean createContext(_GLFWwindow* window,
if (!_glfw_DescribePixelFormat(window->WGL.DC, pixelFormat, sizeof(pfd), &pfd))
{
- _glfwSetError(GLFW_OPENGL_UNAVAILABLE, "Win32/WGL: Failed to retrieve PFD for selected pixel format");
+ _glfwSetError(GLFW_OPENGL_UNAVAILABLE,
+ "Win32/WGL: Failed to retrieve PFD for selected pixel format");
return GL_FALSE;
}
if (!_glfw_SetPixelFormat(window->WGL.DC, pixelFormat, &pfd))
{
- _glfwSetError(GLFW_OPENGL_UNAVAILABLE, "Win32/WGL: Failed to set selected pixel format");
+ _glfwSetError(GLFW_OPENGL_UNAVAILABLE,
+ "Win32/WGL: Failed to set selected pixel format");
return GL_FALSE;
}
@@ -371,14 +386,18 @@ static GLboolean createContext(_GLFWwindow* window,
if (!window->WGL.has_WGL_ARB_create_context_profile)
{
- _glfwSetError(GLFW_VERSION_UNAVAILABLE, "Win32/WGL: OpenGL profile requested but WGL_ARB_create_context_profile is unavailable");
+ _glfwSetError(GLFW_VERSION_UNAVAILABLE,
+ "Win32/WGL: OpenGL profile requested but "
+ "WGL_ARB_create_context_profile is unavailable");
return GL_FALSE;
}
if (wndconfig->glProfile == GLFW_OPENGL_ES2_PROFILE &&
!window->WGL.has_WGL_EXT_create_context_es2_profile)
{
- _glfwSetError(GLFW_VERSION_UNAVAILABLE, "Win32/WGL: OpenGL ES 2.x profile requested but WGL_EXT_create_context_es2_profile is unavailable");
+ _glfwSetError(GLFW_VERSION_UNAVAILABLE,
+ "Win32/WGL: OpenGL ES 2.x profile requested but "
+ "WGL_EXT_create_context_es2_profile is unavailable");
return GL_FALSE;
}
@@ -399,7 +418,10 @@ static GLboolean createContext(_GLFWwindow* window,
if (!window->WGL.has_WGL_ARB_create_context_robustness)
{
- _glfwSetError(GLFW_VERSION_UNAVAILABLE, "Win32/WGL: An OpenGL robustness strategy was requested but WGL_ARB_create_context_robustness is unavailable");
+ _glfwSetError(GLFW_VERSION_UNAVAILABLE,
+ "Win32/WGL: An OpenGL robustness strategy was "
+ "requested but WGL_ARB_create_context_robustness "
+ "is unavailable");
return GL_FALSE;
}
@@ -419,7 +441,8 @@ static GLboolean createContext(_GLFWwindow* window,
attribs);
if (!window->WGL.context)
{
- _glfwSetError(GLFW_VERSION_UNAVAILABLE, "Win32/WGL: Failed to create OpenGL context");
+ _glfwSetError(GLFW_VERSION_UNAVAILABLE,
+ "Win32/WGL: Failed to create OpenGL context");
return GL_FALSE;
}
}
@@ -428,7 +451,8 @@ static GLboolean createContext(_GLFWwindow* window,
window->WGL.context = wglCreateContext(window->WGL.DC);
if (!window->WGL.context)
{
- _glfwSetError(GLFW_PLATFORM_ERROR, "Win32/WGL: Failed to create OpenGL context");
+ _glfwSetError(GLFW_PLATFORM_ERROR,
+ "Win32/WGL: Failed to create OpenGL context");
return GL_FALSE;
}
@@ -436,7 +460,9 @@ static GLboolean createContext(_GLFWwindow* window,
{
if (!wglShareLists(share, window->WGL.context))
{
- _glfwSetError(GLFW_PLATFORM_ERROR, "Win32/WGL: Failed to enable sharing with specified OpenGL context");
+ _glfwSetError(GLFW_PLATFORM_ERROR,
+ "Win32/WGL: Failed to enable sharing with "
+ "specified OpenGL context");
return GL_FALSE;
}
}
@@ -992,7 +1018,11 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
}
if (_glfwLibrary.windowSizeCallback)
- _glfwLibrary.windowSizeCallback(window, window->width, window->height);
+ {
+ _glfwLibrary.windowSizeCallback(window,
+ window->width,
+ window->height);
+ }
return 0;
}
@@ -1178,7 +1208,8 @@ static ATOM registerWindowClass(void)
classAtom = RegisterClass(&wc);
if (!classAtom)
{
- _glfwSetError(GLFW_PLATFORM_ERROR, "Win32/WGL: Failed to register window class");
+ _glfwSetError(GLFW_PLATFORM_ERROR,
+ "Win32/WGL: Failed to register window class");
return 0;
}
@@ -1299,7 +1330,8 @@ static int createWindow(_GLFWwindow* window,
window->WGL.DC = GetDC(window->Win32.handle);
if (!window->WGL.DC)
{
- _glfwSetError(GLFW_PLATFORM_ERROR, "Win32/WGL: Failed to retrieve DC for window");
+ _glfwSetError(GLFW_PLATFORM_ERROR,
+ "Win32/WGL: Failed to retrieve DC for window");
return GL_FALSE;
}
@@ -1417,7 +1449,10 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
{
if (!window->WGL.has_WGL_ARB_create_context)
{
- _glfwSetError(GLFW_VERSION_UNAVAILABLE, "Win32/WGL: A forward compatible or debug OpenGL context requested but WGL_ARB_create_context is unavailable");
+ _glfwSetError(GLFW_VERSION_UNAVAILABLE,
+ "Win32/WGL: A forward compatible or debug OpenGL "
+ "context requested but WGL_ARB_create_context is "
+ "unavailable");
return GL_FALSE;
}
@@ -1428,7 +1463,9 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
{
if (!window->WGL.has_WGL_ARB_create_context_profile)
{
- _glfwSetError(GLFW_VERSION_UNAVAILABLE, "Win32/WGL: OpenGL profile requested but WGL_ARB_create_context_profile is unavailable");
+ _glfwSetError(GLFW_VERSION_UNAVAILABLE,
+ "Win32/WGL: OpenGL profile requested but "
+ "WGL_ARB_create_context_profile is unavailable");
return GL_FALSE;
}
From 53f4f54c46070d090665cae2e2c6cb5393bf68d7 Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Tue, 26 Jul 2011 15:16:34 +0200
Subject: [PATCH 07/11] Flattened source tree.
---
CMakeLists.txt | 25 +-----
src/CMakeLists.txt | 90 ++++++++++++++++++++++
src/cocoa/CMakeLists.txt | 40 ----------
src/cocoa/libglfw.pc.cmake | 11 ---
src/{cocoa => }/cocoa_enable.m | 0
src/{cocoa => }/cocoa_fullscreen.m | 0
src/{cocoa => }/cocoa_gamma.m | 0
src/{cocoa => }/cocoa_init.m | 0
src/{cocoa => }/cocoa_joystick.m | 0
src/{cocoa => }/cocoa_opengl.m | 0
src/{cocoa/platform.h => cocoa_platform.h} | 0
src/{cocoa => }/cocoa_time.m | 0
src/{cocoa => }/cocoa_window.m | 0
src/internal.h | 17 ++--
src/libglfw.pc.cmake | 0
src/win32/CMakeLists.txt | 59 --------------
src/win32/libglfw.pc.cmake | 11 ---
src/{win32 => }/win32_dllmain.c | 0
src/{win32 => }/win32_enable.c | 0
src/{win32 => }/win32_fullscreen.c | 0
src/{win32 => }/win32_gamma.c | 0
src/{win32 => }/win32_init.c | 0
src/{win32 => }/win32_joystick.c | 0
src/{win32 => }/win32_opengl.c | 0
src/{win32/platform.h => win32_platform.h} | 0
src/{win32 => }/win32_time.c | 0
src/{win32 => }/win32_window.c | 0
src/x11/CMakeLists.txt | 30 --------
src/x11/libglfw.pc.cmake | 11 ---
src/{x11 => }/x11_enable.c | 0
src/{x11 => }/x11_fullscreen.c | 0
src/{x11 => }/x11_gamma.c | 0
src/{x11 => }/x11_init.c | 0
src/{x11 => }/x11_joystick.c | 0
src/{x11 => }/x11_keysym2unicode.c | 0
src/{x11 => }/x11_opengl.c | 0
src/{x11/platform.h => x11_platform.h} | 0
src/{x11 => }/x11_time.c | 0
src/{x11 => }/x11_window.c | 0
39 files changed, 104 insertions(+), 190 deletions(-)
create mode 100644 src/CMakeLists.txt
delete mode 100644 src/cocoa/CMakeLists.txt
delete mode 100644 src/cocoa/libglfw.pc.cmake
rename src/{cocoa => }/cocoa_enable.m (100%)
rename src/{cocoa => }/cocoa_fullscreen.m (100%)
rename src/{cocoa => }/cocoa_gamma.m (100%)
rename src/{cocoa => }/cocoa_init.m (100%)
rename src/{cocoa => }/cocoa_joystick.m (100%)
rename src/{cocoa => }/cocoa_opengl.m (100%)
rename src/{cocoa/platform.h => cocoa_platform.h} (100%)
rename src/{cocoa => }/cocoa_time.m (100%)
rename src/{cocoa => }/cocoa_window.m (100%)
create mode 100644 src/libglfw.pc.cmake
delete mode 100644 src/win32/CMakeLists.txt
delete mode 100644 src/win32/libglfw.pc.cmake
rename src/{win32 => }/win32_dllmain.c (100%)
rename src/{win32 => }/win32_enable.c (100%)
rename src/{win32 => }/win32_fullscreen.c (100%)
rename src/{win32 => }/win32_gamma.c (100%)
rename src/{win32 => }/win32_init.c (100%)
rename src/{win32 => }/win32_joystick.c (100%)
rename src/{win32 => }/win32_opengl.c (100%)
rename src/{win32/platform.h => win32_platform.h} (100%)
rename src/{win32 => }/win32_time.c (100%)
rename src/{win32 => }/win32_window.c (100%)
delete mode 100644 src/x11/CMakeLists.txt
delete mode 100644 src/x11/libglfw.pc.cmake
rename src/{x11 => }/x11_enable.c (100%)
rename src/{x11 => }/x11_fullscreen.c (100%)
rename src/{x11 => }/x11_gamma.c (100%)
rename src/{x11 => }/x11_init.c (100%)
rename src/{x11 => }/x11_joystick.c (100%)
rename src/{x11 => }/x11_keysym2unicode.c (100%)
rename src/{x11 => }/x11_opengl.c (100%)
rename src/{x11/platform.h => x11_platform.h} (100%)
rename src/{x11 => }/x11_time.c (100%)
rename src/{x11 => }/x11_window.c (100%)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index aa2f01f0..f0c2eeef 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -15,19 +15,6 @@ include(CheckSymbolExists)
find_package(OpenGL REQUIRED)
-set(common_SOURCES
- ${GLFW_SOURCE_DIR}/src/enable.c
- ${GLFW_SOURCE_DIR}/src/error.c
- ${GLFW_SOURCE_DIR}/src/fullscreen.c
- ${GLFW_SOURCE_DIR}/src/gamma.c
- ${GLFW_SOURCE_DIR}/src/init.c
- ${GLFW_SOURCE_DIR}/src/input.c
- ${GLFW_SOURCE_DIR}/src/joystick.c
- ${GLFW_SOURCE_DIR}/src/opengl.c
- ${GLFW_SOURCE_DIR}/src/time.c
- ${GLFW_SOURCE_DIR}/src/window.c
-)
-
#--------------------------------------------------------------------
# Set up GLFW for Win32 and WGL on Windows
#--------------------------------------------------------------------
@@ -41,9 +28,6 @@ if (WIN32)
set(CMAKE_REQUIRED_LIBRARIES ${OPENGL_gl_LIBRARY})
list(APPEND GLFW_INCLUDE_DIR ${OPENGL_INCLUDE_DIR})
list(APPEND GLFW_LIBRARIES ${OPENGL_gl_LIBRARY})
-
- # Select platform specific code
- add_subdirectory(src/win32)
endif (WIN32)
#--------------------------------------------------------------------
@@ -105,9 +89,6 @@ if (UNIX AND NOT APPLE AND NOT CYGWIN)
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
set(_GLFW_USE_LINUX_JOYSTICKS 1)
endif (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
-
- # Select platform specific code
- add_subdirectory(src/x11)
endif(UNIX AND NOT APPLE AND NOT CYGWIN)
#--------------------------------------------------------------------
@@ -135,14 +116,12 @@ if (UNIX AND APPLE)
find_library(COCOA_FRAMEWORK Cocoa)
list(APPEND GLFW_LIBRARIES ${COCOA_FRAMEWORK})
list(APPEND GLFW_LIBRARIES ${OPENGL_gl_LIBRARY})
-
- # Select platform specific code
- add_subdirectory(src/cocoa)
endif(UNIX AND APPLE)
#--------------------------------------------------------------------
-# Add example and test programs
+# Add subdirectories
#--------------------------------------------------------------------
+add_subdirectory(src)
add_subdirectory(examples)
add_subdirectory(tests)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
new file mode 100644
index 00000000..86be028b
--- /dev/null
+++ b/src/CMakeLists.txt
@@ -0,0 +1,90 @@
+
+if(CYGWIN)
+
+ # These lines are intended to remove the --export-all-symbols
+ # flag added in the Modules/Platform/CYGWIN.cmake file of the
+ # CMake distribution.
+ # This is a HACK. If you have trouble _linking_ the GLFW
+ # _shared_ library on Cygwin, try disabling this.
+ set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared")
+ set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS ${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS})
+
+endif(CYGWIN)
+
+if(UNIX)
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libglfw.pc.cmake
+ ${CMAKE_CURRENT_BINARY_DIR}/libglfw.pc @ONLY)
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libglfw.pc DESTINATION lib/pkgconfig)
+endif(UNIX)
+
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}
+ ${GLFW_SOURCE_DIR}/src
+ ${GLFW_BINARY_DIR}/src
+ ${GLFW_INCLUDE_DIR})
+
+set(common_SOURCES enable.c
+ error.c
+ fullscreen.c
+ gamma.c
+ init.c
+ input.c
+ joystick.c
+ opengl.c
+ time.c
+ window.c)
+
+if(_GLFW_COCOA_NSGL)
+ set(libglfw_SOURCES ${common_SOURCES} cocoa_enable.m cocoa_fullscreen.m
+ cocoa_gamma.m cocoa_init.m cocoa_joystick.m
+ cocoa_opengl.m cocoa_time.m cocoa_window.m)
+
+ # For some reason, CMake doesn't know about .m
+ set_source_files_properties(${libglfw_SOURCES} PROPERTIES LANGUAGE C)
+elseif(_GLFW_WIN32_WGL)
+ set(libglfw_SOURCES ${common_SOURCES} win32_enable.c win32_fullscreen.c
+ win32_gamma.c win32_init.c win32_joystick.c
+ win32_opengl.c win32_time.c win32_window.c
+ win32_dllmain.c)
+elseif(_GLFW_X11_GLX)
+ set(libglfw_SOURCES ${common_SOURCES} x11_enable.c x11_fullscreen.c
+ x11_gamma.c x11_init.c x11_joystick.c
+ x11_keysym2unicode.c x11_opengl.c x11_time.c
+ x11_window.c)
+else()
+ message(FATAL_ERROR "No supported platform was selected")
+endif(_GLFW_COCOA_NSGL)
+
+add_library(libglfwStatic STATIC ${libglfw_SOURCES})
+add_library(libglfwShared SHARED ${libglfw_SOURCES})
+target_link_libraries(libglfwShared ${GLFW_LIBRARIES})
+set_target_properties(libglfwStatic libglfwShared PROPERTIES
+ CLEAN_DIRECT_OUTPUT 1
+ OUTPUT_NAME glfw)
+
+if(WIN32)
+ # The GLFW DLL needs a special compile-time macro and import library name
+ set_target_properties(libglfwShared PROPERTIES
+ DEFINE_SYMBOL GLFW_BUILD_DLL
+ PREFIX ""
+ IMPORT_PREFIX ""
+ IMPORT_SUFFIX "dll.lib")
+endif(WIN32)
+
+if(CYGWIN)
+ # Build for the regular Win32 environment (not Cygwin)
+ set_target_properties(libglfwStatic libglfwShared PROPERTIES
+ COMPILE_FLAGS "-mwin32 -mno-cygwin"
+ LINK_FLAGS "-mwin32 -mno-cygwin")
+endif(CYGWIN)
+
+if(APPLE)
+ # Append -fno-common to the compile flags to work around a bug in the Apple GCC
+ get_target_property(CFLAGS libglfwShared COMPILE_FLAGS)
+ if(NOT CFLAGS)
+ set(CFLAGS "")
+ endif(NOT CFLAGS)
+ set_target_properties(libglfwShared PROPERTIES COMPILE_FLAGS "${CFLAGS} -fno-common")
+endif(APPLE)
+
+install(TARGETS libglfwStatic libglfwShared DESTINATION lib)
+
diff --git a/src/cocoa/CMakeLists.txt b/src/cocoa/CMakeLists.txt
deleted file mode 100644
index f0bc3c4c..00000000
--- a/src/cocoa/CMakeLists.txt
+++ /dev/null
@@ -1,40 +0,0 @@
-
-configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libglfw.pc.cmake
- ${CMAKE_CURRENT_BINARY_DIR}/libglfw.pc @ONLY)
-
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}
- ${GLFW_SOURCE_DIR}/src
- ${GLFW_BINARY_DIR}/src
- ${GLFW_INCLUDE_DIR})
-
-set(cocoa_SOURCES cocoa_enable.m
- cocoa_fullscreen.m
- cocoa_gamma.m
- cocoa_init.m
- cocoa_joystick.m
- cocoa_opengl.m
- cocoa_time.m
- cocoa_window.m)
-
-# For some reason, CMake doesn't know about .m
-set_source_files_properties(${cocoa_SOURCES} PROPERTIES LANGUAGE C)
-
-set(libglfw_SOURCES ${common_SOURCES} ${cocoa_SOURCES})
-
-add_library(libglfwStatic STATIC ${libglfw_SOURCES})
-add_library(libglfwShared SHARED ${libglfw_SOURCES})
-target_link_libraries(libglfwShared ${GLFW_LIBRARIES})
-set_target_properties(libglfwStatic libglfwShared PROPERTIES
- CLEAN_DIRECT_OUTPUT 1
- OUTPUT_NAME glfw)
-
-# Append -fno-common to the compile flags to work around a bug in the Apple GCC
-get_target_property(CFLAGS libglfwShared COMPILE_FLAGS)
-if(NOT CFLAGS)
- set(CFLAGS "")
-endif(NOT CFLAGS)
-set_target_properties(libglfwShared PROPERTIES COMPILE_FLAGS "${CFLAGS} -fno-common")
-
-install(TARGETS libglfwStatic libglfwShared DESTINATION lib)
-install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libglfw.pc DESTINATION lib/pkgconfig)
-
diff --git a/src/cocoa/libglfw.pc.cmake b/src/cocoa/libglfw.pc.cmake
deleted file mode 100644
index 37de53a3..00000000
--- a/src/cocoa/libglfw.pc.cmake
+++ /dev/null
@@ -1,11 +0,0 @@
-prefix=@PREFIX@
-exec_prefix=@PREFIX@
-libdir=@PREFIX@/lib
-includedir=@PREFIX@/include
-
-Name: GLFW
-Description: A portable library for OpenGL development
-Version: 3.0
-URL: http://www.glfw.org/
-Libs: -L${libdir} -lglfw -framework AGL -framework OpenGL -framework Carbon
-Cflags: -I${includedir}
diff --git a/src/cocoa/cocoa_enable.m b/src/cocoa_enable.m
similarity index 100%
rename from src/cocoa/cocoa_enable.m
rename to src/cocoa_enable.m
diff --git a/src/cocoa/cocoa_fullscreen.m b/src/cocoa_fullscreen.m
similarity index 100%
rename from src/cocoa/cocoa_fullscreen.m
rename to src/cocoa_fullscreen.m
diff --git a/src/cocoa/cocoa_gamma.m b/src/cocoa_gamma.m
similarity index 100%
rename from src/cocoa/cocoa_gamma.m
rename to src/cocoa_gamma.m
diff --git a/src/cocoa/cocoa_init.m b/src/cocoa_init.m
similarity index 100%
rename from src/cocoa/cocoa_init.m
rename to src/cocoa_init.m
diff --git a/src/cocoa/cocoa_joystick.m b/src/cocoa_joystick.m
similarity index 100%
rename from src/cocoa/cocoa_joystick.m
rename to src/cocoa_joystick.m
diff --git a/src/cocoa/cocoa_opengl.m b/src/cocoa_opengl.m
similarity index 100%
rename from src/cocoa/cocoa_opengl.m
rename to src/cocoa_opengl.m
diff --git a/src/cocoa/platform.h b/src/cocoa_platform.h
similarity index 100%
rename from src/cocoa/platform.h
rename to src/cocoa_platform.h
diff --git a/src/cocoa/cocoa_time.m b/src/cocoa_time.m
similarity index 100%
rename from src/cocoa/cocoa_time.m
rename to src/cocoa_time.m
diff --git a/src/cocoa/cocoa_window.m b/src/cocoa_window.m
similarity index 100%
rename from src/cocoa/cocoa_window.m
rename to src/cocoa_window.m
diff --git a/src/internal.h b/src/internal.h
index 4a39b9c9..2c49aa2b 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -58,11 +58,18 @@
#include "config.h"
-#include "../../include/GL/glfw3.h"
-#include "../../include/GL/glext.h"
-
-#include "platform.h"
-
+#include "../include/GL/glfw3.h"
+#include "../include/GL/glext.h"
+
+#if defined(_GLFW_COCOA_NSGL)
+#include "cocoa_platform.h"
+#elif defined(_GLFW_WIN32_WGL)
+#include "win32_platform.h"
+#elif defined(_GLFW_X11_GLX)
+#include "x11_platform.h"
+#else
+#error "No supported platform selected"
+#endif
typedef struct _GLFWhints _GLFWhints;
typedef struct _GLFWwndconfig _GLFWwndconfig;
diff --git a/src/libglfw.pc.cmake b/src/libglfw.pc.cmake
new file mode 100644
index 00000000..e69de29b
diff --git a/src/win32/CMakeLists.txt b/src/win32/CMakeLists.txt
deleted file mode 100644
index 1220313d..00000000
--- a/src/win32/CMakeLists.txt
+++ /dev/null
@@ -1,59 +0,0 @@
-
-if(CYGWIN)
-
- configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libglfw.pc.cmake
- ${CMAKE_CURRENT_BINARY_DIR}/libglfw.pc @ONLY)
-
-# These lines are intended to remove the --export-all-symbols
-# flag added in the Modules/Platform/CYGWIN.cmake file of the
-# CMake distribution.
-# This is a HACK. If you have trouble _linking_ the GLFW
-# _shared_ library on Cygwin, try disabling this.
- set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared")
- set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS ${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS})
-
-endif(CYGWIN)
-
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}
- ${GLFW_SOURCE_DIR}/src
- ${GLFW_BINARY_DIR}/src
- ${GLFW_INCLUDE_DIR})
-
-set(libglfw_SOURCES ${common_SOURCES}
- win32_enable.c
- win32_fullscreen.c
- win32_gamma.c
- win32_init.c
- win32_joystick.c
- win32_opengl.c
- win32_time.c
- win32_window.c
- win32_dllmain.c)
-
-add_library(libglfwStatic STATIC ${libglfw_SOURCES})
-add_library(libglfwShared SHARED ${libglfw_SOURCES})
-
-target_link_libraries(libglfwShared ${OPENGL_gl_LIBRARY})
-set_target_properties(libglfwShared PROPERTIES
- DEFINE_SYMBOL GLFW_BUILD_DLL
- PREFIX ""
- IMPORT_PREFIX ""
- IMPORT_SUFFIX "dll.lib")
-
-set_target_properties(libglfwStatic libglfwShared PROPERTIES
- CLEAN_DIRECT_OUTPUT 1
- OUTPUT_NAME glfw)
-
-if(CYGWIN)
- # Build for the regular Win32 environment (not Cygwin)
- set_target_properties(libglfwStatic libglfwShared PROPERTIES
- COMPILE_FLAGS "-mwin32 -mno-cygwin"
- LINK_FLAGS "-mwin32 -mno-cygwin")
-endif(CYGWIN)
-
-install(TARGETS libglfwStatic libglfwShared DESTINATION lib)
-
-if(CYGWIN)
- install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libglfw.pc DESTINATION lib/pkgconfig)
-endif(CYGWIN)
-
diff --git a/src/win32/libglfw.pc.cmake b/src/win32/libglfw.pc.cmake
deleted file mode 100644
index 9449ce2e..00000000
--- a/src/win32/libglfw.pc.cmake
+++ /dev/null
@@ -1,11 +0,0 @@
-prefix=@CMAKE_INSTALL_PREFIX@
-exec_prefix=${prefix}
-libdir=${exec_prefix}/lib
-includedir=${prefix}/include
-
-Name: GLFW
-Description: A portable library for OpenGL development
-Version: 3.0
-URL: http://www.glfw.org/
-Libs: -L${libdir} -lglfw @GLFW_LIBRARIES@
-Cflags: -I${includedir} -mwin32
diff --git a/src/win32/win32_dllmain.c b/src/win32_dllmain.c
similarity index 100%
rename from src/win32/win32_dllmain.c
rename to src/win32_dllmain.c
diff --git a/src/win32/win32_enable.c b/src/win32_enable.c
similarity index 100%
rename from src/win32/win32_enable.c
rename to src/win32_enable.c
diff --git a/src/win32/win32_fullscreen.c b/src/win32_fullscreen.c
similarity index 100%
rename from src/win32/win32_fullscreen.c
rename to src/win32_fullscreen.c
diff --git a/src/win32/win32_gamma.c b/src/win32_gamma.c
similarity index 100%
rename from src/win32/win32_gamma.c
rename to src/win32_gamma.c
diff --git a/src/win32/win32_init.c b/src/win32_init.c
similarity index 100%
rename from src/win32/win32_init.c
rename to src/win32_init.c
diff --git a/src/win32/win32_joystick.c b/src/win32_joystick.c
similarity index 100%
rename from src/win32/win32_joystick.c
rename to src/win32_joystick.c
diff --git a/src/win32/win32_opengl.c b/src/win32_opengl.c
similarity index 100%
rename from src/win32/win32_opengl.c
rename to src/win32_opengl.c
diff --git a/src/win32/platform.h b/src/win32_platform.h
similarity index 100%
rename from src/win32/platform.h
rename to src/win32_platform.h
diff --git a/src/win32/win32_time.c b/src/win32_time.c
similarity index 100%
rename from src/win32/win32_time.c
rename to src/win32_time.c
diff --git a/src/win32/win32_window.c b/src/win32_window.c
similarity index 100%
rename from src/win32/win32_window.c
rename to src/win32_window.c
diff --git a/src/x11/CMakeLists.txt b/src/x11/CMakeLists.txt
deleted file mode 100644
index 6369a334..00000000
--- a/src/x11/CMakeLists.txt
+++ /dev/null
@@ -1,30 +0,0 @@
-
-configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libglfw.pc.cmake
- ${CMAKE_CURRENT_BINARY_DIR}/libglfw.pc @ONLY)
-
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}
- ${GLFW_SOURCE_DIR}/src
- ${GLFW_BINARY_DIR}/src
- ${GLFW_INCLUDE_DIR})
-
-set(libglfw_SOURCES ${common_SOURCES}
- x11_enable.c
- x11_fullscreen.c
- x11_gamma.c
- x11_init.c
- x11_joystick.c
- x11_keysym2unicode.c
- x11_opengl.c
- x11_time.c
- x11_window.c)
-
-add_library(libglfwStatic STATIC ${libglfw_SOURCES})
-add_library(libglfwShared SHARED ${libglfw_SOURCES})
-target_link_libraries(libglfwShared ${GLFW_LIBRARIES})
-set_target_properties(libglfwStatic libglfwShared PROPERTIES
- CLEAN_DIRECT_OUTPUT 1
- OUTPUT_NAME glfw)
-
-install(TARGETS libglfwStatic libglfwShared DESTINATION lib)
-install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libglfw.pc DESTINATION lib/pkgconfig)
-
diff --git a/src/x11/libglfw.pc.cmake b/src/x11/libglfw.pc.cmake
deleted file mode 100644
index c9b8a690..00000000
--- a/src/x11/libglfw.pc.cmake
+++ /dev/null
@@ -1,11 +0,0 @@
-prefix=@CMAKE_INSTALL_PREFIX@
-exec_prefix=${prefix}
-libdir=${exec_prefix}/lib
-includedir=${prefix}/include
-
-Name: GLFW
-Description: A portable library for OpenGL development
-Version: 3.0
-URL: http://www.glfw.org/
-Libs: -L${libdir} -lglfw @GLFW_LIBRARIES@
-Cflags: -I${includedir}
diff --git a/src/x11/x11_enable.c b/src/x11_enable.c
similarity index 100%
rename from src/x11/x11_enable.c
rename to src/x11_enable.c
diff --git a/src/x11/x11_fullscreen.c b/src/x11_fullscreen.c
similarity index 100%
rename from src/x11/x11_fullscreen.c
rename to src/x11_fullscreen.c
diff --git a/src/x11/x11_gamma.c b/src/x11_gamma.c
similarity index 100%
rename from src/x11/x11_gamma.c
rename to src/x11_gamma.c
diff --git a/src/x11/x11_init.c b/src/x11_init.c
similarity index 100%
rename from src/x11/x11_init.c
rename to src/x11_init.c
diff --git a/src/x11/x11_joystick.c b/src/x11_joystick.c
similarity index 100%
rename from src/x11/x11_joystick.c
rename to src/x11_joystick.c
diff --git a/src/x11/x11_keysym2unicode.c b/src/x11_keysym2unicode.c
similarity index 100%
rename from src/x11/x11_keysym2unicode.c
rename to src/x11_keysym2unicode.c
diff --git a/src/x11/x11_opengl.c b/src/x11_opengl.c
similarity index 100%
rename from src/x11/x11_opengl.c
rename to src/x11_opengl.c
diff --git a/src/x11/platform.h b/src/x11_platform.h
similarity index 100%
rename from src/x11/platform.h
rename to src/x11_platform.h
diff --git a/src/x11/x11_time.c b/src/x11_time.c
similarity index 100%
rename from src/x11/x11_time.c
rename to src/x11_time.c
diff --git a/src/x11/x11_window.c b/src/x11_window.c
similarity index 100%
rename from src/x11/x11_window.c
rename to src/x11_window.c
From 4c6e24c911964b8c814f3992f1a9a36e4003d388 Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Tue, 26 Jul 2011 16:52:57 +0200
Subject: [PATCH 08/11] Added declaration of size_t.
---
include/GL/glfw3.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/include/GL/glfw3.h b/include/GL/glfw3.h
index 63e5f17f..cba9e9b7 100644
--- a/include/GL/glfw3.h
+++ b/include/GL/glfw3.h
@@ -147,6 +147,10 @@ extern "C" {
/* -------------------- END SYSTEM/COMPILER SPECIFIC --------------------- */
+/* Include the declaration of the size_t type used below.
+ */
+#include
+
/* Include standard OpenGL headers: GLFW uses GL_FALSE/GL_TRUE, and it is
* convenient for the user to only have to include . This also
* solves the problem with Windows and needing some
From 673b42d8daf2de23757d032553c51c9215a37352 Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Tue, 26 Jul 2011 16:59:37 +0200
Subject: [PATCH 09/11] Formatting.
---
src/CMakeLists.txt | 12 ++----------
1 file changed, 2 insertions(+), 10 deletions(-)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 86be028b..dd844fc1 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -22,16 +22,8 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}
${GLFW_BINARY_DIR}/src
${GLFW_INCLUDE_DIR})
-set(common_SOURCES enable.c
- error.c
- fullscreen.c
- gamma.c
- init.c
- input.c
- joystick.c
- opengl.c
- time.c
- window.c)
+set(common_SOURCES enable.c error.c fullscreen.c gamma.c init.c input.c
+ joystick.c opengl.c time.c window.c)
if(_GLFW_COCOA_NSGL)
set(libglfw_SOURCES ${common_SOURCES} cocoa_enable.m cocoa_fullscreen.m
From 7268fc18b4b63f8f65fe294dfeaef0b931514233 Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Wed, 27 Jul 2011 15:46:19 +0200
Subject: [PATCH 10/11] Don't clobber higher-level uninstall targets.
---
CMakeLists.txt | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f0c2eeef..06acbef0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -155,11 +155,14 @@ install(FILES COPYING.txt readme.html
#--------------------------------------------------------------------
# Uninstall operation
+# Don't generate this target if a higher-level project already has
#--------------------------------------------------------------------
-configure_file(${GLFW_SOURCE_DIR}/cmake_uninstall.cmake.in
- ${GLFW_BINARY_DIR}/cmake_uninstall.cmake IMMEDIATE @ONLY)
+if(NOT TARGET uninstall)
+ configure_file(${GLFW_SOURCE_DIR}/cmake_uninstall.cmake.in
+ ${GLFW_BINARY_DIR}/cmake_uninstall.cmake IMMEDIATE @ONLY)
-add_custom_target(uninstall
- ${CMAKE_COMMAND} -P
- ${GLFW_BINARY_DIR}/cmake_uninstall.cmake)
+ add_custom_target(uninstall
+ ${CMAKE_COMMAND} -P
+ ${GLFW_BINARY_DIR}/cmake_uninstall.cmake)
+endif()
From c1ab73b97970a237222d5c6af684a8e10775e1e5 Mon Sep 17 00:00:00 2001
From: Camilla Berglund
Date: Wed, 27 Jul 2011 16:01:27 +0200
Subject: [PATCH 11/11] Renamed context-related functions to more closely match
underlying APIs.
---
include/GL/glfw3.h | 6 +++---
readme.html | 6 +++---
src/cocoa_opengl.m | 15 ++++++++++++++-
src/cocoa_window.m | 14 +-------------
src/internal.h | 4 ++--
src/opengl.c | 42 ++++++++++++++++++++++++++++++++++++++++--
src/win32_opengl.c | 15 ++++++++++++++-
src/win32_window.c | 17 ++---------------
src/window.c | 42 ++----------------------------------------
src/x11_opengl.c | 19 ++++++++++++++++++-
src/x11_window.c | 17 -----------------
tests/sharing.c | 6 +++---
tests/windows.c | 2 +-
13 files changed, 103 insertions(+), 102 deletions(-)
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();
}