From cb3b3a0eafad7e2417cef875f2f12058d1035022 Mon Sep 17 00:00:00 2001 From: Lucas Baudin Date: Thu, 25 Feb 2016 23:11:26 +0100 Subject: [PATCH] [android] use PrivateData in irr_driver to give the androidapp to the driver --- src/graphics/irr_driver.cpp | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/src/graphics/irr_driver.cpp b/src/graphics/irr_driver.cpp index 80fb1f250..bf707eddd 100644 --- a/src/graphics/irr_driver.cpp +++ b/src/graphics/irr_driver.cpp @@ -94,6 +94,10 @@ using namespace irr; /** singleton */ IrrDriver *irr_driver = NULL; +#ifdef ANDROID +extern void* global_android_app; +#endif + GPUTimer m_perf_query[Q_LAST]; const int MIN_SUPPORTED_HEIGHT = 768; @@ -113,6 +117,15 @@ IrrDriver::IrrDriver() m_shadow_matrices = NULL; m_resolution_changing = RES_CHANGE_NONE; m_phase = SOLID_NORMAL_AND_DEPTH_PASS; +#ifdef ANDROID + struct irr::SIrrlichtCreationParameters p; + p.DriverType = video::EDT_NULL; + // The android app object is needed by the irrlicht device. + p.PrivateData = global_android_app; + p.WindowSize = core::dimension2d(1280,800); + + m_device = createDeviceEx(p); +#else m_device = irr::createDevice(video::EDT_NULL, irr::core::dimension2d(640, 480), /*bits*/16U, /**fullscreen*/ false, @@ -120,6 +133,7 @@ IrrDriver::IrrDriver() /*vsync*/false, /*event receiver*/ NULL, file_manager->getFileSystem()); +#endif m_request_screenshot = false; m_rtts = NULL; m_post_processing = NULL; @@ -440,10 +454,13 @@ void IrrDriver::initDevice() Log::verbose("irr_driver", "Trying to create device with " "%i bits\n", bits); + if(m_device) + break; #ifndef ANDROID_DEVICE params.DriverType = video::EDT_OPENGL; #else params.DriverType = video::EDT_OGLES2; + params.PrivateData = global_android_app; #endif params.Stencilbuffer = false; params.Bits = bits; @@ -493,9 +510,6 @@ void IrrDriver::initDevice() #ifndef ANDROID_DEVICE m_device = createDevice(video::EDT_OPENGL, -#else - m_device = createDevice(video::EDT_OGLES2, -#endif core::dimension2du(UserConfigParams::m_width, UserConfigParams::m_height ), 32, //bits per pixel @@ -505,6 +519,15 @@ void IrrDriver::initDevice() this, // event receiver file_manager->getFileSystem() ); +#else + struct irr::SIrrlichtCreationParameters p; + p.DriverType = video::EDT_OGLES2; + // The android app object is needed by the irrlicht device. + p.PrivateData = global_android_app; + p.WindowSize = core::dimension2d(1280,800); + + m_device = createDeviceEx(p); +#endif if (m_device) { Log::verbose("irr_driver", "An invalid resolution was set in "