Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 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 .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ jobs:
sudo apt update
sudo apt install -y libxrandr-dev \
libgles2-mesa-dev mesa-common-dev libgl1-mesa-dev mesa-vulkan-drivers \
libwayland-dev libwayland-egl1 pkg-config libegl-dev \
qtwayland5 qtbase5-private-dev \
libfreetype6-dev libpugixml-dev libassimp-dev libbullet-dev qtbase5-dev cargo \
nvidia-cg-dev glslang-dev spirv-tools spirv-headers \
swig4.0 mono-mcs python3-dev \
Expand All @@ -27,9 +29,12 @@ jobs:
cmake --build build -- -j 4
cmake --build build --target OgreDoc > /dev/null
env: # need to fix warnings on newer compilers first
LINUX: true
CC: gcc-7
CXX: g++-7
- name: Test
env:
SDL_VIDEODRIVER: wayland
run: |
# doxygen warnings check
cat build/doxygen_warnings.log
Expand Down
16 changes: 12 additions & 4 deletions BuildingOgre.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,29 @@ For manually building the dependencies, please refer to the list below and get a
On linux you additionally need the following system headers to build the GL, GL3+, GLES2 & Vulkan RenderSystems:
* Ubuntu

sudo apt-get install libgles2-mesa-dev libvulkan-dev glslang-dev libxrandr-dev
sudo apt-get install libgles2-mesa-dev libvulkan-dev glslang-dev
# X11:
Comment thread
joakimono marked this conversation as resolved.
Outdated
sudo apt-get install libxrandr-dev
# Wayland:
sudo apt-get install pkg-config libwayland-dev libwayland-egl1 wayland-protocols libegl-dev

* Fedora

sudo dnf install mesa-libGL-devel mesa-vulkan-devel glslang-devel
sudo dnf install mesa-libGL-devel mesa-vulkan-devel glslang-devel mesa-libEGL-devel

furthermore we recommend installing the following optional packages

* Ubuntu

sudo apt-get install libsdl2-dev libxt-dev libxaw7-dev doxygen
sudo apt-get install libsdl2-dev doxygen
# X11:
sudo apt-get install libxt-dev libxaw7-dev

* Fedora

sudo dnf install SDL2-devel libXt-devel libXaw-devel doxygen pugixml-devel
sudo dnf install SDL2-devel doxygen pugixml-devel
# X11:
sudo dnf install libXt-devel libXaw-devel

these will enable input handling in the SampleBrowser, the X11 ConfigDialog and allow building the documentation.

Expand Down
13 changes: 12 additions & 1 deletion CMake/Dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,19 @@ macro_log_feature(FREETYPE_FOUND "freetype" "Portable font engine" "http://www.f

# Find X11
if (UNIX AND NOT APPLE AND NOT ANDROID AND NOT EMSCRIPTEN)
find_package(X11 REQUIRED)
find_package(PkgConfig)
if (PKG_CONFIG_FOUND)
pkg_check_modules(waylands IMPORTED_TARGET wayland-client wayland-egl egl)
macro_log_feature(waylands_FOUND "Wayland" "Wayland window system" "https://wayland.freedesktop.org")
endif ()

if (NOT waylands_FOUND)
find_package(X11 REQUIRED)
else ()
find_package(X11)
endif ()
macro_log_feature(X11_FOUND "X11" "X Window system" "http://www.x.org")

endif ()


Expand Down
2 changes: 1 addition & 1 deletion CMake/Templates/OGREStatic.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ Name: OGRE (static lib)
Description: Object-Oriented Graphics Rendering Engine
Version: @OGRE_VERSION@
URL: http://www.ogre3d.org
Requires: freetype2, zziplib, x11, xt, xaw7, gl
Requires: freetype2, zziplib, gl, x11, xt, xaw7, wayland
Libs: -L${libdir} -L${plugindir} -lOgreMain@OGRE_LIB_SUFFIX@ @OGRE_ADDITIONAL_LIBS@
Cflags: -I${includedir} -I${includedir}/OGRE @OGRE_CFLAGS@
17 changes: 12 additions & 5 deletions Components/Bites/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ elseif(ANDROID)
endif()

cmake_dependent_option(OGRE_BITES_NATIVE_DIALOG "Provide a platform specific ConfigDialog implementation"
ON "NOT ANDROID;NOT EMSCRIPTEN;NOT APPLE_IOS;NOT WINDOWS_STORE;NOT WINDOWS_PHONE;NOT UNIX OR APPLE OR XAW_LIBRARY" OFF)
ON "NOT OGRE_GLSUPPORT_USE_WAYLAND;NOT ANDROID;NOT EMSCRIPTEN;NOT APPLE_IOS;NOT WINDOWS_STORE;NOT WINDOWS_PHONE;NOT UNIX OR APPLE OR XAW_LIBRARY" OFF)

