Allow to make single build with both x11 and wayland device
This commit is contained in:
parent
2f1b61b798
commit
e02a8f4448
@ -21,6 +21,7 @@ option(USE_FRIBIDI "Support for right-to-left languages" ON)
|
||||
option(CHECK_ASSETS "Check if assets are installed in ../stk-assets" ON)
|
||||
option(USE_SYSTEM_ANGELSCRIPT "Use system angelscript instead of built-in angelscript. If you enable this option, make sure to use a compatible version." OFF)
|
||||
option(ENABLE_NETWORK_MULTIPLAYER "Enable network multiplayer. This will replace the online profile GUI in the main menu with the network multiplayer GUI" OFF)
|
||||
option(ENABLE_WAYLAND_DEVICE "Enable Wayland device for linux build" OFF)
|
||||
|
||||
CMAKE_DEPENDENT_OPTION(BUILD_RECORDER "Build opengl recorder" ON
|
||||
"NOT SERVER_ONLY;NOT USE_GLES2;NOT APPLE" OFF)
|
||||
@ -413,7 +414,7 @@ if(NOT SERVER_ONLY)
|
||||
if(NOT USE_GLES2)
|
||||
target_link_libraries(supertuxkart ${OPENGL_gl_LIBRARY} glew graphics_utils)
|
||||
else()
|
||||
target_link_libraries(supertuxkart EGL GLESv2)
|
||||
target_link_libraries(supertuxkart GLESv2)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@ -426,7 +427,6 @@ if(UNIX AND NOT APPLE)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
|
||||
target_link_libraries(supertuxkart "-fsanitize=address")
|
||||
endif()
|
||||
target_link_libraries(supertuxkart wayland-client wayland-egl wayland-cursor EGL xkbcommon)
|
||||
endif()
|
||||
|
||||
if(BUILD_RECORDER)
|
||||
|
@ -11,6 +11,7 @@ include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include/"
|
||||
if (SERVER_ONLY)
|
||||
add_definitions(-DNO_IRR_COMPILE_WITH_OPENGL_)
|
||||
add_definitions(-DNO_IRR_COMPILE_WITH_X11_)
|
||||
add_definitions(-DNO_IRR_COMPILE_WITH_WAYLAND)
|
||||
else()
|
||||
if(NOT USE_GLES2)
|
||||
find_package(OpenGL REQUIRED)
|
||||
@ -23,6 +24,10 @@ if (UNIX AND NOT APPLE)
|
||||
include_directories(${X11_INCLUDE_DIR})
|
||||
endif()
|
||||
|
||||
if(ENABLE_WAYLAND_DEVICE)
|
||||
add_definitions(-D_IRR_COMPILE_WITH_WAYLAND)
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/source/Irrlicht/MacOSX" "${CMAKE_CURRENT_SOURCE_DIR}/source/Irrlicht")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -arch x86_64")
|
||||
@ -552,6 +557,14 @@ endif()
|
||||
add_library(stkirrlicht STATIC ${IRRLICHT_SOURCES})
|
||||
target_link_libraries(stkirrlicht ${PNG_LIBRARY} ${JPEG_LIBRARY} ${ZLIB_LIBRARY})
|
||||
|
||||
if(USE_GLES2 OR ENABLE_WAYLAND_DEVICE)
|
||||
target_link_libraries(stkirrlicht EGL)
|
||||
endif()
|
||||
|
||||
if(ENABLE_WAYLAND_DEVICE)
|
||||
target_link_libraries(stkirrlicht wayland-client wayland-egl wayland-cursor xkbcommon)
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
target_link_libraries(stkirrlicht imm32)
|
||||
endif()
|
||||
|
@ -127,8 +127,16 @@
|
||||
#endif
|
||||
#define _IRR_POSIX_API_
|
||||
#define _IRR_COMPILE_WITH_X11_DEVICE_
|
||||
//#define _IRR_COMPILE_WITH_WAYLAND
|
||||
#endif
|
||||
|
||||
#ifdef NO_IRR_COMPILE_WITH_WAYLAND
|
||||
#undef _IRR_COMPILE_WITH_WAYLAND
|
||||
#endif
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_WAYLAND
|
||||
#define _IRR_COMPILE_WITH_EGL_
|
||||
#endif
|
||||
|
||||
//! Define _IRR_COMPILE_WITH_JOYSTICK_SUPPORT_ if you want joystick events.
|
||||
#define _IRR_COMPILE_WITH_JOYSTICK_EVENTS_
|
||||
@ -211,14 +219,6 @@ define out. */
|
||||
#undef _IRR_COMPILE_WITH_X11_
|
||||
#endif
|
||||
|
||||
#define _IRR_COMPILE_WITH_WAYLAND
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_WAYLAND
|
||||
#define _IRR_COMPILE_WITH_EGL_
|
||||
#undef _IRR_COMPILE_WITH_X11_
|
||||
#undef _IRR_COMPILE_WITH_X11_DEVICE_
|
||||
#endif
|
||||
|
||||
//! Define _IRR_OPENGL_USE_EXTPOINTER_ if the OpenGL renderer should use OpenGL extensions via function pointers.
|
||||
/** On some systems there is no support for the dynamic extension of OpenGL
|
||||
via function pointers such that this has to be undef'ed. */
|
||||
|
@ -1,7 +1,6 @@
|
||||
extern bool GLContextDebugBit;
|
||||
|
||||
#include "CIrrDeviceWayland.h"
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_WAYLAND
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -615,6 +614,21 @@ const wl_registry_listener WaylandCallbacks::registry_listener = {
|
||||
|
||||
//const char* wmDeleteWindow = "WM_DELETE_WINDOW";
|
||||
|
||||
bool CIrrDeviceWayland::isWaylandDeviceWorking()
|
||||
{
|
||||
bool is_working = false;
|
||||
|
||||
wl_display* display = wl_display_connect(NULL);
|
||||
|
||||
if (display != NULL)
|
||||
{
|
||||
is_working = true;
|
||||
wl_display_disconnect(display);
|
||||
}
|
||||
|
||||
return is_working;
|
||||
}
|
||||
|
||||
//! constructor
|
||||
CIrrDeviceWayland::CIrrDeviceWayland(const SIrrlichtCreationParameters& param)
|
||||
: CIrrDeviceStub(param),
|
||||
@ -1401,3 +1415,5 @@ void CIrrDeviceWayland::initXAtoms()
|
||||
}
|
||||
|
||||
} // end namespace
|
||||
|
||||
#endif
|
||||
|
@ -3,6 +3,8 @@
|
||||
|
||||
#include "IrrCompileConfig.h"
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_WAYLAND
|
||||
|
||||
#include "CIrrDeviceStub.h"
|
||||
#include "IrrlichtDevice.h"
|
||||
#include "IImagePresenter.h"
|
||||
@ -236,6 +238,7 @@ namespace irr
|
||||
ContextManagerEGL* EglContext;
|
||||
|
||||
public:
|
||||
static bool isWaylandDeviceWorking();
|
||||
void signalEvent(const SEvent&);
|
||||
void addMode(const core::dimension2du &mode) { Modes.push_back(mode); }
|
||||
void setCurrentMode(const core::dimension2du &mode) { CurrentModes = mode; }
|
||||
@ -322,5 +325,7 @@ private:
|
||||
|
||||
} // end namespace irr
|
||||
|
||||
#endif
|
||||
|
||||
#endif // CIRRDEVICEWAYLAND_H
|
||||
|
||||
|
@ -22,6 +22,9 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include "IrrlichtDevice.h"
|
||||
#if defined(_IRR_COMPILE_WITH_X11_DEVICE_)
|
||||
#include "CIrrDeviceLinux.h"
|
||||
#endif
|
||||
@ -35,24 +38,16 @@
|
||||
namespace irr
|
||||
{
|
||||
|
||||
#if defined(_IRR_COMPILE_WITH_X11_DEVICE_)
|
||||
// constructor linux
|
||||
COSOperator::COSOperator(const core::stringc& osVersion, CIrrDeviceLinux* device)
|
||||
: OperatingSystem(osVersion), IrrDeviceLinux(device)
|
||||
COSOperator::COSOperator(const core::stringc& osVersion, IrrlichtDevice* device)
|
||||
: OperatingSystem(osVersion), IrrDevice(device)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(_IRR_COMPILE_WITH_WAYLAND)
|
||||
// constructor linux
|
||||
COSOperator::COSOperator(const core::stringc& osVersion, CIrrDeviceWayland* device)
|
||||
: OperatingSystem(osVersion), IrrDeviceWayland(device)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
// constructor
|
||||
COSOperator::COSOperator(const core::stringc& osVersion) : OperatingSystem(osVersion)
|
||||
COSOperator::COSOperator(const core::stringc& osVersion)
|
||||
: OperatingSystem(osVersion), IrrDevice(NULL)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
setDebugName("COSOperator");
|
||||
@ -129,12 +124,28 @@ void COSOperator::copyToClipboard(const c8* text) const
|
||||
|
||||
OSXCopyToClipboard(text);
|
||||
|
||||
#elif defined(_IRR_COMPILE_WITH_X11_DEVICE_)
|
||||
if ( IrrDeviceLinux )
|
||||
IrrDeviceLinux->copyToClipboard(text);
|
||||
#elif defined(_IRR_COMPILE_WITH_WAYLAND)
|
||||
if ( IrrDeviceWayland )
|
||||
IrrDeviceWayland->copyToClipboard(text);
|
||||
#elif defined(_IRR_COMPILE_WITH_X11_DEVICE_) || defined(_IRR_COMPILE_WITH_WAYLAND)
|
||||
if (IrrDevice != NULL)
|
||||
{
|
||||
#if defined(_IRR_COMPILE_WITH_X11_DEVICE_)
|
||||
if (IrrDevice->getType() == EIDT_X11)
|
||||
{
|
||||
CIrrDeviceLinux* device = dynamic_cast<CIrrDeviceLinux*>(IrrDevice);
|
||||
assert(device);
|
||||
|
||||
device->copyToClipboard(text);
|
||||
}
|
||||
#endif
|
||||
#if defined(_IRR_COMPILE_WITH_WAYLAND)
|
||||
if (IrrDevice->getType() == EIDT_WAYLAND)
|
||||
{
|
||||
CIrrDeviceWayland* device = dynamic_cast<CIrrDeviceWayland*>(IrrDevice);
|
||||
assert(device);
|
||||
|
||||
device->copyToClipboard(text);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
|
||||
#endif
|
||||
@ -186,14 +197,30 @@ const c8* COSOperator::getTextFromClipboard() const
|
||||
#elif defined(_IRR_COMPILE_WITH_OSX_DEVICE_)
|
||||
return (OSXCopyFromClipboard());
|
||||
|
||||
#elif defined(_IRR_COMPILE_WITH_X11_DEVICE_)
|
||||
if ( IrrDeviceLinux )
|
||||
return IrrDeviceLinux->getTextFromClipboard();
|
||||
return 0;
|
||||
|
||||
#elif defined(_IRR_COMPILE_WITH_WAYLAND)
|
||||
if ( IrrDeviceWayland )
|
||||
return IrrDeviceWayland->getTextFromClipboard();
|
||||
|
||||
#elif defined(_IRR_COMPILE_WITH_X11_DEVICE_) || defined(_IRR_COMPILE_WITH_WAYLAND)
|
||||
if (IrrDevice != NULL)
|
||||
{
|
||||
#if defined(_IRR_COMPILE_WITH_X11_DEVICE_)
|
||||
if (IrrDevice->getType() == EIDT_X11)
|
||||
{
|
||||
CIrrDeviceLinux* device = dynamic_cast<CIrrDeviceLinux*>(IrrDevice);
|
||||
assert(device);
|
||||
|
||||
return device->getTextFromClipboard();
|
||||
}
|
||||
#endif
|
||||
#if defined(_IRR_COMPILE_WITH_WAYLAND)
|
||||
if (IrrDevice->getType() == EIDT_WAYLAND)
|
||||
{
|
||||
CIrrDeviceWayland* device = dynamic_cast<CIrrDeviceWayland*>(IrrDevice);
|
||||
assert(device);
|
||||
|
||||
return device->getTextFromClipboard();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return 0;
|
||||
|
||||
#else
|
||||
|
@ -10,8 +10,7 @@
|
||||
namespace irr
|
||||
{
|
||||
|
||||
class CIrrDeviceLinux;
|
||||
class CIrrDeviceWayland;
|
||||
class IrrlichtDevice;
|
||||
|
||||
//! The Operating system operator provides operation system specific methods and informations.
|
||||
class COSOperator : public IOSOperator
|
||||
@ -19,12 +18,7 @@ class COSOperator : public IOSOperator
|
||||
public:
|
||||
|
||||
// constructor
|
||||
#if defined(_IRR_COMPILE_WITH_X11_DEVICE_)
|
||||
COSOperator(const core::stringc& osversion, CIrrDeviceLinux* device);
|
||||
#endif
|
||||
#if defined(_IRR_COMPILE_WITH_WAYLAND)
|
||||
COSOperator(const core::stringc& osversion, CIrrDeviceWayland* device);
|
||||
#endif
|
||||
COSOperator(const core::stringc& osversion, IrrlichtDevice* device);
|
||||
COSOperator(const core::stringc& osversion);
|
||||
|
||||
//! returns the current operation system version as string.
|
||||
@ -59,14 +53,7 @@ public:
|
||||
private:
|
||||
|
||||
core::stringc OperatingSystem;
|
||||
|
||||
#if defined(_IRR_COMPILE_WITH_X11_DEVICE_)
|
||||
CIrrDeviceLinux * IrrDeviceLinux;
|
||||
#endif
|
||||
#if defined(_IRR_COMPILE_WITH_WAYLAND)
|
||||
CIrrDeviceWayland * IrrDeviceWayland;
|
||||
#endif
|
||||
|
||||
IrrlichtDevice* IrrDevice;
|
||||
|
||||
};
|
||||
|
||||
|
@ -704,6 +704,7 @@ COpenGLDriver::COpenGLDriver(const SIrrlichtCreationParameters& params,
|
||||
|
||||
bool COpenGLDriver::changeRenderContext(const SExposedVideoData& videoData, CIrrDeviceWayland* device)
|
||||
{
|
||||
//TODO
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -722,7 +723,7 @@ bool COpenGLDriver::initDriver(CIrrDeviceWayland* device)
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif // _IRR_COMPILE_WITH_X11_DEVICE_
|
||||
#endif // _IRR_COMPILE_WITH_WAYLAND
|
||||
|
||||
|
||||
|
||||
|
@ -95,7 +95,12 @@ namespace irr
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_WAYLAND
|
||||
if (params.DeviceType == EIDT_WAYLAND || (!dev && params.DeviceType == EIDT_BEST))
|
||||
{
|
||||
if (CIrrDeviceWayland::isWaylandDeviceWorking())
|
||||
{
|
||||
dev = new CIrrDeviceWayland(params);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_X11_DEVICE_
|
||||
|
@ -109,8 +109,12 @@ CGUIEditBox::~CGUIEditBox()
|
||||
if (Operator)
|
||||
Operator->drop();
|
||||
#ifdef _IRR_COMPILE_WITH_X11_DEVICE_
|
||||
CIrrDeviceLinux* dl = dynamic_cast<CIrrDeviceLinux*>(irr_driver->getDevice());
|
||||
if (irr_driver->getDevice()->getType() == irr::EIDT_X11)
|
||||
{
|
||||
CIrrDeviceLinux* dl = dynamic_cast<CIrrDeviceLinux*>(
|
||||
irr_driver->getDevice());
|
||||
dl->setIMEEnable(false);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
@ -243,7 +247,6 @@ bool CGUIEditBox::OnEvent(const SEvent& event)
|
||||
#ifndef SERVER_ONLY
|
||||
if (isEnabled())
|
||||
{
|
||||
|
||||
switch(event.EventType)
|
||||
{
|
||||
case EET_GUI_EVENT:
|
||||
@ -255,17 +258,25 @@ bool CGUIEditBox::OnEvent(const SEvent& event)
|
||||
setTextMarkers(0,0);
|
||||
}
|
||||
#ifdef _IRR_COMPILE_WITH_X11_DEVICE_
|
||||
CIrrDeviceLinux* dl = dynamic_cast<CIrrDeviceLinux*>(irr_driver->getDevice());
|
||||
if (irr_driver->getDevice()->getType() == irr::EIDT_X11)
|
||||
{
|
||||
CIrrDeviceLinux* dl = dynamic_cast<CIrrDeviceLinux*>(
|
||||
irr_driver->getDevice());
|
||||
dl->setIMEEnable(false);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#ifdef _IRR_COMPILE_WITH_X11_DEVICE_
|
||||
else if (event.GUIEvent.EventType == EGET_ELEMENT_FOCUSED)
|
||||
{
|
||||
CIrrDeviceLinux* dl = dynamic_cast<CIrrDeviceLinux*>(irr_driver->getDevice());
|
||||
if (irr_driver->getDevice()->getType() == irr::EIDT_X11)
|
||||
{
|
||||
CIrrDeviceLinux* dl = dynamic_cast<CIrrDeviceLinux*>(
|
||||
irr_driver->getDevice());
|
||||
dl->setIMEEnable(true);
|
||||
dl->setIMELocation(calculateICPos());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
#if defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_)
|
||||
@ -1634,11 +1645,15 @@ void CGUIEditBox::calculateScrollPos()
|
||||
|
||||
// todo: adjust scrollbar
|
||||
#if defined(_IRR_COMPILE_WITH_X11_DEVICE_)
|
||||
CIrrDeviceLinux* dl = dynamic_cast<CIrrDeviceLinux*>(irr_driver->getDevice());
|
||||
if (irr_driver->getDevice()->getType() == irr::EIDT_X11)
|
||||
{
|
||||
CIrrDeviceLinux* dl = dynamic_cast<CIrrDeviceLinux*>(
|
||||
irr_driver->getDevice());
|
||||
if (dl)
|
||||
{
|
||||
dl->setIMELocation(calculateICPos());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif // SERVER_ONLY
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user