Added glfwGetCurrentWindow.
diff --git a/include/GL/glfw3.h b/include/GL/glfw3.h
index c4a6ea4..cc1f01b 100644
--- a/include/GL/glfw3.h
+++ b/include/GL/glfw3.h
@@ -417,6 +417,7 @@
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);
diff --git a/readme.html b/readme.html
index fb08e38..a11b614 100644
--- a/readme.html
+++ b/readme.html
@@ -270,6 +270,7 @@
<li>Added <code>glfwGetWindowPos</code> function for querying the position of the specified window</li>
<li>Added <code>glfwSetWindowFocusCallback</code> function and <code>GLFWwindowfocusfun</code> type for receiving window focus events</li>
<li>Added <code>glfwSetWindowIconifyCallback</code> function and <code>GLFWwindowiconifyfun</code> type for receiving window iconification events</li>
+ <li>Added <code>glfwGetCurrentWindow</code> function for retrieving the window whose OpenGL context is current</li>
<li>Added <code>windows</code> simple multi-window test program</li>
<li>Added <code>sharing</code> simple OpenGL object sharing test program</li>
<li>Added a parameter to <code>glfwOpenWindow</code> for specifying a context the new window's context will share objects with</li>
diff --git a/src/window.c b/src/window.c
index 0129fad..4843d24 100644
--- a/src/window.c
+++ b/src/window.c
@@ -640,6 +640,22 @@
//========================================================================
+// Returns GL_TRUE if the specified window handle is an actual window
+//========================================================================
+
+GLFWAPI GLFWwindow glfwGetCurrentWindow(void)
+{
+ if (!_glfwInitialized)
+ {
+ _glfwSetError(GLFW_NOT_INITIALIZED);
+ return GL_FALSE;
+ }
+
+ return _glfwLibrary.currentWindow;
+}
+
+
+//========================================================================
// Set hints for opening the window
//========================================================================
diff --git a/tests/sharing.c b/tests/sharing.c
index 0c6f598..d2f47db 100644
--- a/tests/sharing.c
+++ b/tests/sharing.c
@@ -72,6 +72,11 @@
static void draw_quad(GLuint texture)
{
+ int width, height;
+ glfwGetWindowSize(glfwGetCurrentWindow(), &width, &height);
+
+ glViewport(0, 0, width, height);
+
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.f, 1.f, 0.f, 1.f);