if(NOT OGRE_BITES_NATIVE_DIALOG)
set_source_files_properties(src/OgreBitesConfigDialog.cpp PROPERTIES COMPILE_DEFINITIONS DISABLE_NATIVE_DIALOG)
Expand All @@ -134,14 +134,13 @@ elseif(APPLE)
set(RESOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/misc/ogrelogo.png")
source_group(Resources FILES ${RESOURCE_FILES})
set(DEPENDENCIES ${DEPENDENCIES} "-framework Cocoa")
elseif(UNIX AND XAW_LIBRARY)
elseif(UNIX AND XAW_LIBRARY AND NOT OGRE_GLSUPPORT_USE_WAYLAND)
list(APPEND SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/OgreGLXConfigDialog.cpp")
list(APPEND DEPENDENCIES ${X11_Xt_LIB} ${XAW_LIBRARY})
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/misc/GLX_backdrop.png" DESTINATION "${OGRE_MEDIA_PATH}/../")
endif()

if(UNIX AND NOT APPLE)
# for WindowEventUtilities
if(UNIX AND NOT APPLE AND NOT OGRE_GLSUPPORT_USE_WAYLAND)
list(APPEND DEPENDENCIES ${X11_X11_LIB})
set(NATIVE_INCLUDES ${X11_Xlib_INCLUDE_PATH})
endif()
Expand Down Expand Up @@ -176,6 +175,10 @@ if(OGRE_STATIC AND APPLE AND OGRE_BUILD_PLUGIN_CG)
target_include_directories(OgreBites PUBLIC ${Cg_INCLUDE_DIRS})
endif()

if(OGRE_GLSUPPORT_USE_WAYLAND)
target_compile_definitions(OgreBites PRIVATE OGRE_WAYLAND)
endif()

if(SDL2_FOUND)
target_link_libraries(OgreBites PRIVATE SDL2::SDL2)
elseif(NOT EMSCRIPTEN)
Expand All @@ -196,10 +199,14 @@ if(Qt6_FOUND OR Qt5_FOUND)
add_library(OgreBitesQt ${OGRE_COMP_LIB_TYPE} ${MOC_SRC} "${CMAKE_CURRENT_SOURCE_DIR}/src/OgreApplicationContextQt.cpp")
set_target_properties(OgreBitesQt PROPERTIES VERSION ${OGRE_SOVERSION} SOVERSION ${OGRE_SOVERSION})
target_link_libraries(OgreBitesQt PUBLIC Qt${QT_VERSION_MAJOR}::Gui OgreBites)
if(OGRE_GLSUPPORT_USE_WAYLAND)
target_compile_definitions(OgreBitesQt PRIVATE OGRE_WAYLAND)
target_link_libraries(OgreBitesQt PRIVATE PkgConfig::waylands)
endif()
ogre_config_component(OgreBitesQt)
endif()

# install
# install
ogre_config_framework(OgreBites)
ogre_config_component(OgreBites)

Expand Down
28 changes: 28 additions & 0 deletions Components/Bites/src/OgreApplicationContextQt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@
#include <QResizeEvent>
#include <QKeyEvent>

#ifdef OGRE_WAYLAND
// This is a private, unstable header (package: qtbase5-private-dev)
// Since Qt 6.5 another stable native interface becomes available, QWaylandApplication
#include <5.12.8/QtGui/qpa/qplatformnativeinterface.h>
#include <wayland-client-protocol.h>
#include <wayland-egl.h>
#define EGL_NO_X11
#ifndef WL_EGL_PLATFORM
#define WL_EGL_PLATFORM 1
#endif
#include <EGL/egl.h>
#endif

namespace OgreBites
{
static Event convert(const QEvent* in)
Expand Down Expand Up @@ -131,6 +144,21 @@ namespace OgreBites

p.miscParams["externalWindowHandle"] = std::to_string(size_t(window->winId()));

#ifdef OGRE_WAYLAND
Comment thread
joakimono marked this conversation as resolved.
Outdated

QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface();

if (!nativeInterface){
Ogre::LogManager::getSingleton().logMessage("[Qt] Native interface is nullptr!");
}

auto display = static_cast<wl_display*>(nativeInterface->nativeResourceForWindow("display", nullptr));
auto surface = static_cast<wl_surface*>(nativeInterface->nativeResourceForWindow("surface", window));

p.miscParams["externalWlDisplay"] = Ogre::StringConverter::toString(size_t(display));
p.miscParams["externalSurface"] = Ogre::StringConverter::toString(size_t(surface));
#endif

if (!mWindows.empty())
{
// additional windows should reuse the context
Expand Down
15 changes: 14 additions & 1 deletion Components/Bites/src/OgreApplicationContextSDL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,20 @@ NativeWindowPair ApplicationContextSDL::createWindow(const Ogre::String& name, O
p.miscParams["sdlwin"] = Ogre::StringConverter::toString(size_t(ret.native));

#if OGRE_PLATFORM == OGRE_PLATFORM_LINUX
p.miscParams["externalWindowHandle"] = Ogre::StringConverter::toString(size_t(wmInfo.info.x11.window));
if (wmInfo.subsystem == SDL_SYSWM_WAYLAND)
{
#ifdef OGRE_WAYLAND
Comment thread
joakimono marked this conversation as resolved.
Outdated
Comment thread
joakimono marked this conversation as resolved.
Outdated
Ogre::LogManager::getSingleton().logMessage("[SDL] Creating Wayland window");

p.miscParams["externalWlDisplay"] = Ogre::StringConverter::toString(size_t(wmInfo.info.wl.display));
p.miscParams["externalSurface"] = Ogre::StringConverter::toString(size_t(wmInfo.info.wl.surface));
Comment thread
joakimono marked this conversation as resolved.
Outdated
#endif
Comment thread
joakimono marked this conversation as resolved.
Outdated
}
else if (wmInfo.subsystem == SDL_SYSWM_X11)
{
Ogre::LogManager::getSingleton().logMessage("[SDL] Creating X11 window");
p.miscParams["externalWindowHandle"] = Ogre::StringConverter::toString(size_t(wmInfo.info.x11.window));
}
#elif OGRE_PLATFORM == OGRE_PLATFORM_WIN32
p.miscParams["externalWindowHandle"] = Ogre::StringConverter::toString(size_t(wmInfo.info.win.window));
#elif OGRE_PLATFORM == OGRE_PLATFORM_APPLE
Expand Down
13 changes: 11 additions & 2 deletions Components/Bites/src/OgreWindowEventUtilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ THE SOFTWARE.
# define NOMINMAX // required to stop windows.h messing up std::min
# endif
# include <windows.h>
#elif OGRE_PLATFORM == OGRE_PLATFORM_LINUX
#include <X11/Xlib.h>
#elif OGRE_PLATFORM == OGRE_PLATFORM_LINUX && !defined(OGRE_WAYLAND)
# if !defined(OGRE_WAYLAND)
# include <X11/Xlib.h>
# endif
#endif

using namespace Ogre;
Expand All @@ -48,7 +50,9 @@ static WindowEventListeners _msListeners;
static RenderWindowList _msWindows;

#if OGRE_PLATFORM == OGRE_PLATFORM_LINUX
# if !defined(OGRE_WAYLAND)
static void GLXProc( RenderWindow *win, const XEvent &event );
# endif
#endif

#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
Expand Down Expand Up @@ -185,6 +189,8 @@ void WindowEventUtilities::messagePump()
DispatchMessage( &msg );
}
#elif OGRE_PLATFORM == OGRE_PLATFORM_LINUX
#if !defined(OGRE_WAYLAND)
// TODO write wayland-alternative
//GLX Message Pump
Display* xDisplay = 0; // same for all windows

Expand All @@ -209,6 +215,7 @@ void WindowEventUtilities::messagePump()
GLXProc(w, event);
}
}
# endif
#endif
}

Expand Down Expand Up @@ -241,6 +248,7 @@ void WindowEventUtilities::_removeRenderWindow(RenderWindow* window)
}

