Skip to content

Commit

Permalink
Don't use Xlib headers by default. (#130)
Browse files Browse the repository at this point in the history
Conceptually, defining EGLNativeDisplayType to Display* is simply incorrect,
because it's not always going to be an Xlib display.

In practice, more and more programs and libraries are being built with EGL but
without Xlib, and end up breaking when the Xlib headers are missing.

Rather than requiring every such program to define EGL_NO_X11, use the (void*)
typedef by default. The existing USE_X11 header can still preserve the current
behavior.

The change to EGLNativeDisplayType will be fine for eglGetDisplay, since you
can always pass a (Display *) as a (void *) parameter.

The EGLNativePixmapType and EGLNativeWindowType types don't change, because
khronos_uintptr_t and XID are both typedefs to unsigned long.

The only things that might break are calls to eglQueryNativeDisplayNV, or
programs that do need the Xlib headers and expect egl.h to include them. Both
of those cases would be trivial to fix.
  • Loading branch information
kbrenneman committed Aug 23, 2021
1 parent 12d8663 commit 64aa561
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions api/EGL/eglplatform.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,7 @@ typedef intptr_t EGLNativeDisplayType;
typedef intptr_t EGLNativePixmapType;
typedef intptr_t EGLNativeWindowType;

#elif defined(__unix__) && defined(EGL_NO_X11)

typedef void *EGLNativeDisplayType;
typedef khronos_uintptr_t EGLNativePixmapType;
typedef khronos_uintptr_t EGLNativeWindowType;

#elif defined(__unix__) || defined(USE_X11)
#elif defined(USE_X11)

/* X11 (tentative) */
#include <X11/Xlib.h>
Expand All @@ -119,6 +113,12 @@ typedef Display *EGLNativeDisplayType;
typedef Pixmap EGLNativePixmapType;
typedef Window EGLNativeWindowType;

#elif defined(__unix__)

typedef void *EGLNativeDisplayType;
typedef khronos_uintptr_t EGLNativePixmapType;
typedef khronos_uintptr_t EGLNativeWindowType;

#elif defined(__APPLE__)

typedef int EGLNativeDisplayType;
Expand Down

0 comments on commit 64aa561

Please sign in to comment.