Merge branch 'master' into multi-monitor
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index a3c26be..723244d 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -9,8 +9,12 @@
 endif()
 
 include_directories(${GLFW_SOURCE_DIR}/include
-                    ${GLFW_SOURCE_DIR}/support
-                    ${OPENGL_INCLUDE_DIR})
+                    ${GLFW_SOURCE_DIR}/support)
+
+if (NOT APPLE)
+    # HACK: This is NOTFOUND on OS X 10.8
+    include_directories(${OPENGL_INCLUDE_DIR})
+endif()
 
 set(GETOPT ${GLFW_SOURCE_DIR}/support/getopt.h
            ${GLFW_SOURCE_DIR}/support/getopt.c)
diff --git a/include/GL/glfw3.h b/include/GL/glfw3.h
index cb3493e..517fe4d 100644
--- a/include/GL/glfw3.h
+++ b/include/GL/glfw3.h
@@ -1135,6 +1135,31 @@
  *  @param[in] target The new value of the window hint.
  *  @ingroup window
  *
+ *  This function sets hints for the next call to @ref glfwCreateWindow.  The
+ *  hints, once set, retain their values until changed by a call to @ref
+ *  glfwWindowHint or @ref glfwDefaultWindowHints, or until the library is
+ *  terminated with @ref glfwTerminate.
+ *
+ *  Some window hints are hard constraints.  These must match the available
+ *  capabilities @em exactly for window and context creation to succeed.  Hints
+ *  that are not hard constraints are matched as closely as possible, but the
+ *  resulting window and context may differ from what these hints requested.  To
+ *  find out the actual properties of the created window and context, use the
+ *  @ref glfwGetWindowParam function.
+ *
+ *  The following hints are hard constraints:
+ *  @arg @ref GLFW_STEREO
+ *  @arg @ref GLFW_CLIENT_API
+ *
+ *  The following additional hints are hard constraints if requesting an OpenGL
+ *  context:
+ *  @arg @ref GLFW_OPENGL_FORWARD_COMPAT
+ *  @arg @ref GLFW_OPENGL_PROFILE
+ *
+ *  Hints that do not apply to a given type of window or context are ignored.
+ *
+ *  @par Framebuffer hints
+ *
  *  The @ref GLFW_RED_BITS, @ref GLFW_GREEN_BITS, @ref GLFW_BLUE_BITS, @ref
  *  GLFW_ALPHA_BITS, @ref GLFW_DEPTH_BITS and @ref GLFW_STENCIL_BITS hints
  *  specify the desired bit depths of the various components of the default
@@ -1160,6 +1185,8 @@
  *  The @ref GLFW_SRGB_CAPABLE hint specifies whether the framebuffer should be
  *  sRGB capable.
  *
+ *  @par Context hints
+ *
  *  The @ref GLFW_CLIENT_API hint specifies which client API to create the
  *  context for.  Possible values are @ref GLFW_OPENGL_API and @ref
  *  GLFW_OPENGL_ES_API.
@@ -1198,6 +1225,8 @@
  *  The @ref GLFW_CONTEXT_ROBUSTNESS hint specifies the robustness strategy to
  *  be used by the context.
  *
+ *  @par Window hints
+ *
  *  The @ref GLFW_RESIZABLE hint specifies whether the window will be resizable
  *  by the user.  The window will still be resizable using the @ref
  *  glfwSetWindowSize function.  This hint is ignored for fullscreen windows.
@@ -1208,22 +1237,6 @@
  *  The @ref GLFW_POSITION_X and @ref GLFW_POSITION_Y hints specify the initial
  *  position of the window.  These hints are ignored for fullscreen windows.
  *
- *  Some window hints are hard constraints.  These must match the available
- *  capabilities @em exactly for window and context creation to succeed.  Hints
- *  that are not hard constraints are matched as closely as possible, but the
- *  resulting window and context may differ from what these hints requested.  To
- *  find out the actual properties of the created window and context, use the
- *  @ref glfwGetWindowParam function.
- *
- *  The following hints are hard constraints:
- *  @arg @ref GLFW_STEREO
- *  @arg @ref GLFW_CLIENT_API
- *
- *  The following additional hints are hard constraints if requesting an OpenGL
- *  context:
- *  @arg @ref GLFW_OPENGL_FORWARD_COMPAT
- *  @arg @ref GLFW_OPENGL_PROFILE
- *
  *  @note This function may only be called from the main thread.
  *
  *  @sa glfwDefaultWindowHints
diff --git a/src/window.c b/src/window.c
index 7a6c1a8..5f7a928 100644
--- a/src/window.c
+++ b/src/window.c
@@ -489,6 +489,20 @@
     if (window == NULL)
         return;
 
+    // Clear all callbacks to avoid exposing a half torn-down window object
+    window->windowPosCallback = NULL;
+    window->windowSizeCallback = NULL;
+    window->windowCloseCallback = NULL;
+    window->windowRefreshCallback = NULL;
+    window->windowFocusCallback = NULL;
+    window->windowIconifyCallback = NULL;
+    window->mouseButtonCallback = NULL;
+    window->cursorPosCallback = NULL;
+    window->cursorEnterCallback = NULL;
+    window->scrollCallback = NULL;
+    window->keyCallback = NULL;
+    window->charCallback = NULL;
+
     // The window's context must not be current on another thread when the
     // window is destroyed
     if (window == _glfwPlatformGetCurrentContext())
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 11bcfe9..3020126 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -14,8 +14,12 @@
 endif()
 
 include_directories(${GLFW_SOURCE_DIR}/include
-                    ${GLFW_SOURCE_DIR}/support
-                    ${OPENGL_INCLUDE_DIR})
+                    ${GLFW_SOURCE_DIR}/support)
+
+if (NOT APPLE)
+    # HACK: This is NOTFOUND on OS X 10.8
+    include_directories(${OPENGL_INCLUDE_DIR})
+endif()
 
 set(GETOPT ${GLFW_SOURCE_DIR}/support/getopt.h
            ${GLFW_SOURCE_DIR}/support/getopt.c)