Skip to content

Commit

Permalink
Merge pull request #398 from friction2d/egl
Browse files Browse the repository at this point in the history
Linux: Support EGL (wayland)
  • Loading branch information
rodlie authored Dec 27, 2024
2 parents 5ffb5ca + b83e0fb commit 9669e7a
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 31 deletions.
21 changes: 3 additions & 18 deletions src/cmake/friction-common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,6 @@ if(MSVC)
add_definitions("/MP")
endif()

if(UNIX AND NOT APPLE)
option(STATIC_FFMPEG "Link against static ffmpeg" OFF)
if(${STATIC_FFMPEG})
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,-Bsymbolic")
endif()
endif()

if(NOT WIN32)
if ((NOT ${CMAKE_VERSION} VERSION_LESS 3.11) AND (NOT OpenGL_GL_PREFERENCE))
set(OpenGL_GL_PREFERENCE "GLVND")
endif()
find_package(OpenGL REQUIRED)
endif()

find_package(PkgConfig QUIET)
find_package(QT NAMES Qt5 COMPONENTS Core REQUIRED)
find_package(
Expand Down Expand Up @@ -120,10 +106,9 @@ else()
if(APPLE)
set(SKIA_LIBRARIES skia)
else()
set(SKIA_LIBRARIES
skia
fontconfig
${OPENGL_LIBRARY})
set(SKIA_LIBRARIES skia.friction)
endif()
if(UNIX AND NOT APPLE)
pkg_check_modules(UNWIND REQUIRED libunwind)
set(GPERF_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/../gperftools ${UNWIND_INCLUDE_DIRS})
set(GPERF_LIBRARIES tcmalloc_static ${UNWIND_LIBRARIES})
Expand Down
12 changes: 4 additions & 8 deletions src/core/appsupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -976,8 +976,8 @@ void AppSupport::checkFFmpeg(const bool &isRenderer)

void AppSupport::initEnv(const bool &isRenderer)
{
#if defined(Q_OS_WIN)
Q_UNUSED(isRenderer)
#if defined(Q_OS_WIN)
// windows theme integration
#if QT_VERSION < QT_VERSION_CHECK(6, 5, 0)
// Set window title bar color based on dark/light theme
Expand All @@ -988,13 +988,9 @@ void AppSupport::initEnv(const bool &isRenderer)
if (registry.value("AppsUseLightTheme", 0).toInt() == 0) { qputenv("QT_QPA_PLATFORM", "windows:darkmode=1"); }
#endif
#elif defined(Q_OS_LINUX)
if (isRenderer) { // Force Mesa if Renderer
qputenv("LIBGL_ALWAYS_SOFTWARE", "1");
}
// Force XCB on Linux until we support Wayland
qputenv("QT_QPA_PLATFORM", isRenderer ? "offscreen" : "xcb");
#else
Q_UNUSED(isRenderer)
#ifdef PROJECT_OFFICIAL
qputenv("QT_QPA_PLATFORM", "xcb");
#endif
#endif
}

Expand Down
18 changes: 18 additions & 0 deletions src/engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ option(LINUX_DEPLOY "Linux Deploy" OFF)
option(MAC_DEPLOY "Mac Deploy" OFF)
option(SYNC_SKIA_DEPS "Sync third-party depends" ON)

if(UNIX AND NOT APPLE)
option(USE_EGL "Use EGL in skia" OFF)
endif()

set(SKIA_SRC "${CMAKE_CURRENT_SOURCE_DIR}/skia")
set(SKIA_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/skia")

Expand Down Expand Up @@ -72,6 +76,10 @@ else()
endif()
set(SKIA_ARGS "ar=\"${CMAKE_AR}\" cc=\"${CMAKE_C_COMPILER}\" cxx=\"${CMAKE_CXX_COMPILER}\"")
if(UNIX AND NOT APPLE)
if(${USE_EGL})
set(SKIA_ARGS "${SKIA_ARGS} skia_use_egl=true")
endif()
set(SKIA_ARGS "${SKIA_ARGS} is_component_build=true")
if (${LINUX_DEPLOY})
set(SKIA_ARGS "${SKIA_ARGS} extra_cflags=[\"-Wno-error\"]")
else()
Expand Down Expand Up @@ -126,6 +134,16 @@ ExternalProject_Add(
USES_TERMINAL_BUILD true
)

if(UNIX AND NOT APPLE)
include(GNUInstallDirs)
install(
FILES
${SKIA_BUILD_DIR}/libskia.friction.so
DESTINATION
${CMAKE_INSTALL_LIBDIR}
)
endif()

if(WIN32)
add_custom_command(TARGET Engine POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${SKIA_BUILD_DIR}/skia.dll.lib ${SKIA_BUILD_DIR}/skia.lib)
endif()
2 changes: 1 addition & 1 deletion src/engine/skia
3 changes: 1 addition & 2 deletions src/scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@ BUILD_ENGINE=${BUILD_ENGINE:-"OFF"}
REL=${REL:-0}
APPIMG=20240401
SDK=1.0.0
SKIA=1.0.0-682c91fa
URL=https://github.com/friction2d/friction-sdk/releases/download/v${SDK}
APPIMAGE_TAR=friction-appimage-tools-${APPIMG}.tar.xz
SDK_TAR=friction-sdk-${SDK}-linux-x86_64.tar.xz
SKIA_TAR=skia-static-${SKIA}-linux-x86_64.tar.xz
SKIA_TAR=skia-friction-09e64895-linux-x86_64.tar.xz

mkdir -p distfiles/sdk || true

Expand Down
4 changes: 2 additions & 2 deletions src/scripts/build_vfxplatform_friction.sh
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ cmake --build .

if [ "${BUILD_ENGINE}" = "ON" ]; then
(cd src/engine ;
tar cf skia-static-${VERSION}-linux-x86_64.tar skia
tar cf skia-friction-${VERSION}-linux-x86_64.tar skia
mkdir -p /mnt/builds/${VERSION} || true
mv skia-static-${VERSION}-linux-x86_64.tar /mnt/builds/${VERSION}/
mv skia-friction-${VERSION}-linux-x86_64.tar /mnt/builds/${VERSION}/
)
fi

Expand Down
7 changes: 7 additions & 0 deletions src/scripts/build_vfxplatform_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ FRICTION_PKG=friction-${VERSION}

APPIMAGETOOL=bfe6e0c
APPIMAGERUNTIME=1bb1157
SKIA_LIB=${DISTFILES}/skia/libskia.friction.so

if [ "${VERSION}" = "" ]; then
echo "Missing version"
Expand Down Expand Up @@ -143,6 +144,12 @@ for so in *.so*; do
done
)

PKG_SKIA_LIB=${BUILD}/${FRICTION_PKG}/opt/friction/lib/libskia.friction.so
if [ -f "${SKIA_LIB}" ] && [ ! -f "${PKG_SKIA_LIB}" ]; then
cp -a ${SKIA_LIB} ${BUILD}/${FRICTION_PKG}/opt/friction/lib/
strip -s ${PKG_SKIA_LIB}
fi

PLUGS="
audio
platforminputcontexts
Expand Down

0 comments on commit 9669e7a

Please sign in to comment.