11/* ************************************************************************
2- * GLFW 3.2 - www.glfw.org
2+ * GLFW 3.3 - www.glfw.org
33 * A library for OpenGL, window and input
44 *------------------------------------------------------------------------
55 * Copyright (c) 2002-2006 Marcus Geelnard
6- * Copyright (c) 2006-2016 Camilla Berglund <elmindreda@glfw.org>
6+ * Copyright (c) 2006-2018 Camilla Löwy <elmindreda@glfw.org>
77 *
88 * This software is provided 'as-is', without any express or implied
99 * warranty. In no event will the authors be held liable for any damages
@@ -45,12 +45,13 @@ extern "C" {
4545 * more information.
4646 */
4747/* ! @defgroup native Native access
48+ * @brief Functions related to accessing native handles.
4849 *
4950 * **By using the native access functions you assert that you know what you're
5051 * doing and how to fix problems caused by using them. If you don't, you
5152 * shouldn't be using them.**
5253 *
53- * Before the inclusion of @ref glfw3native.h, you may define exactly one
54+ * Before the inclusion of @ref glfw3native.h, you may define zero or more
5455 * window system API macro and zero or more context creation API macros.
5556 *
5657 * The chosen backends must match those the library was compiled for. Failure
@@ -61,13 +62,13 @@ extern "C" {
6162 * * `GLFW_EXPOSE_NATIVE_COCOA`
6263 * * `GLFW_EXPOSE_NATIVE_X11`
6364 * * `GLFW_EXPOSE_NATIVE_WAYLAND`
64- * * `GLFW_EXPOSE_NATIVE_MIR`
6565 *
6666 * The available context API macros are:
6767 * * `GLFW_EXPOSE_NATIVE_WGL`
6868 * * `GLFW_EXPOSE_NATIVE_NSGL`
6969 * * `GLFW_EXPOSE_NATIVE_GLX`
7070 * * `GLFW_EXPOSE_NATIVE_EGL`
71+ * * `GLFW_EXPOSE_NATIVE_OSMESA`
7172 *
7273 * These macros select which of the native access functions that are declared
7374 * and which platform-specific headers to include. It is then up your (by
@@ -80,26 +81,27 @@ extern "C" {
8081 * System headers and types
8182 *************************************************************************/
8283
83- #if defined(GLFW_EXPOSE_NATIVE_WIN32)
84+ #if defined(GLFW_EXPOSE_NATIVE_WIN32) || defined(GLFW_EXPOSE_NATIVE_WGL)
8485 // This is a workaround for the fact that glfw3.h needs to export APIENTRY (for
8586 // example to allow applications to correctly declare a GL_ARB_debug_output
8687 // callback) but windows.h assumes no one will define APIENTRY before it does
87- #undef APIENTRY
88+ #if defined(GLFW_APIENTRY_DEFINED)
89+ #undef APIENTRY
90+ #undef GLFW_APIENTRY_DEFINED
91+ #endif
8892 #include < windows.h>
89- #elif defined(GLFW_EXPOSE_NATIVE_COCOA)
90- // #include <ApplicationServices/ApplicationServices.h>
93+ #elif defined(GLFW_EXPOSE_NATIVE_COCOA) || defined(GLFW_EXPOSE_NATIVE_NSGL)
9194 #if defined(__OBJC__)
9295 #import < Cocoa/Cocoa.h>
9396 #else
97+ // #include <ApplicationServices/ApplicationServices.h>
9498 typedef void * id ;
9599 #endif
96- #elif defined(GLFW_EXPOSE_NATIVE_X11)
100+ #elif defined(GLFW_EXPOSE_NATIVE_X11) || defined(GLFW_EXPOSE_NATIVE_GLX)
97101 #include < X11/Xlib.h>
98102 #include < X11/extensions/Xrandr.h>
99103#elif defined(GLFW_EXPOSE_NATIVE_WAYLAND)
100104 #include < wayland-client.h>
101- #elif defined(GLFW_EXPOSE_NATIVE_MIR)
102- #include < mir_toolkit/mir_client_library.h>
103105#endif
104106
105107#if defined(GLFW_EXPOSE_NATIVE_WGL)
@@ -114,6 +116,9 @@ extern "C" {
114116#if defined(GLFW_EXPOSE_NATIVE_EGL)
115117 #include < EGL/egl.h>
116118#endif
119+ #if defined(GLFW_EXPOSE_NATIVE_OSMESA)
120+ #include < GL/osmesa.h>
121+ #endif
117122
118123
119124/* ************************************************************************
@@ -284,6 +289,56 @@ GLFWAPI RROutput glfwGetX11Monitor(GLFWmonitor* monitor);
284289 * @ingroup native
285290 */
286291GLFWAPI Window glfwGetX11Window (GLFWwindow* window);
292+
293+ /* ! @brief Sets the current primary selection to the specified string.
294+ *
295+ * @param[in] string A UTF-8 encoded string.
296+ *
297+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
298+ * GLFW_PLATFORM_ERROR.
299+ *
300+ * @pointer_lifetime The specified string is copied before this function
301+ * returns.
302+ *
303+ * @thread_safety This function must only be called from the main thread.
304+ *
305+ * @sa @ref clipboard
306+ * @sa glfwGetX11SelectionString
307+ * @sa glfwSetClipboardString
308+ *
309+ * @since Added in version 3.3.
310+ *
311+ * @ingroup native
312+ */
313+ GLFWAPI void glfwSetX11SelectionString (const char * string);
314+
315+ /* ! @brief Returns the contents of the current primary selection as a string.
316+ *
317+ * If the selection is empty or if its contents cannot be converted, `NULL`
318+ * is returned and a @ref GLFW_FORMAT_UNAVAILABLE error is generated.
319+ *
320+ * @return The contents of the selection as a UTF-8 encoded string, or `NULL`
321+ * if an [error](@ref error_handling) occurred.
322+ *
323+ * @errors Possible errors include @ref GLFW_NOT_INITIALIZED and @ref
324+ * GLFW_PLATFORM_ERROR.
325+ *
326+ * @pointer_lifetime The returned string is allocated and freed by GLFW. You
327+ * should not free it yourself. It is valid until the next call to @ref
328+ * glfwGetX11SelectionString or @ref glfwSetX11SelectionString, or until the
329+ * library is terminated.
330+ *
331+ * @thread_safety This function must only be called from the main thread.
332+ *
333+ * @sa @ref clipboard
334+ * @sa glfwSetX11SelectionString
335+ * @sa glfwGetClipboardString
336+ *
337+ * @since Added in version 3.3.
338+ *
339+ * @ingroup native
340+ */
341+ GLFWAPI const char * glfwGetX11SelectionString (void );
287342#endif
288343
289344#if defined(GLFW_EXPOSE_NATIVE_GLX)
@@ -360,92 +415,106 @@ GLFWAPI struct wl_output* glfwGetWaylandMonitor(GLFWmonitor* monitor);
360415GLFWAPI struct wl_surface* glfwGetWaylandWindow (GLFWwindow* window);
361416#endif
362417
363- #if defined(GLFW_EXPOSE_NATIVE_MIR )
364- /* ! @brief Returns the `MirConnection* ` used by GLFW.
418+ #if defined(GLFW_EXPOSE_NATIVE_EGL )
419+ /* ! @brief Returns the `EGLDisplay ` used by GLFW.
365420 *
366- * @return The `MirConnection* ` used by GLFW, or `NULL ` if an
421+ * @return The `EGLDisplay ` used by GLFW, or `EGL_NO_DISPLAY ` if an
367422 * [error](@ref error_handling) occurred.
368423 *
369424 * @thread_safety This function may be called from any thread. Access is not
370425 * synchronized.
371426 *
372- * @since Added in version 3.2 .
427+ * @since Added in version 3.0 .
373428 *
374429 * @ingroup native
375430 */
376- GLFWAPI MirConnection* glfwGetMirDisplay (void );
431+ GLFWAPI EGLDisplay glfwGetEGLDisplay (void );
377432
378- /* ! @brief Returns the Mir output ID of the specified monitor .
433+ /* ! @brief Returns the `EGLContext` of the specified window .
379434 *
380- * @return The Mir output ID of the specified monitor , or zero if an
435+ * @return The `EGLContext` of the specified window , or `EGL_NO_CONTEXT` if an
381436 * [error](@ref error_handling) occurred.
382437 *
383438 * @thread_safety This function may be called from any thread. Access is not
384439 * synchronized.
385440 *
386- * @since Added in version 3.2 .
441+ * @since Added in version 3.0 .
387442 *
388443 * @ingroup native
389444 */
390- GLFWAPI int glfwGetMirMonitor (GLFWmonitor* monitor );
445+ GLFWAPI EGLContext glfwGetEGLContext (GLFWwindow* window );
391446
392- /* ! @brief Returns the `MirSurface* ` of the specified window.
447+ /* ! @brief Returns the `EGLSurface ` of the specified window.
393448 *
394- * @return The `MirSurface* ` of the specified window, or `NULL ` if an
449+ * @return The `EGLSurface ` of the specified window, or `EGL_NO_SURFACE ` if an
395450 * [error](@ref error_handling) occurred.
396451 *
397452 * @thread_safety This function may be called from any thread. Access is not
398453 * synchronized.
399454 *
400- * @since Added in version 3.2 .
455+ * @since Added in version 3.0 .
401456 *
402457 * @ingroup native
403458 */
404- GLFWAPI MirSurface* glfwGetMirWindow (GLFWwindow* window);
459+ GLFWAPI EGLSurface glfwGetEGLSurface (GLFWwindow* window);
405460#endif
406461
407- #if defined(GLFW_EXPOSE_NATIVE_EGL)
408- /* ! @brief Returns the `EGLDisplay` used by GLFW.
409- *
410- * @return The `EGLDisplay` used by GLFW, or `EGL_NO_DISPLAY` if an
462+ #if defined(GLFW_EXPOSE_NATIVE_OSMESA)
463+ /* ! @brief Retrieves the color buffer associated with the specified window.
464+ *
465+ * @param[in] window The window whose color buffer to retrieve.
466+ * @param[out] width Where to store the width of the color buffer, or `NULL`.
467+ * @param[out] height Where to store the height of the color buffer, or `NULL`.
468+ * @param[out] format Where to store the OSMesa pixel format of the color
469+ * buffer, or `NULL`.
470+ * @param[out] buffer Where to store the address of the color buffer, or
471+ * `NULL`.
472+ * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
411473 * [error](@ref error_handling) occurred.
412474 *
413475 * @thread_safety This function may be called from any thread. Access is not
414476 * synchronized.
415477 *
416- * @since Added in version 3.0 .
478+ * @since Added in version 3.3 .
417479 *
418480 * @ingroup native
419481 */
420- GLFWAPI EGLDisplay glfwGetEGLDisplay (void );
421-
422- /* ! @brief Returns the `EGLContext` of the specified window.
423- *
424- * @return The `EGLContext` of the specified window, or `EGL_NO_CONTEXT` if an
482+ GLFWAPI int glfwGetOSMesaColorBuffer (GLFWwindow* window, int * width, int * height, int * format, void ** buffer);
483+
484+ /* ! @brief Retrieves the depth buffer associated with the specified window.
485+ *
486+ * @param[in] window The window whose depth buffer to retrieve.
487+ * @param[out] width Where to store the width of the depth buffer, or `NULL`.
488+ * @param[out] height Where to store the height of the depth buffer, or `NULL`.
489+ * @param[out] bytesPerValue Where to store the number of bytes per depth
490+ * buffer element, or `NULL`.
491+ * @param[out] buffer Where to store the address of the depth buffer, or
492+ * `NULL`.
493+ * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an
425494 * [error](@ref error_handling) occurred.
426495 *
427496 * @thread_safety This function may be called from any thread. Access is not
428497 * synchronized.
429498 *
430- * @since Added in version 3.0 .
499+ * @since Added in version 3.3 .
431500 *
432501 * @ingroup native
433502 */
434- GLFWAPI EGLContext glfwGetEGLContext (GLFWwindow* window);
503+ GLFWAPI int glfwGetOSMesaDepthBuffer (GLFWwindow* window, int * width, int * height, int * bytesPerValue, void ** buffer );
435504
436- /* ! @brief Returns the `EGLSurface ` of the specified window.
505+ /* ! @brief Returns the `OSMesaContext ` of the specified window.
437506 *
438- * @return The `EGLSurface ` of the specified window, or `EGL_NO_SURFACE ` if an
507+ * @return The `OSMesaContext ` of the specified window, or `NULL ` if an
439508 * [error](@ref error_handling) occurred.
440509 *
441510 * @thread_safety This function may be called from any thread. Access is not
442511 * synchronized.
443512 *
444- * @since Added in version 3.0 .
513+ * @since Added in version 3.3 .
445514 *
446515 * @ingroup native
447516 */
448- GLFWAPI EGLSurface glfwGetEGLSurface (GLFWwindow* window);
517+ GLFWAPI OSMesaContext glfwGetOSMesaContext (GLFWwindow* window);
449518#endif
450519
451520#ifdef __cplusplus
0 commit comments