Cleanup
Related to #786.
diff --git a/README.md b/README.md
index 40e9544..507ce95 100644
--- a/README.md
+++ b/README.md
@@ -11,8 +11,9 @@
creating windows, contexts and surfaces, reading input, handling events, etc.
GLFW natively supports Windows, macOS and Linux and other Unix-like systems.
-Experimental implementations for the Wayland protocol and the Mir display server
-are available but not yet officially supported.
+Experimental implementations for the Wayland protocol, the Mir display server
+and direct rendering via EGLDevice are available but not yet officially
+supported.
GLFW is licensed under the [zlib/libpng
license](http://www.glfw.org/license.html).
@@ -91,6 +92,9 @@
The (experimental) Wayland backend also depends on the `extra-cmake-modules`
package, which is used to generated Wayland protocol headers.
+The (experimental) EGLDevice backend also depends on the `libdrm-dev`
+development package.
+
The examples and test programs depend on a number of tiny libraries. These are
located in the `deps/` directory.
@@ -208,6 +212,7 @@
- [X11] Bugfix: Incremental reading of selections was not supported (#275)
- [X11] Bugfix: Selection I/O reported but did not support `COMPOUND_TEXT`
- [X11] Bugfix: Latin-1 text read from selections was not converted to UTF-8
+- [Linux] Added experimental support for direct rendering via EGLDevice (#786)
- [Linux] Moved to evdev for joystick input (#906,#1005)
- [Linux] Bugfix: Event processing did not detect joystick disconnection (#932)
- [Linux] Bugfix: The joystick device path could be truncated (#1025)
@@ -282,6 +287,7 @@
- David Carlier
- Arturo Castro
- Chi-kwan Chan
+ - Kamal Chandra
- Ian Clarkson
- Michał Cichoń
- Lambert Clara
diff --git a/docs/compile.dox b/docs/compile.dox
index 35d6573..cc11a7a 100644
--- a/docs/compile.dox
+++ b/docs/compile.dox
@@ -257,6 +257,7 @@
- @b _GLFW_WAYLAND to use the Wayland API (experimental and incomplete)
- @b _GLFW_MIR to use the Mir API (experimental and incomplete)
- @b _GLFW_OSMESA to use the OSMesa API (headless and non-interactive)
+ - @b _GLFW_EGLDEVICE to use the EGLDevice API (experimental and incomplete)
If you are building GLFW as a shared library / dynamic library / DLL then you
must also define @b _GLFW_BUILD_DLL. Otherwise, you must not define it.
diff --git a/src/egldevice_init.c b/src/egldevice_init.c
index 1372895..157383f 100644
--- a/src/egldevice_init.c
+++ b/src/egldevice_init.c
@@ -1,5 +1,5 @@
//========================================================================
-// GLFW 3.2 EGLDevice - www.glfw.org
+// GLFW 3.3 EGLDevice - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
//
@@ -28,44 +28,44 @@
#include <linux/limits.h>
-static GLFWbool initializeExtensions()
+static GLFWbool initializeExtensions(void)
{
- _glfw.egldevice.eglQueryDevicesEXT =
+ _glfw.egldevice.QueryDevicesEXT =
(PFNEGLQUERYDEVICESEXTPROC)
- _glfw.egl.GetProcAddress("eglQueryDevicesEXT");
- _glfw.egldevice.eglQueryDeviceStringEXT =
+ eglGetProcAddress("eglQueryDevicesEXT");
+ _glfw.egldevice.QueryDeviceStringEXT =
(PFNEGLQUERYDEVICESTRINGEXTPROC)
- _glfw.egl.GetProcAddress("eglQueryDeviceStringEXT");
- _glfw.egldevice.eglGetPlatformDisplayEXT =
+ eglGetProcAddress("eglQueryDeviceStringEXT");
+ _glfw.egldevice.GetPlatformDisplayEXT =
(PFNEGLGETPLATFORMDISPLAYEXTPROC)
- _glfw.egl.GetProcAddress("eglGetPlatformDisplayEXT");
- _glfw.egldevice.eglGetOutputLayersEXT =
+ eglGetProcAddress("eglGetPlatformDisplayEXT");
+ _glfw.egldevice.GetOutputLayersEXT =
(PFNEGLGETOUTPUTLAYERSEXTPROC)
- _glfw.egl.GetProcAddress("eglGetOutputLayersEXT");
- _glfw.egldevice.eglCreateStreamKHR =
+ eglGetProcAddress("eglGetOutputLayersEXT");
+ _glfw.egldevice.CreateStreamKHR =
(PFNEGLCREATESTREAMKHRPROC)
- _glfw.egl.GetProcAddress("eglCreateStreamKHR");
- _glfw.egldevice.eglDestroyStreamKHR =
+ eglGetProcAddress("eglCreateStreamKHR");
+ _glfw.egldevice.DestroyStreamKHR =
(PFNEGLDESTROYSTREAMKHRPROC)
- _glfw.egl.GetProcAddress("eglDestroyStreamKHR");
- _glfw.egldevice.eglStreamConsumerOutputEXT =
+ eglGetProcAddress("eglDestroyStreamKHR");
+ _glfw.egldevice.StreamConsumerOutputEXT =
(PFNEGLSTREAMCONSUMEROUTPUTEXTPROC)
- _glfw.egl.GetProcAddress("eglStreamConsumerOutputEXT");
- _glfw.egldevice.eglCreateStreamProducerSurfaceKHR =
+ eglGetProcAddress("eglStreamConsumerOutputEXT");
+ _glfw.egldevice.CreateStreamProducerSurfaceKHR =
(PFNEGLCREATESTREAMPRODUCERSURFACEKHRPROC)
- _glfw.egl.GetProcAddress("eglCreateStreamProducerSurfaceKHR");
+ eglGetProcAddress("eglCreateStreamProducerSurfaceKHR");
- if(!_glfw.egldevice.eglQueryDevicesEXT ||
- !_glfw.egldevice.eglQueryDeviceStringEXT ||
- !_glfw.egldevice.eglGetPlatformDisplayEXT ||
- !_glfw.egldevice.eglGetOutputLayersEXT ||
- !_glfw.egldevice.eglCreateStreamKHR ||
- !_glfw.egldevice.eglDestroyStreamKHR ||
- !_glfw.egldevice.eglStreamConsumerOutputEXT ||
- !_glfw.egldevice.eglCreateStreamProducerSurfaceKHR)
+ if(!_glfw.egldevice.QueryDevicesEXT ||
+ !_glfw.egldevice.QueryDeviceStringEXT ||
+ !_glfw.egldevice.GetPlatformDisplayEXT ||
+ !_glfw.egldevice.GetOutputLayersEXT ||
+ !_glfw.egldevice.CreateStreamKHR ||
+ !_glfw.egldevice.DestroyStreamKHR ||
+ !_glfw.egldevice.StreamConsumerOutputEXT ||
+ !_glfw.egldevice.CreateStreamProducerSurfaceKHR)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
- "EGLDevice: Missing required function(s)");
+ "EGLDevice: Failed to find required EGL extension functions");
return GLFW_FALSE;
}
return GLFW_TRUE;
@@ -90,7 +90,7 @@
"EGLDevice: EGL_EXT_device base extensions not found");
}
- if (!_glfw.egldevice.eglQueryDevicesEXT(0, NULL, &num_devs))
+ if (!eglQueryDevicesEXT(0, NULL, &num_devs))
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"EGLDevice: Falied to query EGLDevice");
@@ -98,7 +98,7 @@
if (num_devs < 1)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
- "EGLDevice: No Devices Found");
+ "EGLDevice: No devices found");
}
egl_devs = calloc(sizeof(EGLDeviceEXT), num_devs);
@@ -109,7 +109,7 @@
}
// Select suitable device
- if (!_glfw.egldevice.eglQueryDevicesEXT(num_devs, egl_devs, &num_devs))
+ if (!eglQueryDevicesEXT(num_devs, egl_devs, &num_devs))
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"EGLDevice: Failed to query EGL devices");
@@ -119,8 +119,7 @@
{
const char* deviceExtensionString;
- deviceExtensionString =
- _glfw.egldevice.eglQueryDeviceStringEXT(egl_devs[i], EGL_EXTENSIONS);
+ deviceExtensionString = eglQueryDeviceStringEXT(egl_devs[i], EGL_EXTENSIONS);
if (_glfwStringInExtensionString("EGL_EXT_device_drm",
deviceExtensionString))
{
@@ -134,8 +133,7 @@
if (eglDevice == EGL_NO_DEVICE_EXT)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
- "EGLDevice: Missing required extension:"
- " EGL_EXT_device_drm");
+ "EGLDevice: Missing required extension EGL_EXT_device_drm");
}
return eglDevice;
}
@@ -145,8 +143,7 @@
int drm_fd;
const char* drmName;
- drmName = _glfw.egldevice.eglQueryDeviceStringEXT(eglDevice,
- EGL_DRM_DEVICE_FILE_EXT);
+ drmName = eglQueryDeviceStringEXT(eglDevice, EGL_DRM_DEVICE_FILE_EXT);
if (!drmName || (strnlen(drmName, PATH_MAX) == 0))
{
_glfwInputError(GLFW_PLATFORM_ERROR,
@@ -173,8 +170,7 @@
EGL_NONE
};
- _glfw.egl.display =
- _glfw.egldevice.eglGetPlatformDisplayEXT(EGL_PLATFORM_DEVICE_EXT,
+ _glfw.egl.display = eglGetPlatformDisplayEXT(EGL_PLATFORM_DEVICE_EXT,
(void*)egl_dev,
displayAttribs);
if (_glfw.egl.display == EGL_NO_DISPLAY)
@@ -196,8 +192,7 @@
displayExtensionString))
{
_glfwInputError(GLFW_PLATFORM_ERROR,
- "EGLDevice: Missing required extension:"
- " EGL_EXT_output_base");
+ "EGLDevice: Missing required extension EGL_EXT_output_base");
return GLFW_FALSE;
}
@@ -205,8 +200,7 @@
displayExtensionString))
{
_glfwInputError(GLFW_PLATFORM_ERROR,
- "EGLDevice: Missing required extension:"
- " EGL_EXT_output_drm");
+ "EGLDevice: Missing required extension EGL_EXT_output_drm");
return GLFW_FALSE;
}
@@ -214,8 +208,7 @@
displayExtensionString))
{
_glfwInputError(GLFW_PLATFORM_ERROR,
- "EGLDevice: Missing required extension:"
- " EGL_KHR_stream");
+ "EGLDevice: Missing required extension EGL_KHR_stream");
return GLFW_FALSE;
}
@@ -223,16 +216,14 @@
displayExtensionString))
{
_glfwInputError(GLFW_PLATFORM_ERROR,
- "EGLDevice: Missing required extension:"
- " EGL_KHR_stream_producer_eglsurface");
+ "EGLDevice: Missing required extension EGL_KHR_stream_producer_eglsurface");
return GLFW_FALSE;
}
if (!_glfwStringInExtensionString("EGL_EXT_stream_consumer_egloutput",
displayExtensionString))
{
_glfwInputError(GLFW_PLATFORM_ERROR,
- "EGLDevice: Missing required extension:"
- " EGL_EXT_stream_consumer_egloutput");
+ "EGLDevice: Missing required extension EGL_EXT_stream_consumer_egloutput");
return GLFW_FALSE;
}
@@ -290,3 +281,4 @@
#endif
;
}
+
diff --git a/src/egldevice_monitor.c b/src/egldevice_monitor.c
index 4024df9..ed9d74a 100644
--- a/src/egldevice_monitor.c
+++ b/src/egldevice_monitor.c
@@ -1,5 +1,5 @@
//========================================================================
-// GLFW 3.2 EGLDevice - www.glfw.org
+// GLFW 3.3 EGLDevice - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
//
@@ -58,8 +58,7 @@
drmModeGetEncoder(drm_fd, monitor->egldevice.encId);
if (!enc_info) {
_glfwInputError(GLFW_PLATFORM_ERROR,
- "EGLDevice: Unable to query DRM-KMS"
- " information for connector index %d", i);
+ "EGLDevice: Unable to query DRM-KMS information for connector index %d", i);
}
// Select the modesize
@@ -163,3 +162,4 @@
_glfwInputError(GLFW_PLATFORM_ERROR,
"EGLDevice: _glfwPlatformSetGammaRamp not implemented");
}
+
diff --git a/src/egldevice_platform.h b/src/egldevice_platform.h
index 0fdfe6b..ce3867e 100644
--- a/src/egldevice_platform.h
+++ b/src/egldevice_platform.h
@@ -1,5 +1,5 @@
//========================================================================
-// GLFW 3.2 EGLDevice - www.glfw.org
+// GLFW 3.3 EGLDevice - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
//
@@ -24,9 +24,6 @@
//
//========================================================================
-#ifndef _glfw3_egldevice_h_
-#define _glfw3_egldevice_h_
-
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
@@ -77,6 +74,16 @@
typedef EGLSurface (EGLAPIENTRY * PFNEGLCREATESTREAMPRODUCERSURFACEKHRPROC)(EGLDisplay,EGLConfig,EGLStreamKHR,const EGLint*);
typedef EGLBoolean (EGLAPIENTRY * PFNEGLSTREAMATTRIBKHRPROC)(EGLDisplay,EGLStreamKHR,EGLenum,EGLint);
typedef EGLBoolean (EGLAPIENTRY * PFNEGLSTREAMCONSUMERACQUIREATTRIBKHRPROC)(EGLDisplay,EGLStreamKHR,const EGLAttrib*);
+#define eglQueryDevicesEXT _glfw.egldevice.QueryDevicesEXT
+#define eglQueryDeviceStringEXT _glfw.egldevice.QueryDeviceStringEXT
+#define eglGetPlatformDisplayEXT _glfw.egldevice.GetPlatformDisplayEXT
+#define eglGetOutputLayersEXT _glfw.egldevice.GetOutputLayersEXT
+#define eglCreateStreamKHR _glfw.egldevice.CreateStreamKHR
+#define eglDestroyStreamKHR _glfw.egldevice.DestroyStreamKHR
+#define eglStreamConsumerOutputEXT _glfw.egldevice.StreamConsumerOutputEXT
+#define eglCreateStreamProducerSurfaceKHR _glfw.egldevice.CreateStreamProducerSurfaceKHR
+#define eglStreamAttribKHR _glfw.egldevice.StreamAttribKHR
+#define eglStreamConsumerAcquireAttribKHR _glfw.egldevice.StreamConsumerAcquireAttribKHR
#define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL)
#define _glfw_dlclose(handle) dlclose(handle)
@@ -85,17 +92,17 @@
#define _GLFW_EGL_NATIVE_DISPLAY EGL_DEFAULT_DISPLAY
#define _GLFW_EGL_NATIVE_WINDOW ((EGLNativeWindowType)window->egldevice.handle)
-#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowEgldevice egldevice
-#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryEgldevice egldevice
-#define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorEgldevice egldevice
-#define _GLFW_PLATFORM_CURSOR_STATE _GLFWcursorEgldevice egldevice
+#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowEGLDevice egldevice
+#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryEGLDevice egldevice
+#define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorEGLDevice egldevice
+#define _GLFW_PLATFORM_CURSOR_STATE _GLFWcursorEGLDevice egldevice
#define _GLFW_PLATFORM_CONTEXT_STATE
#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE
-// EGLDEVICE-specific per-window data
+// EGLDevice-specific per-window data
//
-typedef struct _GLFWwindowEgldevice
+typedef struct _GLFWwindowEGLDevice
{
int xsurfsize, ysurfsize;
int xoffset, yoffset;
@@ -106,38 +113,39 @@
EGLDisplay handle;
EGLOutputLayerEXT eglLayer;
EGLStreamKHR eglStream;
-} _GLFWwindowEgldevice;
+} _GLFWwindowEGLDevice;
-// EGLDEVICE-specific global data
+// EGLDevice-specific global data
//
-typedef struct _GLFWlibraryEgldevice
+typedef struct _GLFWlibraryEGLDevice
{
int drmFd;
- PFNEGLQUERYDEVICESEXTPROC eglQueryDevicesEXT;
- PFNEGLQUERYDEVICESTRINGEXTPROC eglQueryDeviceStringEXT;
- PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplayEXT;
- PFNEGLGETOUTPUTLAYERSEXTPROC eglGetOutputLayersEXT;
- PFNEGLCREATESTREAMKHRPROC eglCreateStreamKHR;
- PFNEGLDESTROYSTREAMKHRPROC eglDestroyStreamKHR;
- PFNEGLSTREAMCONSUMEROUTPUTEXTPROC eglStreamConsumerOutputEXT;
- PFNEGLCREATESTREAMPRODUCERSURFACEKHRPROC eglCreateStreamProducerSurfaceKHR;
- PFNEGLSTREAMATTRIBKHRPROC eglStreamAttribKHR;
- PFNEGLSTREAMCONSUMERACQUIREATTRIBKHRPROC eglStreamConsumerAcquireAttribKHR;
-} _GLFWlibraryEgldevice;
+ PFNEGLQUERYDEVICESEXTPROC QueryDevicesEXT;
+ PFNEGLQUERYDEVICESTRINGEXTPROC QueryDeviceStringEXT;
+ PFNEGLGETPLATFORMDISPLAYEXTPROC GetPlatformDisplayEXT;
+ PFNEGLGETOUTPUTLAYERSEXTPROC GetOutputLayersEXT;
+ PFNEGLCREATESTREAMKHRPROC CreateStreamKHR;
+ PFNEGLDESTROYSTREAMKHRPROC DestroyStreamKHR;
+ PFNEGLSTREAMCONSUMEROUTPUTEXTPROC StreamConsumerOutputEXT;
+ PFNEGLCREATESTREAMPRODUCERSURFACEKHRPROC CreateStreamProducerSurfaceKHR;
+ PFNEGLSTREAMATTRIBKHRPROC StreamAttribKHR;
+ PFNEGLSTREAMCONSUMERACQUIREATTRIBKHRPROC StreamConsumerAcquireAttribKHR;
+} _GLFWlibraryEGLDevice;
-// EGLDEVICE-specific per-monitor data
+// EGLDevice-specific per-monitor data
//
-typedef struct _GLFWmonitorEgldevice {
+typedef struct _GLFWmonitorEGLDevice
+{
int crtcIndex;
uint32_t connId, encId, crtcId;
-} _GLFWmonitorEgldevice;
+} _GLFWmonitorEGLDevice;
-// EGLDEVICE-specific per-cursor data
+// EGLDevice-specific per-cursor data
//
-typedef struct _GLFWcursorEgldevice {
-} _GLFWcursorEgldevice;
+typedef struct _GLFWcursorEGLDevice
+{
+} _GLFWcursorEGLDevice;
void _glfwPollMonitorsEGLDevice(void);
-#endif // _glfw3_egldevice_platform_h_
diff --git a/src/egldevice_window.c b/src/egldevice_window.c
index 55b4d5c..34ea960 100644
--- a/src/egldevice_window.c
+++ b/src/egldevice_window.c
@@ -1,5 +1,5 @@
//========================================================================
-// GLFW 3.2 EGLDevice - www.glfw.org
+// GLFW 3.3 EGLDevice - www.glfw.org
//------------------------------------------------------------------------
// Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
//
@@ -57,9 +57,9 @@
layerAttribs[0] = EGL_DRM_CRTC_EXT;
layerAttribs[1] = (EGLAttrib)monitor->egldevice.crtcId;
- if (!_glfw.egldevice.eglGetOutputLayersEXT(_glfw.egl.display, layerAttribs,
- &window->egldevice.eglLayer,
- 1, &n) || !n)
+ if (!eglGetOutputLayersEXT(_glfw.egl.display, layerAttribs,
+ &window->egldevice.eglLayer,
+ 1, &n) || !n)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"EGLDevice: Unable to obtain EGLOutputLayer");
@@ -68,7 +68,7 @@
// Create a stream and connect to the output
window->egldevice.eglStream =
- _glfw.egldevice.eglCreateStreamKHR(_glfw.egl.display, streamAttribs);
+ eglCreateStreamKHR(_glfw.egl.display, streamAttribs);
if (window->egldevice.eglStream == EGL_NO_STREAM_KHR)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
@@ -76,9 +76,9 @@
eglGetError());
return GLFW_FALSE;
}
- if (!_glfw.egldevice.eglStreamConsumerOutputEXT(_glfw.egl.display,
- window->egldevice.eglStream,
- window->egldevice.eglLayer))
+ if (!eglStreamConsumerOutputEXT(_glfw.egl.display,
+ window->egldevice.eglStream,
+ window->egldevice.eglLayer))
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"EGLDevice: Unable to connect stream (error 0x%x)",
@@ -90,15 +90,14 @@
surfaceAttribs[1] = window->egldevice.xsurfsize;
surfaceAttribs[3] = window->egldevice.ysurfsize;
window->context.egl.surface =
- _glfw.egldevice.eglCreateStreamProducerSurfaceKHR(_glfw.egl.display,
- window->context.egl.config,
- window->egldevice.eglStream,
- surfaceAttribs);
+ eglCreateStreamProducerSurfaceKHR(_glfw.egl.display,
+ window->context.egl.config,
+ window->egldevice.eglStream,
+ surfaceAttribs);
if (window->context.egl.surface == EGL_NO_SURFACE)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
- "EGLDevice: Unable to create rendering"
- " surface (error 0x%x)", eglGetError());
+ "EGLDevice: Unable to create rendering surface (error 0x%x)", eglGetError());
return GLFW_FALSE;
}
@@ -111,10 +110,7 @@
window->context.destroy(window);
if (window->egldevice.eglStream != EGL_NO_STREAM_KHR)
- {
- _glfw.egldevice.eglDestroyStreamKHR(_glfw.egl.display,
- window->egldevice.eglStream);
- }
+ eglDestroyStreamKHR(_glfw.egl.display, window->egldevice.eglStream);
}
void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
@@ -307,7 +303,7 @@
void _glfwPlatformPollEvents(void)
{
- return;
+ _glfwDetectJoystickConnectionLinux();
}
void _glfwPlatformWaitEvents(void)
@@ -419,7 +415,7 @@
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"EGLDevice: _glfwPlatformGetPhysicalDevicePresentationSupport not supported");
- return 0;
+ return GLFW_FALSE;
}
VkResult _glfwPlatformCreateWindowSurface(VkInstance instance,
@@ -429,5 +425,6 @@
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"EGLDevice: _glfwPlatformCreateWindowSurface not supported");
- return (VkResult)NULL;
+ return VK_ERROR_INITIALIZATION_FAILED;
}
+