#if OGRE_PLATFORM == OGRE_PLATFORM_LINUX
# if !defined(OGRE_WAYLAND)
//--------------------------------------------------------------------------------//
static void GLXProc( Ogre::RenderWindow *win, const XEvent &event )
{
Expand Down Expand Up @@ -347,6 +355,7 @@ static void GLXProc( Ogre::RenderWindow *win, const XEvent &event )
break;
} //End switch event.type
}
# endif
#endif

}
2 changes: 1 addition & 1 deletion OgreMain/include/OgreRenderSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ namespace Ogre
| Full Screen | true, false | false | Specify whether to create the window in full screen mode | |
| border | none, fixed, resize | resize | The type of window border (in windowed mode) | Windows, OSX |
| displayFrequency | Refresh rate in Hertz (e.g. 60, 75, 100) | Desktop vsync rate | Display frequency rate, for fullscreen mode | |
| externalWindowHandle | <ul><li>Win32: HWND as int<li>Linux: X11 Window as ulong<li>OSX: OgreGLView address as an integer. You can pass NSView or NSWindow too, but should perform OgreGLView callbacks into the Ogre manually<li>iOS: UIWindow address as an integer<li>Emscripten: canvas selector String ("#canvas")</ul> | 0 (none) | External window handle, for embedding the OGRE render in an existing window | |
| externalWindowHandle | <ul><li>Win32: HWND as int<li>Linux: X11 Window as ulong; Wayland EGL window address as an integer<li>OSX: OgreGLView address as an integer. You can pass NSView or NSWindow too, but should perform OgreGLView callbacks into the Ogre manually<li>iOS: UIWindow address as an integer<li>Emscripten: canvas selector String ("#canvas")</ul> | 0 (none) | External window handle, for embedding the OGRE render in an existing window | |
| externalGLControl | true, false | false | Let the external window control OpenGL i.e. don't select a pixel format for the window, do not change v-sync and do not swap buffer. When set to true, the calling application is responsible of OpenGL initialization and buffer swapping. It should also create an OpenGL context for its own rendering, Ogre will create one for its use. Then the calling application must also enable Ogre OpenGL context before calling any Ogre function and restore its OpenGL context after these calls. | OpenGL |
| currentGLContext | true, false | false | Use an externally created GL context. (Must be current) | OpenGL |
| minColourBufferSize | Positive integer (usually 16, 32) | 16 | Min total colour buffer size. See EGL_BUFFER_SIZE | OpenGL |
Expand Down
36 changes: 29 additions & 7 deletions RenderSystems/GLSupport/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

