Allow to use GLES renderer with Wayland device.
It would be nice to simplify it a bit, i.e. decide if OpenGL context should be created on device side or driver side, use single constructor in GLES driver etc... But I'm not really sure how it will look like after Benau's space partitioning work, so some refactoring postponed till later.
This commit is contained in:
parent
c8137fc0fa
commit
e00995d099
@ -64,6 +64,8 @@ namespace irr
|
||||
extern bool useCoreContext;
|
||||
IVideoDriver* createOpenGLDriver(const SIrrlichtCreationParameters& params,
|
||||
io::IFileSystem* io, CIrrDeviceWayland* device);
|
||||
IVideoDriver* createOGLES2Driver(const SIrrlichtCreationParameters& params,
|
||||
io::IFileSystem* io, CIrrDeviceWayland* device);
|
||||
}
|
||||
}
|
||||
|
||||
@ -730,7 +732,11 @@ bool CIrrDeviceWayland::initEGL()
|
||||
m_egl_context = new ContextManagerEGL();
|
||||
|
||||
ContextEGLParams egl_params;
|
||||
#ifdef _IRR_COMPILE_WITH_OGLES2_
|
||||
egl_params.opengl_api = CEGL_API_OPENGL_ES;
|
||||
#else
|
||||
egl_params.opengl_api = CEGL_API_OPENGL;
|
||||
#endif
|
||||
egl_params.surface_type = CEGL_SURFACE_WINDOW;
|
||||
egl_params.force_legacy_device = CreationParams.ForceLegacyDevice;
|
||||
egl_params.with_alpha_channel = CreationParams.WithAlphaChannel;
|
||||
@ -819,9 +825,6 @@ void CIrrDeviceWayland::createDriver()
|
||||
{
|
||||
switch(CreationParams.DriverType)
|
||||
{
|
||||
default:
|
||||
os::Printer::log("Wayland driver only supports OpenGL.", ELL_ERROR);
|
||||
break;
|
||||
case video::EDT_OPENGL:
|
||||
#ifdef _IRR_COMPILE_WITH_OPENGL_
|
||||
VideoDriver = video::createOpenGLDriver(CreationParams, FileSystem, this);
|
||||
@ -829,6 +832,19 @@ void CIrrDeviceWayland::createDriver()
|
||||
os::Printer::log("No OpenGL support compiled in.", ELL_ERROR);
|
||||
#endif
|
||||
break;
|
||||
case video::EDT_OGLES2:
|
||||
#ifdef _IRR_COMPILE_WITH_OGLES2_
|
||||
VideoDriver = video::createOGLES2Driver(CreationParams, FileSystem, this);
|
||||
#else
|
||||
os::Printer::log("No OpenGL ES 2.0 support compiled in.", ELL_ERROR);
|
||||
#endif
|
||||
break;
|
||||
case video::EDT_NULL:
|
||||
VideoDriver = video::createNullDriver(FileSystem, CreationParams.WindowSize);
|
||||
break;
|
||||
default:
|
||||
os::Printer::log("Wayland driver only supports OpenGL.", ELL_ERROR);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -54,6 +54,9 @@ namespace video
|
||||
#endif
|
||||
#if defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_)
|
||||
, HDc(0)
|
||||
#endif
|
||||
#ifdef _IRR_COMPILE_WITH_WAYLAND_DEVICE_
|
||||
, wl_device(0)
|
||||
#endif
|
||||
, Params(params)
|
||||
{
|
||||
@ -77,7 +80,7 @@ namespace video
|
||||
HDc = GetDC(data.OpenGLWin32.HWnd);
|
||||
egl_params.display = (NativeDisplayType)(HDc);
|
||||
#elif defined(_IRR_COMPILE_WITH_X11_DEVICE_)
|
||||
egl_params.window = data.OpenGLLinux.X11Window;
|
||||
egl_params.window = (EGLNativeWindowType)(data.OpenGLLinux.X11Window);
|
||||
egl_params.display = (EGLNativeDisplayType)(data.OpenGLLinux.X11Display);
|
||||
#elif defined(_IRR_COMPILE_WITH_ANDROID_DEVICE_)
|
||||
egl_params.window = ((struct android_app *)(params.PrivateData))->window;
|
||||
@ -133,6 +136,21 @@ namespace video
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_WAYLAND_DEVICE_
|
||||
COGLES2Driver::COGLES2Driver(const SIrrlichtCreationParameters& params,
|
||||
io::IFileSystem* io, CIrrDeviceWayland* device)
|
||||
: CNullDriver(io, params.WindowSize), COGLES2ExtensionHandler(),
|
||||
BridgeCalls(0), CurrentRenderMode(ERM_NONE), ResetRenderStates(true),
|
||||
Transformation3DChanged(true), AntiAlias(params.AntiAlias),
|
||||
RenderTargetTexture(0), CurrentRendertargetSize(0, 0),
|
||||
ColorFormat(ECF_R8G8B8), EglContext(0), Params(params)
|
||||
{
|
||||
EglContext = device->getEGLContext();
|
||||
wl_device = device;
|
||||
genericDriverInit(params.WindowSize, params.Stencilbuffer);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
//! destructor
|
||||
COGLES2Driver::~COGLES2Driver()
|
||||
@ -467,15 +485,23 @@ namespace video
|
||||
CNullDriver::endScene();
|
||||
|
||||
#if defined(_IRR_COMPILE_WITH_EGL_)
|
||||
|
||||
bool res = EglContext->swapBuffers();
|
||||
|
||||
if (!res)
|
||||
#ifdef _IRR_COMPILE_WITH_WAYLAND_DEVICE_
|
||||
if (wl_device != NULL)
|
||||
{
|
||||
os::Printer::log("Could not swap buffers for OpenGL-ES2 driver.");
|
||||
return false;
|
||||
wl_device->swapBuffers();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
bool res = EglContext->swapBuffers();
|
||||
|
||||
if (!res)
|
||||
{
|
||||
os::Printer::log("Could not swap buffers for OpenGL-ES2 driver.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#elif defined(_IRR_COMPILE_WITH_IPHONE_DEVICE_)
|
||||
glFlush();
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, ViewRenderbuffer);
|
||||
@ -2871,6 +2897,22 @@ namespace video
|
||||
}
|
||||
#endif
|
||||
|
||||
// -----------------------------------
|
||||
// WAYLAND VERSION
|
||||
// -----------------------------------
|
||||
#ifdef _IRR_COMPILE_WITH_WAYLAND_DEVICE_
|
||||
IVideoDriver* createOGLES2Driver(const SIrrlichtCreationParameters& params,
|
||||
io::IFileSystem* io, CIrrDeviceWayland* device)
|
||||
{
|
||||
#ifdef _IRR_COMPILE_WITH_OGLES2_
|
||||
return new COGLES2Driver(params, io, device);
|
||||
#else
|
||||
return 0;
|
||||
#endif // _IRR_COMPILE_WITH_OGLES2_
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// -----------------------------------
|
||||
// MACOSX VERSION
|
||||
// -----------------------------------
|
||||
|
@ -14,6 +14,8 @@
|
||||
#include "MacOSX/CIrrDeviceMacOSX.h"
|
||||
#elif defined(_IRR_COMPILE_WITH_IPHONE_DEVICE_)
|
||||
#include "iOS/CIrrDeviceiOS.h"
|
||||
#elif _IRR_COMPILE_WITH_WAYLAND_DEVICE_
|
||||
#include "CIrrDeviceWayland.h"
|
||||
#endif
|
||||
|
||||
#include "SIrrCreationParameters.h"
|
||||
@ -63,6 +65,11 @@ namespace video
|
||||
io::IFileSystem* io);
|
||||
#endif
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_WAYLAND_DEVICE_
|
||||
COGLES2Driver(const SIrrlichtCreationParameters& params,
|
||||
io::IFileSystem* io, CIrrDeviceWayland* device);
|
||||
#endif
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_OSX_DEVICE_
|
||||
COGLES2Driver(const SIrrlichtCreationParameters& params,
|
||||
io::IFileSystem* io, CIrrDeviceMacOSX *device);
|
||||
@ -461,6 +468,9 @@ namespace video
|
||||
#if defined(_IRR_COMPILE_WITH_EGL_)
|
||||
ContextManagerEGL* EglContext;
|
||||
#endif
|
||||
#ifdef _IRR_COMPILE_WITH_WAYLAND_DEVICE_
|
||||
CIrrDeviceWayland* wl_device;
|
||||
#endif
|
||||
#if defined(_IRR_COMPILE_WITH_IPHONE_DEVICE_)
|
||||
CIrrDeviceIPhone* Device;
|
||||
GLuint ViewFramebuffer;
|
||||
|
@ -4998,6 +4998,7 @@ IVideoDriver* createOpenGLDriver(const SIrrlichtCreationParameters& params,
|
||||
IVideoDriver* createOpenGLDriver(const SIrrlichtCreationParameters& params,
|
||||
io::IFileSystem* io, CIrrDeviceWayland* device)
|
||||
{
|
||||
#ifdef _IRR_COMPILE_WITH_OPENGL_
|
||||
COpenGLDriver* ogl = new COpenGLDriver(params, io, device);
|
||||
if (!ogl->initDriver(device))
|
||||
{
|
||||
@ -5005,7 +5006,9 @@ IVideoDriver* createOpenGLDriver(const SIrrlichtCreationParameters& params,
|
||||
ogl = 0;
|
||||
}
|
||||
return ogl;
|
||||
|
||||
#else
|
||||
return 0;
|
||||
#endif // _IRR_COMPILE_WITH_OPENGL_
|
||||
}
|
||||
#endif // _IRR_COMPILE_WITH_WAYLAND_DEVICE
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user