Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
19 changes: 18 additions & 1 deletion Components/Bites/src/OgreApplicationContextSDL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "OgreApplicationContext.h"

#include "OgreException.h"
#include "OgreRoot.h"
#include "OgreRenderWindow.h"

Expand All @@ -13,6 +14,11 @@

#include "SDLInputMapping.h"

// OGRE_WAYLAND is only defined (as 1) for wayland builds
#ifndef OGRE_WAYLAND
#define OGRE_WAYLAND 0
#endif

namespace OgreBites {

ApplicationContextSDL::ApplicationContextSDL(const Ogre::String& appName) : ApplicationContextBase(appName)
Expand All @@ -38,7 +44,18 @@ NativeWindowPair ApplicationContextSDL::createWindow(const Ogre::String& name, O
if(SDL_GameControllerAddMappingsFromFile("gamecontrollerdb.txt") > 0)
Ogre::LogManager::getSingleton().logMessage("[SDL] gamecontrollerdb.txt loaded");

SDL_InitSubSystem(SDL_INIT_VIDEO | SDL_INIT_GAMECONTROLLER);
#if OGRE_PLATFORM == OGRE_PLATFORM_LINUX
// The EGL backend is built for one windowing system only, so do not let
// SDL pick the other one (e.g. X11 on a Wayland session) unless the
// application chose a driver explicitly.
if (!SDL_getenv("SDL_VIDEODRIVER"))
SDL_setenv("SDL_VIDEODRIVER", OGRE_WAYLAND ? "wayland" : "x11", 1);
#endif

if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0)
OGRE_EXCEPT(Ogre::Exception::ERR_RENDERINGAPI_ERROR,
Ogre::String("SDL video initialization failed: ") + SDL_GetError());
SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER);
}

auto p = mRoot->getRenderSystem()->getRenderWindowDescription();
Expand Down
32 changes: 22 additions & 10 deletions RenderSystems/GLSupport/src/EGL/Wayland/OgreWaylandEGLSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,21 +80,33 @@ NativeDisplayType WaylandEGLSupport::getNativeDisplay()
RenderWindow* WaylandEGLSupport::newWindow(const String& name, unsigned int width, unsigned int height, bool fullScreen,
const NameValuePairList* miscParams)
{
if (miscParams)
{
NameValuePairList::const_iterator end = miscParams->end();

// A window from another backend cannot be presented here. Without this
// check it would be silently ignored and rendered into an offscreen
// surface instead.
if (miscParams->find("externalWindowHandle") != end || miscParams->find("parentWindowHandle") != end)
{
OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS,
"externalWindowHandle/parentWindowHandle is not a Wayland window; "
"recompile with OGRE_USE_WAYLAND=OFF");
}

if (miscParams->find("externalWlSurface") != end && miscParams->find("externalWlDisplay") == end)
{
OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, "externalWlDisplay required with externalWlSurface");
}
}

if (!mInitialWindow)
{
if (miscParams)
{
NameValuePairList::const_iterator opt;
NameValuePairList::const_iterator end = miscParams->end();

if ((opt = miscParams->find("externalWlDisplay")) != end)
{
NameValuePairList::const_iterator opt = miscParams->find("externalWlDisplay");
if (opt != miscParams->end())
mNativeDisplay = reinterpret_cast<NativeDisplayType>(StringConverter::parseSizeT(opt->second));
}
else if (miscParams->find("externalWlSurface") != end)
{
OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, "externalWlDisplay required with externalWlSurface");
}
}

doInit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,6 @@ void WaylandEGLWindow::create(const String& name, uint width, uint height, bool
mIsExternalGLControl = StringConverter::parseBool(opt->second);
}

OgreAssert(miscParams->find("parentWindowHandle") == end && miscParams->find("externalWindowHandle") == end,
"Recompile with OGRE_USE_WAYLAND=OFF");
}

initNativeCreatedWindow(miscParams);
Expand Down
15 changes: 15 additions & 0 deletions RenderSystems/GLSupport/src/EGL/X11/OgreX11EGLSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,21 @@ namespace Ogre {
bool fullScreen,
const NameValuePairList *miscParams)
{
if (miscParams)
{
NameValuePairList::const_iterator end = miscParams->end();

// A Wayland window cannot be presented here. Without this check it
// would be silently ignored when no X display is available and the
// window would render into an offscreen surface instead.
if (miscParams->find("externalWlDisplay") != end || miscParams->find("externalWlSurface") != end)
{
OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS,
"externalWlDisplay/externalWlSurface is not an X11 window; "
"recompile with OGRE_USE_WAYLAND=ON");
}
}

EGLWindow* window =
mNativeDisplay == EGL_DEFAULT_DISPLAY ? new EGLWindow(this) : new X11EGLWindow(this);
window->create(name, width, height, fullScreen, miscParams);
Expand Down
2 changes: 0 additions & 2 deletions RenderSystems/GLSupport/src/EGL/X11/OgreX11EGLWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ namespace Ogre {
NameValuePairList::const_iterator opt;
NameValuePairList::const_iterator end = miscParams->end();

OgreAssert(miscParams->find("externalWlDisplay") == end, "Recompile with OGRE_USE_WAYLAND=ON");

if ((opt = miscParams->find("parentWindowHandle")) != end ||
(opt = miscParams->find("externalWindowHandle")) != end)
{
Expand Down
Loading