if(EGL_FOUND)
cmake_dependent_option(OGRE_GLSUPPORT_USE_EGL "use EGL for GL Context Creation instead of GLX/ WGL" TRUE "NOT WIN32" FALSE)

cmake_dependent_option(OGRE_GLSUPPORT_USE_WAYLAND "use Wayland window manager" FALSE "UNIX;NOT APPLE;NOT EMSCRIPTEN;NOT ANDROID" FALSE)
endif()

if(ANDROID)
Expand Down Expand Up @@ -64,13 +66,27 @@ elseif (APPLE)
set(PLATFORM_LIBS "-framework AppKit" ${OPENGL_gl_LIBRARY})
elseif (UNIX)
if(OGRE_GLSUPPORT_USE_EGL)
file(GLOB PLATFORM_HEADERS "include/EGL/X11/*.h" "include/EGL/*.h")
file(GLOB PLATFORM_SOURCES "src/EGL/X11/*.cpp" "src/EGL/*.cpp" "src/X11/*.cpp")

set(NATIVE_INCLUDES
${CMAKE_CURRENT_SOURCE_DIR}/include/EGL
list(APPEND _EGL_HEADERS "include/EGL/*.h")
list(APPEND _EGL_SOURCES "src/EGL/*.cpp")
list(APPEND NATIVE_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/include/EGL)
if(OGRE_GLSUPPORT_USE_WAYLAND)
list(APPEND _EGL_HEADERS "include/EGL/Wayland/*.h")
list(APPEND _EGL_SOURCES "src/EGL/Wayland/*.cpp")
list(APPEND NATIVE_INCLUDES
${CMAKE_CURRENT_SOURCE_DIR}/include/EGL/Wayland)
set(WAYLAND_LIBRARIES PkgConfig::waylands)
else()
list(APPEND _EGL_HEADERS "include/EGL/X11/*.h")
list(APPEND _EGL_SOURCES "src/EGL/X11/*.cpp")
list(APPEND _EGL_SOURCES "src/X11/*.cpp")
list(APPEND NATIVE_INCLUDES
${CMAKE_CURRENT_SOURCE_DIR}/include/EGL/X11)
set(PLATFORM_LIBS ${X11_LIBRARIES} ${X11_Xrandr_LIB} ${EGL_LIBRARIES})
endif()

file(GLOB PLATFORM_HEADERS ${_EGL_HEADERS})
file(GLOB PLATFORM_SOURCES ${_EGL_SOURCES})

set(PLATFORM_LIBS ${X11_LIBRARIES} ${X11_Xrandr_LIB} ${EGL_LIBRARIES} ${WAYLAND_LIBRARIES})
else()
file(GLOB PLATFORM_HEADERS "include/GLX/*.h")
file(GLOB PLATFORM_SOURCES "src/GLX/*.cpp" "src/X11/*.cpp")
Expand All @@ -85,7 +101,9 @@ elseif (UNIX)

set(PLATFORM_LIBS ${X11_LIBRARIES} ${X11_Xrandr_LIB} ${OPENGL_glx_LIBRARY})
endif()
list(APPEND NATIVE_INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/src/X11/")
if(NOT OGRE_GLSUPPORT_USE_WAYLAND)
list(APPEND NATIVE_INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/src/X11/")
endif()
endif ()

file(GLOB GLSUPPORT_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/include/*.h")
Expand Down Expand Up @@ -116,6 +134,10 @@ target_include_directories(OgreGLSupport PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/GLSL>"
PRIVATE "$<BUILD_INTERFACE:${NATIVE_INCLUDES}>")

if(OGRE_GLSUPPORT_USE_WAYLAND)
target_compile_definitions(OgreGLSupport PUBLIC OGRE_WAYLAND)
endif()

set_property(TARGET OgreGLSupport PROPERTY POSITION_INDEPENDENT_CODE ON)
generate_export_header(OgreGLSupport
EXPORT_MACRO_NAME _OgreGLExport
Expand Down
11 changes: 11 additions & 0 deletions RenderSystems/GLSupport/include/EGL/OgreEGLSupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ THE SOFTWARE.
#ifndef __EGLSupport_H__
#define __EGLSupport_H__

#ifndef OGRE_WAYLAND
// Tell EGL that we are using X11 (to select the appropriate definitions)
#define USE_X11
#else
// Tell EGL to not include X11 headers
#define EGL_NO_X11
// Tell EGL that we are using wayland
#ifndef WL_EGL_PLATFORM
#define WL_EGL_PLATFORM 1
#endif
#endif

#include "OgreGLNativeSupport.h"
#include <EGL/egl.h>
Expand Down
Loading