Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Wayland support
Based on the original port to Wayland by: Joel Teichroeb, Benjamin Franzke, Scott Moreau, et al.

Additional changes in this commit, done by me:

* Wayland uses the common EGL framework
* EGL can now create a desktop OpenGL context
* testgl2 loads GL functions dynamically, no need to link to libGL anymore
* Assorted fixes to the Wayland backend

Tested on the Weston Compositor (v1.0.5) that ships with Ubuntu 13.10,
running Weston under X. Tests ran: testrendercopyex (all backends), testgl2, testgles2,testintersections
  • Loading branch information
gabomdq committed Dec 14, 2013
1 parent 4a8c296 commit ec1cb49
Show file tree
Hide file tree
Showing 25 changed files with 2,044 additions and 138 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Expand Up @@ -218,6 +218,7 @@ set_option(RPATH "Use an rpath when linking SDL" ${UNIX_SYS})
set_option(CLOCK_GETTIME "Use clock_gettime() instead of gettimeofday()" OFF)
set_option(INPUT_TSLIB "Use the Touchscreen library for input" ${UNIX_SYS})
set_option(VIDEO_X11 "Use X11 video driver" ${UNIX_SYS})
set_option(VIDEO_WAYLAND "Use Wayland video driver" ${UNIX_SYS})
dep_option(X11_SHARED "Dynamically load X11 support" ON "VIDEO_X11" OFF)
set(SDL_X11_OPTIONS Xcursor Xinerama XInput Xrandr Xscrnsaver XShape Xvm)
foreach(_SUB ${SDL_X11_OPTIONS})
Expand Down Expand Up @@ -641,6 +642,7 @@ if(UNIX AND NOT APPLE)
CheckDirectFB()
CheckOpenGLX11()
CheckOpenGLESX11()
CheckWayland()
endif(SDL_VIDEO)

if(LINUX)
Expand Down
7 changes: 5 additions & 2 deletions WhatsNew.txt
Expand Up @@ -7,7 +7,10 @@ This is a list of major changes in SDL's version history.
General:
* Added an API to load a database of Game Controller mappings from a file:
SDL_GameControllerAddMappingsFromFile

* EGL can now create/manage OpenGL and OpenGL ES 1.x/2.x contexts, and share
them using SDL_GL_SHARE_WITH_CURRENT_CONTEXT
* Added testgles2. testgl2 does not need to link with libGL anymore.

Windows:
* Support for OpenGL ES 2.x contexts using either WGL or EGL (natively via
the driver or emulated through ANGLE)
Expand All @@ -20,7 +23,7 @@ Android:

Linux:
* Fixed fullscreen and focused behavior when receiving NotifyGrab events

* Wayland support

---------------------------------------------------------------------------
2.0.1:
Expand Down
23 changes: 23 additions & 0 deletions cmake/sdlchecks.cmake
Expand Up @@ -505,6 +505,29 @@ macro(CheckX11)
endif(VIDEO_X11)
endmacro(CheckX11)

# Requires:
# - EGL
macro(CheckWayland)
if(VIDEO_WAYLAND)
pkg_check_modules(WAYLAND wayland-client wayland-cursor wayland-egl egl xkbcommon)
if(WAYLAND_FOUND)
link_directories(
${WAYLAND_LIBRARY_DIRS}
)
include_directories(
${WAYLAND_INCLUDE_DIRS}
)
set(EXTRA_LIBS ${WAYLAND_LIBRARIES} ${EXTRA_LIBS})
set(HAVE_VIDEO_WAYLAND TRUE)
set(HAVE_SDL_VIDEO TRUE)

