Skip to content
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,11 @@ IF(NOT (ANDROID AND OSG_FIND_3RD_PARTY_DEPS))
ENDIF()
ENDIF()

IF(OSG_WINDOWING_SYSTEM STREQUAL "X11")
# optional Wayland graphics also supported..
FIND_PACKAGE(Wayland)
ENDIF()

################################################################################
# Create bin and lib directories if required

Expand Down
15 changes: 15 additions & 0 deletions CMakeModules/FindWayland.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Find Wayland development libraries & headers for wayland-egl & wayland-cursor & EGL & XKBcommon
#
# WAYLAND_FOUND - system has a libwayland-[egl|client|cursor] + libEGL + libxkbcommon
# WAYLAND_INCLUDE_DIR - where to find header files
# WAYLAND_LIBRARIES - the libraries to link against Wayland
#
# copyright (c) 2022 Phil Ashby <[email protected]>
# Redistribution and use of this file is allowed according to the terms of the BSD license.
#

# Use PkgConfig to find includes and libs
find_package(PkgConfig QUIET)
if (PKG_CONFIG_FOUND)
PKG_CHECK_MODULES(WAYLAND QUIET wayland-egl wayland-cursor egl xkbcommon)
endif ()
30 changes: 23 additions & 7 deletions src/osg/GraphicsContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,28 +75,44 @@ GraphicsContext::WindowingSystemInterface* GraphicsContext::WindowingSystemInter
OSG_WARN<<"Warning: GraphicsContext::WindowingSystemInterfaces::getWindowingSystemInterface() failed, no interfaces available."<<std::endl;
return 0;
}
std::string search = name;
if (getenv("OSG_WINDOWING_SYSTEM") != NULL)
{
search = getenv("OSG_WINDOWING_SYSTEM");
}

if (!name.empty())
if (!search.empty())
{
for(Interfaces::iterator itr = _interfaces.begin();
itr != _interfaces.end();
++itr)
{
if ((*itr)->getName()==name)
if ((*itr)->getName()==search)
{
OSG_INFO<<"found WindowingSystemInterface : "<<search<<std::endl;
return itr->get();
}

OSG_NOTICE<<" tried interface "<<typeid(*itr).name()<<", name= "<<(*itr)->getName()<<std::endl;
}

OSG_WARN<<"Warning: GraphicsContext::WindowingSystemInterfaces::getWindowingSystemInterface() failed, no interfaces matches name : "<<name<<std::endl;
OSG_WARN<<"Warning: GraphicsContext::WindowingSystemInterfaces::getWindowingSystemInterface() failed, no interfaces matches name : "<<search<<std::endl;
return 0;
}
else
{
// no preference provided so just take the first available interface
return _interfaces.front().get();
// no preference provided so just take the first available interface that works
for (Interfaces::iterator itr = _interfaces.begin();
itr != _interfaces.end();
++itr)
{
if ((*itr)->getNumScreens() > 0)
{
OSG_INFO<<"using default WindowingSystemInterface : "<<(*itr)->getName()<<std::endl;
return itr->get();
}
}

OSG_WARN<<"Warning: GraphicsContext::WindowingSystemInterfaces::getWindowingSystemInterface() failed, no working interfaces"<<std::endl;
return 0;
}
}

Expand Down
10 changes: 10 additions & 0 deletions src/osgViewer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,16 @@ ELSE()

SET(LIB_EXTRA_LIBS ${X11_X11_LIB} ${LIB_EXTRA_LIBS})
ENDIF(APPLE)

# Add Wayland here if available..
IF(WAYLAND_FOUND)
ADD_DEFINITIONS(-DOSGVIEWER_USE_WAYLAND)
SET(LIB_COMMON_FILES ${LIB_COMMON_FILES}
GraphicsWindowWayland.cpp
xdg-shell.c
xdg-decoration-unstable-v1.c)
SET(LIB_EXTRA_LIBS ${WAYLAND_LIBRARIES} ${LIB_EXTRA_LIBS})
ENDIF()
ELSE()
MESSAGE(STATUS "Windowing system not supported")
ENDIF()
Expand Down
Loading