diff --git a/CMakeLists.txt b/CMakeLists.txt index e33b64a2e..bb01dd179 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -566,7 +566,11 @@ if(NOT SERVER_ONLY) if(NOT USE_GLES2) target_link_libraries(supertuxkart ${OPENGL_gl_LIBRARY} ${GLEW_LIBRARIES}) elseif (IOS) - target_link_libraries(supertuxkart "-framework OpenGLES -framework UIKit -framework CoreMotion -framework Foundation -framework QuartzCore") + target_link_libraries(supertuxkart "-framework OpenGLES + -framework UIKit + -framework CoreMotion + -framework Foundation + -framework GLKit") else() target_link_libraries(supertuxkart GLESv2) endif() diff --git a/lib/irrlicht/CMakeLists.txt b/lib/irrlicht/CMakeLists.txt index b7ebef0ce..55937f80a 100644 --- a/lib/irrlicht/CMakeLists.txt +++ b/lib/irrlicht/CMakeLists.txt @@ -607,11 +607,8 @@ endif() if(IOS) set(IRRLICHT_SOURCES ${IRRLICHT_SOURCES} - source/Irrlicht/CEAGLManager.mm - source/Irrlicht/CIrrDeviceiOS.mm) - - set_source_files_properties(source/Irrlicht/CEAGLManager.mm PROPERTIES COMPILE_FLAGS "-x objective-c++ -O3 -fno-rtti") - set_source_files_properties(source/Irrlicht/CEAGLManager.mm PROPERTIES LANGUAGE C) + source/Irrlicht/CIrrDeviceiOS.mm + source/Irrlicht/CIrrDeviceiOS.h) set_source_files_properties(source/Irrlicht/CIrrDeviceiOS.mm PROPERTIES COMPILE_FLAGS "-x objective-c++ -O3 -fno-rtti") set_source_files_properties(source/Irrlicht/CIrrDeviceiOS.mm PROPERTIES LANGUAGE C) diff --git a/lib/irrlicht/include/IContextManager.h b/lib/irrlicht/include/IContextManager.h deleted file mode 100644 index fd98f937b..000000000 --- a/lib/irrlicht/include/IContextManager.h +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (C) 2013-2015 Patryk Nadrowski -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in irrlicht.h - -#ifndef __IRR_I_CONTEXT_MANAGER_H_INCLUDED__ -#define __IRR_I_CONTEXT_MANAGER_H_INCLUDED__ - -#include "SExposedVideoData.h" -#include "SIrrCreationParameters.h" - -namespace irr -{ -namespace video -{ - // For system specific window contexts (used for OpenGL) - class IContextManager : public virtual IReferenceCounted - { - public: - //! Initialize manager with device creation parameters and device window (passed as exposed video data) - virtual bool initialize(const SIrrlichtCreationParameters& params, const SExposedVideoData& data) =0; - - //! Terminate manager, any cleanup that is left over. Manager needs a new initialize to be usable again - virtual void terminate() =0; - - //! Create surface based on current window set - virtual bool generateSurface() =0; - - //! Destroy current surface - virtual void destroySurface() =0; - - //! Create context based on current surface - virtual bool generateContext() =0; - - //! Destroy current context - virtual void destroyContext() =0; - - //! Get current context - virtual const SExposedVideoData& getContext() const =0; - - //! Change render context, disable old and activate new defined by videoData - virtual bool activateContext(const SExposedVideoData& videoData) =0; - - //! Swap buffers. - virtual bool swapBuffers() =0; - }; - -} // end namespace video -} // end namespace irr - - -#endif diff --git a/lib/irrlicht/source/Irrlicht/CEAGLManager.h b/lib/irrlicht/source/Irrlicht/CEAGLManager.h deleted file mode 100644 index b91234a89..000000000 --- a/lib/irrlicht/source/Irrlicht/CEAGLManager.h +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright (C) 2015 Patryk Nadrowski -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in Irrlicht.h - -#ifndef __C_EAGL_MANAGER_H_INCLUDED__ -#define __C_EAGL_MANAGER_H_INCLUDED__ - -#include "IrrCompileConfig.h" - -#include "SIrrCreationParameters.h" -#include "SExposedVideoData.h" -#include "IContextManager.h" - -namespace irr -{ -namespace video -{ - // EAGL manager. - class CEAGLManager : public IContextManager - { - public: - //! Constructor. - CEAGLManager(); - - //! Destructor. - virtual ~CEAGLManager(); - - // Initialize EAGL. - /* This method checks if a view has CAEAGLLayer and grabs it if it does, anyway surface and context - aren't create. */ - bool initialize(const SIrrlichtCreationParameters& params, const SExposedVideoData& data); - - // Terminate EAGL. - /* Terminate EAGL context. This method break both existed surface and context. */ - void terminate(); - - // Create EAGL surface. - /* This method configure CAEAGLLayer. */ - bool generateSurface(); - - // Destroy EAGL surface. - /* This method reset CAEAGLLayer states. */ - void destroySurface(); - - // Create EAGL context. - /* This method create and activate EAGL context. */ - bool generateContext(); - - // Destroy EAGL context. - /* This method destroy EAGL context. */ - void destroyContext(); - - const SExposedVideoData& getContext() const; - - bool activateContext(const SExposedVideoData& videoData); - - // Swap buffers. - bool swapBuffers(); - - private: - SIrrlichtCreationParameters Params; - SExposedVideoData Data; - - bool Configured; - - void* DataStorage; - - struct SFrameBuffer - { - SFrameBuffer() : BufferID(0), ColorBuffer(0), DepthBuffer(0) - { - } - - u32 BufferID; - u32 ColorBuffer; - u32 DepthBuffer; - }; - - SFrameBuffer FrameBuffer; - }; -} -} - -#endif diff --git a/lib/irrlicht/source/Irrlicht/CEAGLManager.mm b/lib/irrlicht/source/Irrlicht/CEAGLManager.mm deleted file mode 100644 index d209f2cd4..000000000 --- a/lib/irrlicht/source/Irrlicht/CEAGLManager.mm +++ /dev/null @@ -1,270 +0,0 @@ -// Copyright (C) 2015 Patryk Nadrowski -// This file is part of the "Irrlicht Engine". -// For conditions of distribution and use, see copyright notice in Irrlicht.h - -#include "CEAGLManager.h" - -#include "irrString.h" -#include "os.h" - -#import -#import - -#import -#import -#import -#import - -namespace irr -{ -namespace video -{ - -struct SEAGLManagerDataStorage -{ - SEAGLManagerDataStorage() : Layer(0), Context(0) - { - } - - CAEAGLLayer* Layer; - EAGLContext* Context; -}; - -CEAGLManager::CEAGLManager() : IContextManager(), Configured(false), DataStorage(0) -{ -#ifdef _DEBUG - setDebugName("CEAGLManager"); -#endif - - DataStorage = new SEAGLManagerDataStorage(); -} - -CEAGLManager::~CEAGLManager() -{ - destroyContext(); - destroySurface(); - terminate(); - - delete static_cast(DataStorage); -} - -bool CEAGLManager::initialize(const SIrrlichtCreationParameters& params, const SExposedVideoData& data) -{ - SEAGLManagerDataStorage* dataStorage = static_cast(DataStorage); - - if (dataStorage->Layer != nil) - return true; - - Params = params; - Data = data; - - UIView* view = (__bridge UIView*)data.OpenGLiOS.View; - - if (view == nil || ![[view layer] isKindOfClass:[CAEAGLLayer class]]) - { - os::Printer::log("Could not get EAGL display."); - return false; - } - - dataStorage->Layer = (CAEAGLLayer*)[view layer]; - dataStorage->Layer.contentsScale = view.contentScaleFactor; - - return true; -} - -void CEAGLManager::terminate() -{ - SEAGLManagerDataStorage* dataStorage = static_cast(DataStorage); - - [EAGLContext setCurrentContext:0]; - - destroySurface(); - - if (dataStorage->Layer != nil) - dataStorage->Layer = 0; -} - -bool CEAGLManager::generateSurface() -{ - SEAGLManagerDataStorage* dataStorage = static_cast(DataStorage); - CAEAGLLayer* layer = dataStorage->Layer; - - if (layer == nil) - return false; - - if (Configured) - return true; - - NSDictionary* attribs = [NSDictionary dictionaryWithObjectsAndKeys: - [NSNumber numberWithBool:NO], - kEAGLDrawablePropertyRetainedBacking, - (Params.Bits > 16) ? kEAGLColorFormatRGBA8 : kEAGLColorFormatRGB565, - kEAGLDrawablePropertyColorFormat, - nil]; - - [layer setOpaque:(Params.WithAlphaChannel) ? YES : NO]; - [layer setDrawableProperties:attribs]; - - Configured = true; - - return true; -} - -void CEAGLManager::destroySurface() -{ - SEAGLManagerDataStorage* dataStorage = static_cast(DataStorage); - CAEAGLLayer* layer = dataStorage->Layer; - - if (layer == nil) - return; - - [layer setOpaque:NO]; - [layer setDrawableProperties:nil]; - - Configured = false; -} - -bool CEAGLManager::generateContext() -{ - SEAGLManagerDataStorage* dataStorage = static_cast(DataStorage); - - if (dataStorage->Context != nil || !Configured) - return false; - - EAGLRenderingAPI OpenGLESVersion = kEAGLRenderingAPIOpenGLES2; - - switch (Params.DriverType) - { - case EDT_OGLES2: - { - // For IOS we use 64bit only and all 64bit ios devices support GLES3 anyway - if (!Params.ForceLegacyDevice) - OpenGLESVersion = kEAGLRenderingAPIOpenGLES3; - else - OpenGLESVersion = kEAGLRenderingAPIOpenGLES2; - break; - } - default: - break; - } - - dataStorage->Context = [[EAGLContext alloc] initWithAPI:OpenGLESVersion]; - - if (dataStorage->Context == nil) - { - os::Printer::log("Could not create EAGL context.", ELL_ERROR); - return false; - } - - Data.OpenGLiOS.Context = (__bridge void*)dataStorage->Context; - - os::Printer::log("EAGL context created with OpenGLESVersion: ", core::stringc(static_cast(OpenGLESVersion)), ELL_DEBUG); - - return true; -} - -void CEAGLManager::destroyContext() -{ - SEAGLManagerDataStorage* dataStorage = static_cast(DataStorage); - - [dataStorage->Context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:nil]; - - if (FrameBuffer.BufferID != 0) - { - glDeleteFramebuffersOES(1, &FrameBuffer.BufferID); - FrameBuffer.BufferID = 0; - } - - if (FrameBuffer.ColorBuffer != 0) - { - glDeleteRenderbuffersOES(1, &FrameBuffer.ColorBuffer); - FrameBuffer.ColorBuffer = 0; - } - - if (FrameBuffer.DepthBuffer != 0) - { - glDeleteRenderbuffersOES(1, &FrameBuffer.DepthBuffer); - FrameBuffer.DepthBuffer = 0; - } - - [EAGLContext setCurrentContext:0]; - - if (dataStorage->Context != nil) - dataStorage->Context = 0; - - Data.OpenGLiOS.Context = 0; -} - -bool CEAGLManager::activateContext(const SExposedVideoData& videoData) -{ - SEAGLManagerDataStorage* dataStorage = static_cast(DataStorage); - EAGLContext* context = dataStorage->Context; - - bool status = false; - - if (context != nil) - { - status = ([EAGLContext currentContext] == context || [EAGLContext setCurrentContext:context]); - } - - if (status) - { - if (FrameBuffer.ColorBuffer == 0) - { - glGenRenderbuffersOES(1, &FrameBuffer.ColorBuffer); - glBindRenderbufferOES(GL_RENDERBUFFER_OES, FrameBuffer.ColorBuffer); - [context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:dataStorage->Layer]; - } - - if (FrameBuffer.DepthBuffer == 0) - { - GLenum depth = (Params.ZBufferBits >= 24) ? GL_DEPTH_COMPONENT24_OES : GL_DEPTH_COMPONENT16_OES; - - glGenRenderbuffersOES(1, &FrameBuffer.DepthBuffer); - glBindRenderbufferOES(GL_RENDERBUFFER_OES, FrameBuffer.DepthBuffer); - glRenderbufferStorageOES(GL_RENDERBUFFER_OES, depth, Params.WindowSize.Width, Params.WindowSize.Height); - } - - if (FrameBuffer.BufferID == 0) - { - glGenFramebuffersOES(1, &FrameBuffer.BufferID); - glBindFramebufferOES(GL_FRAMEBUFFER_OES, FrameBuffer.BufferID); - glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, FrameBuffer.ColorBuffer); - glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, FrameBuffer.DepthBuffer); - } - - glBindFramebufferOES(GL_FRAMEBUFFER_OES, FrameBuffer.BufferID); - } - else - { - os::Printer::log("Could not make EGL context current."); - } - - return status; -} - -const SExposedVideoData& CEAGLManager::getContext() const -{ - return Data; -} - -bool CEAGLManager::swapBuffers() -{ - SEAGLManagerDataStorage* dataStorage = static_cast(DataStorage); - EAGLContext* context = dataStorage->Context; - - bool status = false; - - if (context != nil && context == [EAGLContext currentContext]) - { - glBindRenderbufferOES(GL_RENDERBUFFER_OES, FrameBuffer.ColorBuffer); - [context presentRenderbuffer:GL_RENDERBUFFER_OES]; - - status = true; - } - - return status; -} - -} -} diff --git a/lib/irrlicht/source/Irrlicht/CIrrDeviceiOS.h b/lib/irrlicht/source/Irrlicht/CIrrDeviceiOS.h index 62cc2b5c0..1b76b8807 100644 --- a/lib/irrlicht/source/Irrlicht/CIrrDeviceiOS.h +++ b/lib/irrlicht/source/Irrlicht/CIrrDeviceiOS.h @@ -17,14 +17,12 @@ namespace irr { - namespace video - { - class IContextManager; - } class CIrrDeviceiOS : public CIrrDeviceStub, public video::IImagePresenter { public: CIrrDeviceiOS(const SIrrlichtCreationParameters& params); + void swapBuffers(); + void beginScene(); virtual ~CIrrDeviceiOS(); virtual bool run(); @@ -81,8 +79,6 @@ namespace irr void createWindow(); void createViewAndDriver(); - video::IContextManager* ContextManager; - void* DataStorage; bool Close; diff --git a/lib/irrlicht/source/Irrlicht/CIrrDeviceiOS.mm b/lib/irrlicht/source/Irrlicht/CIrrDeviceiOS.mm index 2b4964b98..7bc6a3c0c 100644 --- a/lib/irrlicht/source/Irrlicht/CIrrDeviceiOS.mm +++ b/lib/irrlicht/source/Irrlicht/CIrrDeviceiOS.mm @@ -10,12 +10,11 @@ #include "IFileSystem.h" #include "CTimer.h" -#include "CEAGLManager.h" #include "COGLES2Driver.h" #include "MobileCursorControl.h" -#import #import +#import /* Important information */ @@ -170,10 +169,9 @@ namespace irr /* CIrrViewiOS */ -@interface CIrrViewiOS : UIView +@interface CIrrViewiOS : GLKView -- (id)initWithFrame:(CGRect)frame forDevice:(irr::CIrrDeviceiOS*)device; -@property (nonatomic) float Scale; +- (id)initWithFrame:(CGRect)frame forDevice:(irr::CIrrDeviceiOS*)device forContext:(EAGLContext*)eagl_context; @end @@ -182,12 +180,13 @@ namespace irr irr::CIrrDeviceiOS* Device; } -- (id)initWithFrame:(CGRect)frame forDevice:(irr::CIrrDeviceiOS*)device; +- (id)initWithFrame:(CGRect)frame forDevice:(irr::CIrrDeviceiOS*)device forContext:(EAGLContext*)eagl_context { - self = [super initWithFrame:frame]; - self.Scale = 1.0f; + self = [super initWithFrame:(frame) context:(eagl_context)]; if (self) { + self.drawableDepthFormat = GLKViewDrawableDepthFormat24; + self.drawableStencilFormat = GLKViewDrawableStencilFormat8; Device = device; } @@ -215,8 +214,8 @@ namespace irr CGPoint touchPoint = [touch locationInView:self]; - ev.TouchInput.X = touchPoint.x * self.Scale; - ev.TouchInput.Y = touchPoint.y * self.Scale; + ev.TouchInput.X = touchPoint.x * self.contentScaleFactor; + ev.TouchInput.Y = touchPoint.y * self.contentScaleFactor; Device->postEventFromUser(ev); if (ev.TouchInput.ID == 0) @@ -246,8 +245,8 @@ namespace irr CGPoint touchPoint = [touch locationInView:self]; - ev.TouchInput.X = touchPoint.x * self.Scale; - ev.TouchInput.Y = touchPoint.y * self.Scale; + ev.TouchInput.X = touchPoint.x * self.contentScaleFactor; + ev.TouchInput.Y = touchPoint.y * self.contentScaleFactor; Device->postEventFromUser(ev); if (ev.TouchInput.ID == 0) @@ -277,8 +276,8 @@ namespace irr CGPoint touchPoint = [touch locationInView:self]; - ev.TouchInput.X = touchPoint.x * self.Scale; - ev.TouchInput.Y = touchPoint.y * self.Scale; + ev.TouchInput.X = touchPoint.x * self.contentScaleFactor; + ev.TouchInput.Y = touchPoint.y * self.contentScaleFactor; Device->postEventFromUser(ev); if (ev.TouchInput.ID == 0) @@ -308,8 +307,8 @@ namespace irr CGPoint touchPoint = [touch locationInView:self]; - ev.TouchInput.X = touchPoint.x * self.Scale; - ev.TouchInput.Y = touchPoint.y * self.Scale; + ev.TouchInput.X = touchPoint.x * self.contentScaleFactor; + ev.TouchInput.Y = touchPoint.y * self.contentScaleFactor; Device->postEventFromUser(ev); if (ev.TouchInput.ID == 0) @@ -325,20 +324,7 @@ namespace irr @end -/* CIrrViewEAGLiOS */ -@interface CIrrViewEAGLiOS : CIrrViewiOS - -@end - -@implementation CIrrViewEAGLiOS - -+ (Class)layerClass -{ - return [CAEAGLLayer class]; -} - -@end namespace irr { @@ -347,16 +333,26 @@ namespace irr SIrrDeviceiOSDataStorage() : Window(0), ViewController(0), View(0), MotionManager(0), ReferenceAttitude(0) { MotionManager = [[CMMotionManager alloc] init]; + m_eagl_context = 0; + } + ~SIrrDeviceiOSDataStorage() + { + [Window release]; + [ViewController release]; + [View release]; + [MotionManager release]; + [EAGLContext setCurrentContext:0]; + [m_eagl_context release]; } - UIWindow* Window; UIViewController* ViewController; CIrrViewiOS* View; CMMotionManager* MotionManager; CMAttitude* ReferenceAttitude; + EAGLContext* m_eagl_context; }; - CIrrDeviceiOS::CIrrDeviceiOS(const SIrrlichtCreationParameters& params) : CIrrDeviceStub(params), ContextManager(0), DataStorage(0), Close(false) + CIrrDeviceiOS::CIrrDeviceiOS(const SIrrlichtCreationParameters& params) : CIrrDeviceStub(params), DataStorage(0), Close(false) { #ifdef _DEBUG setDebugName("CIrrDeviceiOS"); @@ -393,8 +389,6 @@ namespace irr CIrrDelegateiOS* delegate = [UIApplication sharedApplication].delegate; [delegate setDevice:nil]; #endif - if (ContextManager) - ContextManager->drop(); } bool CIrrDeviceiOS::run() @@ -736,45 +730,10 @@ namespace irr if (CreationParams.DriverType != video::EDT_NULL) { SIrrDeviceiOSDataStorage* dataStorage = static_cast(DataStorage); - - UIView* externalView = (__bridge UIView*)CreationParams.WindowId; - - if (externalView == nil) - { - dataStorage->Window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; - dataStorage->ViewController = [[UIViewController alloc] init]; - dataStorage->Window.rootViewController = dataStorage->ViewController; - - [dataStorage->Window makeKeyAndVisible]; - } - else - { - dataStorage->Window = externalView.window; - - UIResponder* currentResponder = externalView.nextResponder; - - do - { - if ([currentResponder isKindOfClass:[UIViewController class]]) - { - dataStorage->ViewController = (UIViewController*)currentResponder; - - currentResponder = nil; - } - else if ([currentResponder isKindOfClass:[UIView class]]) - { - currentResponder = currentResponder.nextResponder; - } - else - { - currentResponder = nil; - - // Could not find view controller. - _IRR_DEBUG_BREAK_IF(true); - } - } - while (currentResponder != nil); - } + dataStorage->Window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; + dataStorage->ViewController = [[UIViewController alloc] init]; + dataStorage->Window.rootViewController = dataStorage->ViewController; + [dataStorage->Window makeKeyAndVisible]; } } @@ -782,34 +741,36 @@ namespace irr { SIrrDeviceiOSDataStorage* dataStorage = static_cast(DataStorage); - video::SExposedVideoData data; - data.OpenGLiOS.Window = (__bridge void*)dataStorage->Window; - data.OpenGLiOS.ViewController = (__bridge void*)dataStorage->ViewController; - - UIView* externalView = (__bridge UIView*)CreationParams.WindowId; - - CGRect resolution = (externalView == nil) ? [[UIScreen mainScreen] bounds] : externalView.bounds; - switch (CreationParams.DriverType) { case video::EDT_OGLES2: #ifdef _IRR_COMPILE_WITH_OGLES2_ { - CIrrViewEAGLiOS* view = [[CIrrViewEAGLiOS alloc] initWithFrame:resolution forDevice:this]; + EAGLRenderingAPI OpenGLESVersion = kEAGLRenderingAPIOpenGLES2; + // For IOS we use 64bit only and all 64bit ios devices support GLES3 anyway + if (!CreationParams.ForceLegacyDevice) + OpenGLESVersion = kEAGLRenderingAPIOpenGLES3; + else + OpenGLESVersion = kEAGLRenderingAPIOpenGLES2; + dataStorage->m_eagl_context = [[EAGLContext alloc] initWithAPI:OpenGLESVersion]; + [EAGLContext setCurrentContext:dataStorage->m_eagl_context]; + + CIrrViewiOS* view = [[CIrrViewiOS alloc] initWithFrame:[[UIScreen mainScreen] bounds] + forDevice:this forContext:dataStorage->m_eagl_context]; + dataStorage->View = view; view.contentScaleFactor = dataStorage->Window.screen.nativeScale; - view.Scale = view.contentScaleFactor; + // This will initialize the default framebuffer, which bind its valus to GL_FRAMEBUFFER_BINDING + beginScene(); + GLint default_fb = 0; + glGetIntegerv(GL_FRAMEBUFFER_BINDING, &default_fb); + CreationParams.WindowSize = { - view.frame.size.width * view.contentScaleFactor, - view.frame.size.height * view.contentScaleFactor + (u32)view.drawableWidth, + (u32)view.drawableHeight }; - dataStorage->View = view; - data.OpenGLiOS.View = (__bridge void*)view; - - ContextManager = new irr::video::CEAGLManager(); - ContextManager->initialize(CreationParams, data); - - VideoDriver = new video::COGLES2Driver(CreationParams, FileSystem, this, ContextManager); + [dataStorage->Window addSubview:view]; + VideoDriver = new video::COGLES2Driver(CreationParams, FileSystem, this, default_fb); if (!VideoDriver) os::Printer::log("Could not create OpenGL ES 2.x driver.", ELL_ERROR); @@ -835,10 +796,15 @@ namespace irr break; } - if (externalView == nil) - dataStorage->ViewController.view = dataStorage->View; - else - [externalView addSubview:dataStorage->View]; + dataStorage->ViewController.view = dataStorage->View; + } + void CIrrDeviceiOS::beginScene() + { + [static_cast(DataStorage)->View bindDrawable]; + } + void CIrrDeviceiOS::swapBuffers() + { + [static_cast(DataStorage)->View display]; } } diff --git a/lib/irrlicht/source/Irrlicht/COGLES2Driver.cpp b/lib/irrlicht/source/Irrlicht/COGLES2Driver.cpp index f96ae2f5e..a67ebf35b 100644 --- a/lib/irrlicht/source/Irrlicht/COGLES2Driver.cpp +++ b/lib/irrlicht/source/Irrlicht/COGLES2Driver.cpp @@ -8,7 +8,6 @@ #include "COGLES2Driver.h" // needed here also because of the create methods' parameters #include "CNullDriver.h" -#include "IContextManager.h" #ifdef _IRR_COMPILE_WITH_OGLES2_ @@ -43,19 +42,13 @@ namespace video //! constructor and init code #ifdef _IRR_COMPILE_WITH_IOS_DEVICE_ COGLES2Driver::COGLES2Driver(const SIrrlichtCreationParameters& params, - io::IFileSystem* io, IrrlichtDevice* device, IContextManager* context) + io::IFileSystem* io, IrrlichtDevice* device, u32 default_fb) : 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), Params(params) + ColorFormat(ECF_R8G8B8), Params(params), m_default_fb(default_fb) { - m_eagl_context = context; - m_eagl_context->grab(); - m_eagl_context->generateSurface(); - m_eagl_context->generateContext(); - ExposedData = m_eagl_context->getContext(); - m_eagl_context->activateContext(ExposedData); m_device = device; genericDriverInit(params.WindowSize, params.Stencilbuffer); } @@ -161,13 +154,6 @@ namespace video ReleaseDC((ExposedData.OpenGLWin32.HWnd, HDc); #endif -#endif - -#if defined(_IRR_COMPILE_WITH_IOS_DEVICE_) - m_eagl_context->destroyContext(); - m_eagl_context->destroySurface(); - m_eagl_context->terminate(); - m_eagl_context->drop(); #endif } @@ -484,7 +470,7 @@ namespace video return false; } #elif defined(_IRR_COMPILE_WITH_IOS_DEVICE_) - m_eagl_context->swapBuffers(); + static_cast(m_device)->swapBuffers(); #endif return true; @@ -497,7 +483,7 @@ namespace video { CNullDriver::beginScene(backBuffer, zBuffer, color); #if defined(_IRR_COMPILE_WITH_IOS_DEVICE_) - m_eagl_context->activateContext(videoData); + static_cast(m_device)->beginScene(); #endif GLbitfield mask = 0; diff --git a/lib/irrlicht/source/Irrlicht/COGLES2Driver.h b/lib/irrlicht/source/Irrlicht/COGLES2Driver.h index c16555d89..acd855989 100644 --- a/lib/irrlicht/source/Irrlicht/COGLES2Driver.h +++ b/lib/irrlicht/source/Irrlicht/COGLES2Driver.h @@ -76,8 +76,9 @@ namespace video #endif #if defined(_IRR_COMPILE_WITH_IOS_DEVICE_) - COGLES2Driver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, - IrrlichtDevice* device, IContextManager* context); + COGLES2Driver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, + IrrlichtDevice* device, u32 default_fb); + virtual u32 getDefaultFramebuffer() const { return m_default_fb; } #endif //! destructor @@ -473,7 +474,7 @@ namespace video bool EglContextExternal; #endif #if defined(_IRR_COMPILE_WITH_IOS_DEVICE_) - IContextManager* m_eagl_context; + u32 m_default_fb; #endif #ifdef _IRR_COMPILE_WITH_WINDOWS_DEVICE_ HDC HDc;