file(GLOB WAYLAND_SOURCES ${SDL2_SOURCE_DIR}/src/video/wayland/*.c)
set(SOURCE_FILES ${SOURCE_FILES} ${WAYLAND_SOURCES})
set(SDL_VIDEO_DRIVER_WAYLAND 1)
endif(WAYLAND_FOUND)
endif(VIDEO_WAYLAND)
endmacro(CheckWayland)

# Requires:
# - n/a
#
Expand Down
79 changes: 79 additions & 0 deletions configure
Expand Up @@ -817,6 +817,7 @@ enable_sndio
enable_sndio_shared
enable_diskaudio
enable_dummyaudio
enable_video_wayland
enable_video_x11
with_x
enable_x11_shared
Expand Down Expand Up @@ -1532,6 +1533,7 @@ Optional Features:
--enable-sndio-shared dynamically load sndio audio support [[default=yes]]
--enable-diskaudio support the disk writer audio driver [[default=yes]]
--enable-dummyaudio support the dummy audio driver [[default=yes]]
--enable-video-wayland use Wayland video driver [[default=yes]]
--enable-video-x11 use X11 video driver [[default=yes]]
--enable-x11-shared dynamically load X11 support [[default=maybe]]
--enable-video-x11-xcursor
Expand Down Expand Up @@ -18633,6 +18635,82 @@ $as_echo "$need_gcc_Wno_multichar" >&6; }
fi
}

CheckWayland()
{
# Check whether --enable-video-wayland was given.
if test "${enable_video_wayland+set}" = set; then :
enableval=$enable_video_wayland;
else
enable_video_wayland=yes
fi


if test x$enable_video = xyes -a x$enable_video_wayland = xyes; then
# Extract the first word of "pkg-config", so it can be a program name with args.
set dummy pkg-config; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_path_PKG_CONFIG+:} false; then :
$as_echo_n "(cached) " >&6
else
case $PKG_CONFIG in
[\\/]* | ?:[\\/]*)
ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
;;
*)
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS

test -z "$ac_cv_path_PKG_CONFIG" && ac_cv_path_PKG_CONFIG="no"
;;
esac
fi
PKG_CONFIG=$ac_cv_path_PKG_CONFIG
if test -n "$PKG_CONFIG"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5
$as_echo "$PKG_CONFIG" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi


{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Wayland support" >&5
$as_echo_n "checking for Wayland support... " >&6; }
video_wayland=no
if test x$PKG_CONFIG != xno; then
if $PKG_CONFIG --exists wayland-client wayland-egl wayland-cursor egl xkbcommon ; then
WAYLAND_CFLAGS=`$PKG_CONFIG --cflags wayland-client wayland-egl wayland-cursor egl xkbcommon`
WAYLAND_LIBS=`$PKG_CONFIG --libs wayland-client wayland-egl wayland-cursor egl xkbcommon`
video_wayland=yes
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $video_wayland" >&5
$as_echo "$video_wayland" >&6; }

if test x$video_wayland = xyes; then

$as_echo "#define SDL_VIDEO_DRIVER_WAYLAND 1" >>confdefs.h

SOURCES="$SOURCES $srcdir/src/video/wayland/*.c"
EXTRA_CFLAGS="$EXTRA_CFLAGS $WAYLAND_CFLAGS"
EXTRA_LDFLAGS="$EXTRA_LDFLAGS $WAYLAND_LIBS"
have_video=yes
fi
fi
}

CheckX11()
{
Expand Down Expand Up @@ -22220,6 +22298,7 @@ case "$host" in
CheckNAS
CheckSNDIO
CheckX11
CheckWayland
CheckDirectFB
CheckFusionSound
CheckOpenGLX11
Expand Down
31 changes: 31 additions & 0 deletions configure.in
Expand Up @@ -1115,6 +1115,36 @@ CheckWarnAll()
fi
}

dnl Check for Wayland
CheckWayland()
{
AC_ARG_ENABLE(video-wayland,
AC_HELP_STRING([--enable-video-wayland], [use Wayland video driver [[default=yes]]]),
,enable_video_wayland=yes)

if test x$enable_video = xyes -a x$enable_video_wayland = xyes; then
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
AC_MSG_CHECKING(for Wayland support)
video_wayland=no
if test x$PKG_CONFIG != xno; then
if $PKG_CONFIG --exists wayland-client wayland-egl wayland-cursor egl xkbcommon ; then
WAYLAND_CFLAGS=`$PKG_CONFIG --cflags wayland-client wayland-egl wayland-cursor egl xkbcommon`
WAYLAND_LIBS=`$PKG_CONFIG --libs wayland-client wayland-egl wayland-cursor egl xkbcommon`
video_wayland=yes
fi
fi
AC_MSG_RESULT($video_wayland)

if test x$video_wayland = xyes; then
AC_DEFINE(SDL_VIDEO_DRIVER_WAYLAND, 1, [ ])
SOURCES="$SOURCES $srcdir/src/video/wayland/*.c"
EXTRA_CFLAGS="$EXTRA_CFLAGS $WAYLAND_CFLAGS"
dnl FIXME do dynamic loading code here.
EXTRA_LDFLAGS="$EXTRA_LDFLAGS $WAYLAND_LIBS"
have_video=yes
fi
fi
}

dnl Find the X11 include and library directories
CheckX11()
Expand Down Expand Up @@ -2449,6 +2479,7 @@ case "$host" in
CheckNAS
CheckSNDIO
CheckX11
CheckWayland
CheckDirectFB
CheckFusionSound
CheckOpenGLX11
Expand Down
1 change: 1 addition & 0 deletions include/SDL_config.h.cmake
Expand Up @@ -259,6 +259,7 @@
#cmakedefine SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC @SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC@
#cmakedefine SDL_VIDEO_DRIVER_DUMMY @SDL_VIDEO_DRIVER_DUMMY@
#cmakedefine SDL_VIDEO_DRIVER_WINDOWS @SDL_VIDEO_DRIVER_WINDOWS@
#cmakedefine SDL_VIDEO_DRIVER_WAYLAND @SDL_VIDEO_DRIVER_WAYLAND@
#cmakedefine SDL_VIDEO_DRIVER_X11 @SDL_VIDEO_DRIVER_X11@
#cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC @SDL_VIDEO_DRIVER_X11_DYNAMIC@
#cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT @SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT@
Expand Down
1 change: 1 addition & 0 deletions include/SDL_config.h.in
Expand Up @@ -260,6 +260,7 @@
#undef SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC
#undef SDL_VIDEO_DRIVER_DUMMY
#undef SDL_VIDEO_DRIVER_WINDOWS
#undef SDL_VIDEO_DRIVER_WAYLAND
#undef SDL_VIDEO_DRIVER_X11
#undef SDL_VIDEO_DRIVER_RPI
#undef SDL_VIDEO_DRIVER_X11_DYNAMIC
Expand Down
9 changes: 9 additions & 0 deletions include/SDL_syswm.h
Expand Up @@ -101,6 +101,7 @@ typedef enum
SDL_SYSWM_UNKNOWN,
SDL_SYSWM_WINDOWS,
SDL_SYSWM_X11,
SDL_SYSWM_WAYLAND,
SDL_SYSWM_DIRECTFB,
SDL_SYSWM_COCOA,
SDL_SYSWM_UIKIT,
Expand Down Expand Up @@ -175,6 +176,14 @@ struct SDL_SysWMinfo
Window window; /**< The X11 window */
} x11;
#endif
#if defined(SDL_VIDEO_DRIVER_WAYLAND)
struct
{
struct wl_display *display; /**< Wayland display */
struct wl_surface *surface; /**< Wayland surface */
struct wl_shell_surface *shell_surface; /**< Wayland shell_surface (window manager handle) */
} wl;
#endif
#if defined(SDL_VIDEO_DRIVER_DIRECTFB)
struct
{
Expand Down
10 changes: 5 additions & 5 deletions src/render/opengl/SDL_glfuncs.h
Expand Up @@ -30,7 +30,7 @@ SDL_PROC_UNUSED(void, glColor3bv, (const GLbyte *))
SDL_PROC_UNUSED(void, glColor3d, (GLdouble, GLdouble, GLdouble))
SDL_PROC_UNUSED(void, glColor3dv, (const GLdouble *))
SDL_PROC_UNUSED(void, glColor3f, (GLfloat, GLfloat, GLfloat))
SDL_PROC_UNUSED(void, glColor3fv, (const GLfloat *))
SDL_PROC(void, glColor3fv, (const GLfloat *))
SDL_PROC_UNUSED(void, glColor3i, (GLint, GLint, GLint))
SDL_PROC_UNUSED(void, glColor3iv, (const GLint *))
SDL_PROC_UNUSED(void, glColor3s, (GLshort, GLshort, GLshort))
Expand Down Expand Up @@ -85,7 +85,7 @@ SDL_PROC_UNUSED(void, glCopyTexSubImage2D,
SDL_PROC_UNUSED(void, glCullFace, (GLenum mode))
SDL_PROC_UNUSED(void, glDeleteLists, (GLuint list, GLsizei range))
SDL_PROC(void, glDeleteTextures, (GLsizei n, const GLuint * textures))
SDL_PROC_UNUSED(void, glDepthFunc, (GLenum func))
SDL_PROC(void, glDepthFunc, (GLenum func))
SDL_PROC_UNUSED(void, glDepthMask, (GLboolean flag))
SDL_PROC_UNUSED(void, glDepthRange, (GLclampd zNear, GLclampd zFar))
SDL_PROC(void, glDisable, (GLenum cap))
Expand Down Expand Up @@ -334,13 +334,13 @@ SDL_PROC_UNUSED(void, glRectsv, (const GLshort * v1, const GLshort * v2))
SDL_PROC_UNUSED(GLint, glRenderMode, (GLenum mode))
SDL_PROC(void, glRotated,
(GLdouble angle, GLdouble x, GLdouble y, GLdouble z))
SDL_PROC_UNUSED(void, glRotatef,
SDL_PROC(void, glRotatef,
(GLfloat angle, GLfloat x, GLfloat y, GLfloat z))
SDL_PROC_UNUSED(void, glScaled, (GLdouble x, GLdouble y, GLdouble z))
SDL_PROC_UNUSED(void, glScalef, (GLfloat x, GLfloat y, GLfloat z))
SDL_PROC(void, glScissor, (GLint x, GLint y, GLsizei width, GLsizei height))
SDL_PROC_UNUSED(void, glSelectBuffer, (GLsizei size, GLuint * buffer))
SDL_PROC_UNUSED(void, glShadeModel, (GLenum mode))
SDL_PROC(void, glShadeModel, (GLenum mode))
SDL_PROC_UNUSED(void, glStencilFunc, (GLenum func, GLint ref, GLuint mask))
SDL_PROC_UNUSED(void, glStencilMask, (GLuint mask))
SDL_PROC_UNUSED(void, glStencilOp, (GLenum fail, GLenum zfail, GLenum zpass))
Expand Down Expand Up @@ -432,7 +432,7 @@ SDL_PROC_UNUSED(void, glVertex2sv, (const GLshort * v))
SDL_PROC_UNUSED(void, glVertex3d, (GLdouble x, GLdouble y, GLdouble z))
SDL_PROC_UNUSED(void, glVertex3dv, (const GLdouble * v))
SDL_PROC_UNUSED(void, glVertex3f, (GLfloat x, GLfloat y, GLfloat z))
SDL_PROC_UNUSED(void, glVertex3fv, (const GLfloat * v))
SDL_PROC(void, glVertex3fv, (const GLfloat * v))
SDL_PROC_UNUSED(void, glVertex3i, (GLint x, GLint y, GLint z))
SDL_PROC_UNUSED(void, glVertex3iv, (const GLint * v))
SDL_PROC_UNUSED(void, glVertex3s, (GLshort x, GLshort y, GLshort z))
Expand Down

0 comments on commit ec1cb49

Please sign in to comment.