From c13f812290172455dae72c59d32309ddf4312693 Mon Sep 17 00:00:00 2001 From: Deve Date: Tue, 30 May 2017 21:39:30 +0200 Subject: [PATCH] Simplify previous commit and also fix the double egl context deletion --- .../source/Irrlicht/CIrrDeviceWayland.cpp | 27 ++++++++------- .../source/Irrlicht/CIrrDeviceWayland.h | 1 - .../source/Irrlicht/COGLES2Driver.cpp | 34 ++++++------------- lib/irrlicht/source/Irrlicht/COGLES2Driver.h | 3 -- .../source/Irrlicht/COpenGLDriver.cpp | 2 +- 5 files changed, 25 insertions(+), 42 deletions(-) diff --git a/lib/irrlicht/source/Irrlicht/CIrrDeviceWayland.cpp b/lib/irrlicht/source/Irrlicht/CIrrDeviceWayland.cpp index 5b2ee7c26..715d239d7 100644 --- a/lib/irrlicht/source/Irrlicht/CIrrDeviceWayland.cpp +++ b/lib/irrlicht/source/Irrlicht/CIrrDeviceWayland.cpp @@ -120,7 +120,7 @@ public: uint32_t serial, uint32_t time, uint32_t button, uint32_t state) { - CIrrDeviceWayland* device = static_cast(data); + CIrrDeviceWayland* device = static_cast(data); SEvent irrevent; irrevent.EventType = irr::EET_MOUSE_INPUT_EVENT; @@ -210,7 +210,7 @@ public: static void pointer_axis(void* data, wl_pointer* wl_pointer, uint32_t time, uint32_t axis, wl_fixed_t value) { - CIrrDeviceWayland* device = static_cast(data); + CIrrDeviceWayland* device = static_cast(data); if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL) { @@ -733,11 +733,16 @@ 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 + + if (CreationParams.DriverType == video::EDT_OGLES2) + { + egl_params.opengl_api = CEGL_API_OPENGL_ES; + } + else + { + egl_params.opengl_api = CEGL_API_OPENGL; + } + egl_params.surface_type = CEGL_SURFACE_WINDOW; egl_params.force_legacy_device = CreationParams.ForceLegacyDevice; egl_params.with_alpha_channel = CreationParams.WithAlphaChannel; @@ -849,12 +854,6 @@ void CIrrDeviceWayland::createDriver() } } -void CIrrDeviceWayland::swapBuffers() -{ - wl_display_dispatch_pending(m_display); - m_egl_context->swapBuffers(); -} - void CIrrDeviceWayland::updateCursor() { if (!getCursorControl()->isVisible() && CreationParams.Fullscreen) @@ -887,6 +886,8 @@ bool CIrrDeviceWayland::run() { os::Timer::tick(); + wl_display_dispatch_pending(m_display); + for (unsigned int i = 0; i < m_events.size(); i++) { postEventFromUser(m_events[i]); diff --git a/lib/irrlicht/source/Irrlicht/CIrrDeviceWayland.h b/lib/irrlicht/source/Irrlicht/CIrrDeviceWayland.h index 37c0896b2..4983a0481 100644 --- a/lib/irrlicht/source/Irrlicht/CIrrDeviceWayland.h +++ b/lib/irrlicht/source/Irrlicht/CIrrDeviceWayland.h @@ -135,7 +135,6 @@ namespace irr static bool isWaylandDeviceWorking(); ContextManagerEGL* getEGLContext() {return m_egl_context;} - void swapBuffers(); void updateCursor(); unsigned int getWidth() {return m_width;} unsigned int getHeight() {return m_height;} diff --git a/lib/irrlicht/source/Irrlicht/COGLES2Driver.cpp b/lib/irrlicht/source/Irrlicht/COGLES2Driver.cpp index 68617f854..7bfb7356d 100644 --- a/lib/irrlicht/source/Irrlicht/COGLES2Driver.cpp +++ b/lib/irrlicht/source/Irrlicht/COGLES2Driver.cpp @@ -54,9 +54,6 @@ 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) { @@ -146,7 +143,6 @@ namespace video ColorFormat(ECF_R8G8B8), EglContext(0), Params(params) { EglContext = device->getEGLContext(); - wl_device = device; genericDriverInit(params.WindowSize, params.Stencilbuffer); } #endif @@ -162,7 +158,7 @@ namespace video if (BridgeCalls) delete BridgeCalls; -#if defined(_IRR_COMPILE_WITH_EGL_) +#if defined(_IRR_COMPILE_WITH_EGL_) && !defined(_IRR_COMPILE_WITH_WAYLAND_DEVICE_) delete EglContext; #if defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_) @@ -482,30 +478,20 @@ namespace video //! presents the rendered scene on the screen, returns false if failed bool COGLES2Driver::endScene() { - CNullDriver::endScene(); + CNullDriver::endScene(); #if defined(_IRR_COMPILE_WITH_EGL_) -#ifdef _IRR_COMPILE_WITH_WAYLAND_DEVICE_ - if (wl_device != NULL) + bool res = EglContext->swapBuffers(); + + if (!res) { - 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; - } + 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); - Device->displayEnd(); + glFlush(); + glBindRenderbuffer(GL_RENDERBUFFER, ViewRenderbuffer); + Device->displayEnd(); #endif return true; diff --git a/lib/irrlicht/source/Irrlicht/COGLES2Driver.h b/lib/irrlicht/source/Irrlicht/COGLES2Driver.h index 5b685ba43..734e6e416 100644 --- a/lib/irrlicht/source/Irrlicht/COGLES2Driver.h +++ b/lib/irrlicht/source/Irrlicht/COGLES2Driver.h @@ -468,9 +468,6 @@ 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; diff --git a/lib/irrlicht/source/Irrlicht/COpenGLDriver.cpp b/lib/irrlicht/source/Irrlicht/COpenGLDriver.cpp index 3d08ac836..2d58a401a 100644 --- a/lib/irrlicht/source/Irrlicht/COpenGLDriver.cpp +++ b/lib/irrlicht/source/Irrlicht/COpenGLDriver.cpp @@ -982,7 +982,7 @@ bool COpenGLDriver::endScene() #ifdef _IRR_COMPILE_WITH_WAYLAND_DEVICE_ if (DeviceType == EIDT_WAYLAND) { - wl_device->swapBuffers(); + wl_device->getEGLContext()->swapBuffers(); return true; } #endif