1
1
/* ************************************************************************
2
- * GLFW 3.2 - www.glfw.org
2
+ * GLFW 3.3 - www.glfw.org
3
3
* A library for OpenGL, window and input
4
4
*------------------------------------------------------------------------
5
5
* Copyright (c) 2002-2006 Marcus Geelnard
6
- * Copyright (c) 2006-2016 Camilla Berglund <[email protected] >
6
+ * Copyright (c) 2006-2018 Camilla Löwy <[email protected] >
7
7
*
8
8
* This software is provided 'as-is', without any express or implied
9
9
* warranty. In no event will the authors be held liable for any damages
@@ -45,12 +45,13 @@ extern "C" {
45
45
* more information.
46
46
*/
47
47
/* ! @defgroup native Native access
48
+ * @brief Functions related to accessing native handles.
48
49
*
49
50
* **By using the native access functions you assert that you know what you're
50
51
* doing and how to fix problems caused by using them. If you don't, you
51
52
* shouldn't be using them.**
52
53
*
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
54
55
* window system API macro and zero or more context creation API macros.
55
56
*
56
57
* The chosen backends must match those the library was compiled for. Failure
@@ -61,13 +62,13 @@ extern "C" {
61
62
* * `GLFW_EXPOSE_NATIVE_COCOA`
62
63
* * `GLFW_EXPOSE_NATIVE_X11`
63
64
* * `GLFW_EXPOSE_NATIVE_WAYLAND`
64
- * * `GLFW_EXPOSE_NATIVE_MIR`
65
65
*
66
66
* The available context API macros are:
67
67
* * `GLFW_EXPOSE_NATIVE_WGL`
68
68
* * `GLFW_EXPOSE_NATIVE_NSGL`
69
69
* * `GLFW_EXPOSE_NATIVE_GLX`
70
70
* * `GLFW_EXPOSE_NATIVE_EGL`
71
+ * * `GLFW_EXPOSE_NATIVE_OSMESA`
71
72
*
72
73
* These macros select which of the native access functions that are declared
73
74
* and which platform-specific headers to include. It is then up your (by
@@ -80,26 +81,27 @@ extern "C" {
80
81
* System headers and types
81
82
*************************************************************************/
82
83
83
- #if defined(GLFW_EXPOSE_NATIVE_WIN32)
84
+ #if defined(GLFW_EXPOSE_NATIVE_WIN32) || defined(GLFW_EXPOSE_NATIVE_WGL)
84
85
// This is a workaround for the fact that glfw3.h needs to export APIENTRY (for
85
86
// example to allow applications to correctly declare a GL_ARB_debug_output
86
87
// 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
88
92
#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)
91
94
#if defined(__OBJC__)
92
95
#import < Cocoa/Cocoa.h>
93
96
#else
97
+ // #include <ApplicationServices/ApplicationServices.h>
94
98
typedef void * id ;
95
99
#endif
96
- #elif defined(GLFW_EXPOSE_NATIVE_X11)
100
+ #elif defined(GLFW_EXPOSE_NATIVE_X11) || defined(GLFW_EXPOSE_NATIVE_GLX)
97
101
#include < X11/Xlib.h>
98
102
#include < X11/extensions/Xrandr.h>
99
103
#elif defined(GLFW_EXPOSE_NATIVE_WAYLAND)
100
104
#include < wayland-client.h>
101
- #elif defined(GLFW_EXPOSE_NATIVE_MIR)
102
- #include < mir_toolkit/mir_client_library.h>
103
105
#endif
104
106
105
107
#if defined(GLFW_EXPOSE_NATIVE_WGL)
@@ -114,6 +116,9 @@ extern "C" {
114
116
#if defined(GLFW_EXPOSE_NATIVE_EGL)
115
117
#include < EGL/egl.h>
116
118
#endif
119
+ #if defined(GLFW_EXPOSE_NATIVE_OSMESA)
120
+ #include < GL/osmesa.h>
121
+ #endif
117
122
118
123
119
124
/* ************************************************************************
@@ -284,6 +289,56 @@ GLFWAPI RROutput glfwGetX11Monitor(GLFWmonitor* monitor);
284
289
* @ingroup native
285
290
*/
286
291
GLFWAPI 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 );
287
342
#endif
288
343
289
344
#if defined(GLFW_EXPOSE_NATIVE_GLX)
@@ -360,92 +415,106 @@ GLFWAPI struct wl_output* glfwGetWaylandMonitor(GLFWmonitor* monitor);
360
415
GLFWAPI struct wl_surface* glfwGetWaylandWindow (GLFWwindow* window);
361
416
#endif
362
417
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.
365
420
*
366
- * @return The `MirConnection* ` used by GLFW, or `NULL ` if an
421
+ * @return The `EGLDisplay ` used by GLFW, or `EGL_NO_DISPLAY ` if an
367
422
* [error](@ref error_handling) occurred.
368
423
*
369
424
* @thread_safety This function may be called from any thread. Access is not
370
425
* synchronized.
371
426
*
372
- * @since Added in version 3.2 .
427
+ * @since Added in version 3.0 .
373
428
*
374
429
* @ingroup native
375
430
*/
376
- GLFWAPI MirConnection* glfwGetMirDisplay (void );
431
+ GLFWAPI EGLDisplay glfwGetEGLDisplay (void );
377
432
378
- /* ! @brief Returns the Mir output ID of the specified monitor .
433
+ /* ! @brief Returns the `EGLContext` of the specified window .
379
434
*
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
381
436
* [error](@ref error_handling) occurred.
382
437
*
383
438
* @thread_safety This function may be called from any thread. Access is not
384
439
* synchronized.
385
440
*
386
- * @since Added in version 3.2 .
441
+ * @since Added in version 3.0 .
387
442
*
388
443
* @ingroup native
389
444
*/
390
- GLFWAPI int glfwGetMirMonitor (GLFWmonitor* monitor );
445
+ GLFWAPI EGLContext glfwGetEGLContext (GLFWwindow* window );
391
446
392
- /* ! @brief Returns the `MirSurface* ` of the specified window.
447
+ /* ! @brief Returns the `EGLSurface ` of the specified window.
393
448
*
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
395
450
* [error](@ref error_handling) occurred.
396
451
*
397
452
* @thread_safety This function may be called from any thread. Access is not
398
453
* synchronized.
399
454
*
400
- * @since Added in version 3.2 .
455
+ * @since Added in version 3.0 .
401
456
*
402
457
* @ingroup native
403
458
*/
404
- GLFWAPI MirSurface* glfwGetMirWindow (GLFWwindow* window);
459
+ GLFWAPI EGLSurface glfwGetEGLSurface (GLFWwindow* window);
405
460
#endif
406
461
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
411
473
* [error](@ref error_handling) occurred.
412
474
*
413
475
* @thread_safety This function may be called from any thread. Access is not
414
476
* synchronized.
415
477
*
416
- * @since Added in version 3.0 .
478
+ * @since Added in version 3.3 .
417
479
*
418
480
* @ingroup native
419
481
*/
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
425
494
* [error](@ref error_handling) occurred.
426
495
*
427
496
* @thread_safety This function may be called from any thread. Access is not
428
497
* synchronized.
429
498
*
430
- * @since Added in version 3.0 .
499
+ * @since Added in version 3.3 .
431
500
*
432
501
* @ingroup native
433
502
*/
434
- GLFWAPI EGLContext glfwGetEGLContext (GLFWwindow* window);
503
+ GLFWAPI int glfwGetOSMesaDepthBuffer (GLFWwindow* window, int * width, int * height, int * bytesPerValue, void ** buffer );
435
504
436
- /* ! @brief Returns the `EGLSurface ` of the specified window.
505
+ /* ! @brief Returns the `OSMesaContext ` of the specified window.
437
506
*
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
439
508
* [error](@ref error_handling) occurred.
440
509
*
441
510
* @thread_safety This function may be called from any thread. Access is not
442
511
* synchronized.
443
512
*
444
- * @since Added in version 3.0 .
513
+ * @since Added in version 3.3 .
445
514
*
446
515
* @ingroup native
447
516
*/
448
- GLFWAPI EGLSurface glfwGetEGLSurface (GLFWwindow* window);
517
+ GLFWAPI OSMesaContext glfwGetOSMesaContext (GLFWwindow* window);
449
518
#endif
450
519
451
520
#ifdef __cplusplus
0 commit comments