[android] backport the Irrlicht.cpp createDevice changes, fix the compile error, and use OGLES2 on android

This commit is contained in:
Lucas Baudin 2016-02-25 20:15:24 +01:00
parent d2b5d5ad05
commit e39efc128c
2 changed files with 21 additions and 20 deletions

View File

@ -4,7 +4,7 @@
#include "IrrCompileConfig.h" #include "IrrCompileConfig.h"
static const char* const copyright = "Irrlicht Engine (c) 2002-2012 Nikolaus Gebhardt"; //static const char* const copyright = "Irrlicht Engine (c) 2002-2012 Nikolaus Gebhardt";
#ifdef _IRR_WINDOWS_ #ifdef _IRR_WINDOWS_
#include <windows.h> #include <windows.h>
@ -30,10 +30,6 @@ static const char* const copyright = "Irrlicht Engine (c) 2002-2012 Nikolaus Geb
#include "CIrrDeviceLinux.h" #include "CIrrDeviceLinux.h"
#endif #endif
#ifdef _IRR_COMPILE_WITH_IPHONE_DEVICE_
#include "iOS/CIrrDeviceiOS.h"
#endif
#ifdef _IRR_COMPILE_WITH_SDL_DEVICE_ #ifdef _IRR_COMPILE_WITH_SDL_DEVICE_
#include "CIrrDeviceSDL.h" #include "CIrrDeviceSDL.h"
#endif #endif
@ -57,7 +53,8 @@ namespace irr
IRRLICHT_API IrrlichtDevice* IRRCALLCONV createDevice(video::E_DRIVER_TYPE driverType, IRRLICHT_API IrrlichtDevice* IRRCALLCONV createDevice(video::E_DRIVER_TYPE driverType,
const core::dimension2d<u32>& windowSize, const core::dimension2d<u32>& windowSize,
u32 bits, bool fullscreen, u32 bits, bool fullscreen,
bool stencilbuffer, bool vsync, IEventReceiver* res) bool stencilbuffer, bool vsync, IEventReceiver* res,
io::IFileSystem *file_system)
{ {
SIrrlichtCreationParameters p; SIrrlichtCreationParameters p;
p.DriverType = driverType; p.DriverType = driverType;
@ -67,6 +64,7 @@ namespace irr
p.Stencilbuffer = stencilbuffer; p.Stencilbuffer = stencilbuffer;
p.Vsync = vsync; p.Vsync = vsync;
p.EventReceiver = res; p.EventReceiver = res;
p.FileSystem = file_system;
return createDeviceEx(p); return createDeviceEx(p);
} }
@ -95,11 +93,6 @@ namespace irr
if (params.DeviceType == EIDT_X11 || (!dev && params.DeviceType == EIDT_BEST)) if (params.DeviceType == EIDT_X11 || (!dev && params.DeviceType == EIDT_BEST))
dev = new CIrrDeviceLinux(params); dev = new CIrrDeviceLinux(params);
#endif #endif
#ifdef _IRR_COMPILE_WITH_IPHONE_DEVICE_
if (params.DeviceType == EIDT_IPHONE || (!dev && params.DeviceType == EIDT_BEST))
dev = new CIrrDeviceIPhone(params);
#endif
#ifdef _IRR_COMPILE_WITH_SDL_DEVICE_ #ifdef _IRR_COMPILE_WITH_SDL_DEVICE_
if (params.DeviceType == EIDT_SDL || (!dev && params.DeviceType == EIDT_BEST)) if (params.DeviceType == EIDT_SDL || (!dev && params.DeviceType == EIDT_BEST))
@ -111,17 +104,17 @@ namespace irr
dev = new CIrrDeviceFB(params); dev = new CIrrDeviceFB(params);
#endif #endif
#ifdef _IRR_COMPILE_WITH_ANDROID_DEVICE_
if (params.DeviceType == EIDT_ANDROID || (!dev && params.DeviceType == EIDT_BEST)) {
dev = new CIrrDeviceAndroid(params);
}
#endif
#ifdef _IRR_COMPILE_WITH_CONSOLE_DEVICE_ #ifdef _IRR_COMPILE_WITH_CONSOLE_DEVICE_
if (params.DeviceType == EIDT_CONSOLE || (!dev && params.DeviceType == EIDT_BEST)) if (params.DeviceType == EIDT_CONSOLE || (!dev && params.DeviceType == EIDT_BEST))
dev = new CIrrDeviceConsole(params); dev = new CIrrDeviceConsole(params);
#endif #endif
#ifdef _IRR_COMPILE_WITH_ANDROID_DEVICE_
if (params.DeviceType == EIDT_ANDROID || (!dev && params.DeviceType == EIDT_BEST)) {
dev = new CIrrDeviceAndroid(params);
}
#endif
if (dev && !dev->getVideoDriver() && params.DriverType != video::EDT_NULL) if (dev && !dev->getVideoDriver() && params.DriverType != video::EDT_NULL)
{ {
dev->closeDevice(); // destroy window dev->closeDevice(); // destroy window
@ -147,7 +140,7 @@ namespace video
} // end namespace irr } // end namespace irr
#if defined(_IRR_WINDOWS_API_) #if defined(_IRR_WINDOWS_API_) && !defined(_IRR_STATIC_LIB_)
BOOL APIENTRY DllMain( HANDLE hModule, BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call, DWORD ul_reason_for_call,

View File

@ -113,7 +113,7 @@ IrrDriver::IrrDriver()
m_shadow_matrices = NULL; m_shadow_matrices = NULL;
m_resolution_changing = RES_CHANGE_NONE; m_resolution_changing = RES_CHANGE_NONE;
m_phase = SOLID_NORMAL_AND_DEPTH_PASS; m_phase = SOLID_NORMAL_AND_DEPTH_PASS;
m_device = createDevice(video::EDT_NULL, m_device = irr::createDevice(video::EDT_NULL,
irr::core::dimension2d<u32>(640, 480), irr::core::dimension2d<u32>(640, 480),
/*bits*/16U, /**fullscreen*/ false, /*bits*/16U, /**fullscreen*/ false,
/*stencilBuffer*/ false, /*stencilBuffer*/ false,
@ -440,7 +440,11 @@ void IrrDriver::initDevice()
Log::verbose("irr_driver", "Trying to create device with " Log::verbose("irr_driver", "Trying to create device with "
"%i bits\n", bits); "%i bits\n", bits);
#ifdef ANDROID_DEVICE
params.DriverType = video::EDT_OPENGL; params.DriverType = video::EDT_OPENGL;
#else
params.DriverType = video::EDT_OGLES2;
#endif
params.Stencilbuffer = false; params.Stencilbuffer = false;
params.Bits = bits; params.Bits = bits;
params.EventReceiver = this; params.EventReceiver = this;
@ -473,7 +477,7 @@ void IrrDriver::initDevice()
(int)UserConfigParams::m_antialiasing); (int)UserConfigParams::m_antialiasing);
} }
*/ */
m_device = createDeviceEx(params); m_device = irr::createDeviceEx(params);
if(m_device) if(m_device)
break; break;
@ -487,7 +491,11 @@ void IrrDriver::initDevice()
UserConfigParams::m_width = MIN_SUPPORTED_WIDTH; UserConfigParams::m_width = MIN_SUPPORTED_WIDTH;
UserConfigParams::m_height = MIN_SUPPORTED_HEIGHT; UserConfigParams::m_height = MIN_SUPPORTED_HEIGHT;
#ifdef ANDROID_DEVICE
m_device = createDevice(video::EDT_OPENGL, m_device = createDevice(video::EDT_OPENGL,
#else
m_device = createDevice(video::EDT_OGLES2,
#endif
core::dimension2du(UserConfigParams::m_width, core::dimension2du(UserConfigParams::m_width,
UserConfigParams::m_height ), UserConfigParams::m_height ),
32, //bits per pixel 32, //bits per pixel