mirror of
https://github.com/minetest/irrlicht.git
synced 2024-11-18 13:43:48 +01:00
Add missing parameters in CEAGLManager::activateContext.
Thanks to Maksym Hamarnyk for the patch. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/branches/ogl-es@6118 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
parent
562c0fb6f1
commit
87c0b1fb93
@ -54,7 +54,7 @@ namespace video
|
|||||||
|
|
||||||
const SExposedVideoData& getContext() const;
|
const SExposedVideoData& getContext() const;
|
||||||
|
|
||||||
bool activateContext(const SExposedVideoData& videoData);
|
bool activateContext(const SExposedVideoData& videoData, bool restorePrimaryOnZero);
|
||||||
|
|
||||||
// Swap buffers.
|
// Swap buffers.
|
||||||
bool swapBuffers();
|
bool swapBuffers();
|
||||||
@ -62,22 +62,22 @@ namespace video
|
|||||||
private:
|
private:
|
||||||
SIrrlichtCreationParameters Params;
|
SIrrlichtCreationParameters Params;
|
||||||
SExposedVideoData Data;
|
SExposedVideoData Data;
|
||||||
|
|
||||||
bool Configured;
|
bool Configured;
|
||||||
|
|
||||||
void* DataStorage;
|
void* DataStorage;
|
||||||
|
|
||||||
struct SFrameBuffer
|
struct SFrameBuffer
|
||||||
{
|
{
|
||||||
SFrameBuffer() : BufferID(0), ColorBuffer(0), DepthBuffer(0)
|
SFrameBuffer() : BufferID(0), ColorBuffer(0), DepthBuffer(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 BufferID;
|
u32 BufferID;
|
||||||
u32 ColorBuffer;
|
u32 ColorBuffer;
|
||||||
u32 DepthBuffer;
|
u32 DepthBuffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
SFrameBuffer FrameBuffer;
|
SFrameBuffer FrameBuffer;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ namespace irr
|
|||||||
{
|
{
|
||||||
namespace video
|
namespace video
|
||||||
{
|
{
|
||||||
|
|
||||||
struct SEAGLManagerDataStorage
|
struct SEAGLManagerDataStorage
|
||||||
{
|
{
|
||||||
SEAGLManagerDataStorage() : Layer(0), Context(0)
|
SEAGLManagerDataStorage() : Layer(0), Context(0)
|
||||||
@ -40,7 +40,7 @@ CEAGLManager::CEAGLManager() : IContextManager(), Configured(false), DataStorage
|
|||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
setDebugName("CEAGLManager");
|
setDebugName("CEAGLManager");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DataStorage = new SEAGLManagerDataStorage();
|
DataStorage = new SEAGLManagerDataStorage();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ CEAGLManager::~CEAGLManager()
|
|||||||
destroyContext();
|
destroyContext();
|
||||||
destroySurface();
|
destroySurface();
|
||||||
terminate();
|
terminate();
|
||||||
|
|
||||||
delete static_cast<SEAGLManagerDataStorage*>(DataStorage);
|
delete static_cast<SEAGLManagerDataStorage*>(DataStorage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ bool CEAGLManager::initialize(const SIrrlichtCreationParameters& params, const S
|
|||||||
|
|
||||||
Params = params;
|
Params = params;
|
||||||
Data = data;
|
Data = data;
|
||||||
|
|
||||||
UIView* view = (__bridge UIView*)data.OpenGLiOS.View;
|
UIView* view = (__bridge UIView*)data.OpenGLiOS.View;
|
||||||
|
|
||||||
if (view == nil || ![[view layer] isKindOfClass:[CAEAGLLayer class]])
|
if (view == nil || ![[view layer] isKindOfClass:[CAEAGLLayer class]])
|
||||||
@ -70,7 +70,7 @@ bool CEAGLManager::initialize(const SIrrlichtCreationParameters& params, const S
|
|||||||
os::Printer::log("Could not get EAGL display.");
|
os::Printer::log("Could not get EAGL display.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
dataStorage->Layer = (CAEAGLLayer*)[view layer];
|
dataStorage->Layer = (CAEAGLLayer*)[view layer];
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -79,11 +79,11 @@ bool CEAGLManager::initialize(const SIrrlichtCreationParameters& params, const S
|
|||||||
void CEAGLManager::terminate()
|
void CEAGLManager::terminate()
|
||||||
{
|
{
|
||||||
SEAGLManagerDataStorage* dataStorage = static_cast<SEAGLManagerDataStorage*>(DataStorage);
|
SEAGLManagerDataStorage* dataStorage = static_cast<SEAGLManagerDataStorage*>(DataStorage);
|
||||||
|
|
||||||
[EAGLContext setCurrentContext:0];
|
[EAGLContext setCurrentContext:0];
|
||||||
|
|
||||||
destroySurface();
|
destroySurface();
|
||||||
|
|
||||||
if (dataStorage->Layer != nil)
|
if (dataStorage->Layer != nil)
|
||||||
dataStorage->Layer = 0;
|
dataStorage->Layer = 0;
|
||||||
}
|
}
|
||||||
@ -92,13 +92,13 @@ bool CEAGLManager::generateSurface()
|
|||||||
{
|
{
|
||||||
SEAGLManagerDataStorage* dataStorage = static_cast<SEAGLManagerDataStorage*>(DataStorage);
|
SEAGLManagerDataStorage* dataStorage = static_cast<SEAGLManagerDataStorage*>(DataStorage);
|
||||||
CAEAGLLayer* layer = dataStorage->Layer;
|
CAEAGLLayer* layer = dataStorage->Layer;
|
||||||
|
|
||||||
if (layer == nil)
|
if (layer == nil)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (Configured)
|
if (Configured)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
NSDictionary* attribs = [NSDictionary dictionaryWithObjectsAndKeys:
|
NSDictionary* attribs = [NSDictionary dictionaryWithObjectsAndKeys:
|
||||||
[NSNumber numberWithBool:NO],
|
[NSNumber numberWithBool:NO],
|
||||||
kEAGLDrawablePropertyRetainedBacking,
|
kEAGLDrawablePropertyRetainedBacking,
|
||||||
@ -108,7 +108,7 @@ bool CEAGLManager::generateSurface()
|
|||||||
|
|
||||||
[layer setOpaque:(Params.WithAlphaChannel) ? YES : NO];
|
[layer setOpaque:(Params.WithAlphaChannel) ? YES : NO];
|
||||||
[layer setDrawableProperties:attribs];
|
[layer setDrawableProperties:attribs];
|
||||||
|
|
||||||
Configured = true;
|
Configured = true;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -118,13 +118,13 @@ void CEAGLManager::destroySurface()
|
|||||||
{
|
{
|
||||||
SEAGLManagerDataStorage* dataStorage = static_cast<SEAGLManagerDataStorage*>(DataStorage);
|
SEAGLManagerDataStorage* dataStorage = static_cast<SEAGLManagerDataStorage*>(DataStorage);
|
||||||
CAEAGLLayer* layer = dataStorage->Layer;
|
CAEAGLLayer* layer = dataStorage->Layer;
|
||||||
|
|
||||||
if (layer == nil)
|
if (layer == nil)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
[layer setOpaque:NO];
|
[layer setOpaque:NO];
|
||||||
[layer setDrawableProperties:nil];
|
[layer setDrawableProperties:nil];
|
||||||
|
|
||||||
Configured = false;
|
Configured = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,7 +156,7 @@ bool CEAGLManager::generateContext()
|
|||||||
os::Printer::log("Could not create EAGL context.", ELL_ERROR);
|
os::Printer::log("Could not create EAGL context.", ELL_ERROR);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Data.OpenGLiOS.Context = (__bridge void*)dataStorage->Context;
|
Data.OpenGLiOS.Context = (__bridge void*)dataStorage->Context;
|
||||||
|
|
||||||
os::Printer::log("EAGL context created with OpenGLESVersion: ", core::stringc(static_cast<int>(OpenGLESVersion)), ELL_DEBUG);
|
os::Printer::log("EAGL context created with OpenGLESVersion: ", core::stringc(static_cast<int>(OpenGLESVersion)), ELL_DEBUG);
|
||||||
@ -167,7 +167,7 @@ bool CEAGLManager::generateContext()
|
|||||||
void CEAGLManager::destroyContext()
|
void CEAGLManager::destroyContext()
|
||||||
{
|
{
|
||||||
SEAGLManagerDataStorage* dataStorage = static_cast<SEAGLManagerDataStorage*>(DataStorage);
|
SEAGLManagerDataStorage* dataStorage = static_cast<SEAGLManagerDataStorage*>(DataStorage);
|
||||||
|
|
||||||
[dataStorage->Context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:nil];
|
[dataStorage->Context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:nil];
|
||||||
|
|
||||||
if (FrameBuffer.BufferID != 0)
|
if (FrameBuffer.BufferID != 0)
|
||||||
@ -175,13 +175,13 @@ void CEAGLManager::destroyContext()
|
|||||||
glDeleteFramebuffersOES(1, &FrameBuffer.BufferID);
|
glDeleteFramebuffersOES(1, &FrameBuffer.BufferID);
|
||||||
FrameBuffer.BufferID = 0;
|
FrameBuffer.BufferID = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FrameBuffer.ColorBuffer != 0)
|
if (FrameBuffer.ColorBuffer != 0)
|
||||||
{
|
{
|
||||||
glDeleteRenderbuffersOES(1, &FrameBuffer.ColorBuffer);
|
glDeleteRenderbuffersOES(1, &FrameBuffer.ColorBuffer);
|
||||||
FrameBuffer.ColorBuffer = 0;
|
FrameBuffer.ColorBuffer = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FrameBuffer.DepthBuffer != 0)
|
if (FrameBuffer.DepthBuffer != 0)
|
||||||
{
|
{
|
||||||
glDeleteRenderbuffersOES(1, &FrameBuffer.DepthBuffer);
|
glDeleteRenderbuffersOES(1, &FrameBuffer.DepthBuffer);
|
||||||
@ -189,25 +189,25 @@ void CEAGLManager::destroyContext()
|
|||||||
}
|
}
|
||||||
|
|
||||||
[EAGLContext setCurrentContext:0];
|
[EAGLContext setCurrentContext:0];
|
||||||
|
|
||||||
if (dataStorage->Context != nil)
|
if (dataStorage->Context != nil)
|
||||||
dataStorage->Context = 0;
|
dataStorage->Context = 0;
|
||||||
|
|
||||||
Data.OpenGLiOS.Context = 0;
|
Data.OpenGLiOS.Context = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CEAGLManager::activateContext(const SExposedVideoData& videoData)
|
bool CEAGLManager::activateContext(const SExposedVideoData& videoData, bool restorePrimaryOnZero)
|
||||||
{
|
{
|
||||||
SEAGLManagerDataStorage* dataStorage = static_cast<SEAGLManagerDataStorage*>(DataStorage);
|
SEAGLManagerDataStorage* dataStorage = static_cast<SEAGLManagerDataStorage*>(DataStorage);
|
||||||
EAGLContext* context = dataStorage->Context;
|
EAGLContext* context = dataStorage->Context;
|
||||||
|
|
||||||
bool status = false;
|
bool status = false;
|
||||||
|
|
||||||
if (context != nil)
|
if (context != nil)
|
||||||
{
|
{
|
||||||
status = ([EAGLContext currentContext] == context || [EAGLContext setCurrentContext:context]);
|
status = ([EAGLContext currentContext] == context || [EAGLContext setCurrentContext:context]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status)
|
if (status)
|
||||||
{
|
{
|
||||||
if (FrameBuffer.ColorBuffer == 0)
|
if (FrameBuffer.ColorBuffer == 0)
|
||||||
@ -216,7 +216,7 @@ bool CEAGLManager::activateContext(const SExposedVideoData& videoData)
|
|||||||
glBindRenderbufferOES(GL_RENDERBUFFER_OES, FrameBuffer.ColorBuffer);
|
glBindRenderbufferOES(GL_RENDERBUFFER_OES, FrameBuffer.ColorBuffer);
|
||||||
[context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:dataStorage->Layer];
|
[context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:dataStorage->Layer];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FrameBuffer.DepthBuffer == 0)
|
if (FrameBuffer.DepthBuffer == 0)
|
||||||
{
|
{
|
||||||
GLenum depth = (Params.ZBufferBits >= 24) ? GL_DEPTH_COMPONENT24_OES : GL_DEPTH_COMPONENT16_OES;
|
GLenum depth = (Params.ZBufferBits >= 24) ? GL_DEPTH_COMPONENT24_OES : GL_DEPTH_COMPONENT16_OES;
|
||||||
@ -225,7 +225,7 @@ bool CEAGLManager::activateContext(const SExposedVideoData& videoData)
|
|||||||
glBindRenderbufferOES(GL_RENDERBUFFER_OES, FrameBuffer.DepthBuffer);
|
glBindRenderbufferOES(GL_RENDERBUFFER_OES, FrameBuffer.DepthBuffer);
|
||||||
glRenderbufferStorageOES(GL_RENDERBUFFER_OES, depth, Params.WindowSize.Width, Params.WindowSize.Height);
|
glRenderbufferStorageOES(GL_RENDERBUFFER_OES, depth, Params.WindowSize.Width, Params.WindowSize.Height);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FrameBuffer.BufferID == 0)
|
if (FrameBuffer.BufferID == 0)
|
||||||
{
|
{
|
||||||
glGenFramebuffersOES(1, &FrameBuffer.BufferID);
|
glGenFramebuffersOES(1, &FrameBuffer.BufferID);
|
||||||
@ -233,7 +233,7 @@ bool CEAGLManager::activateContext(const SExposedVideoData& videoData)
|
|||||||
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, FrameBuffer.ColorBuffer);
|
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);
|
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, FrameBuffer.DepthBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
glBindFramebufferOES(GL_FRAMEBUFFER_OES, FrameBuffer.BufferID);
|
glBindFramebufferOES(GL_FRAMEBUFFER_OES, FrameBuffer.BufferID);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -253,17 +253,17 @@ bool CEAGLManager::swapBuffers()
|
|||||||
{
|
{
|
||||||
SEAGLManagerDataStorage* dataStorage = static_cast<SEAGLManagerDataStorage*>(DataStorage);
|
SEAGLManagerDataStorage* dataStorage = static_cast<SEAGLManagerDataStorage*>(DataStorage);
|
||||||
EAGLContext* context = dataStorage->Context;
|
EAGLContext* context = dataStorage->Context;
|
||||||
|
|
||||||
bool status = false;
|
bool status = false;
|
||||||
|
|
||||||
if (context != nil && context == [EAGLContext currentContext])
|
if (context != nil && context == [EAGLContext currentContext])
|
||||||
{
|
{
|
||||||
glBindRenderbufferOES(GL_RENDERBUFFER_OES, FrameBuffer.ColorBuffer);
|
glBindRenderbufferOES(GL_RENDERBUFFER_OES, FrameBuffer.ColorBuffer);
|
||||||
[context presentRenderbuffer:GL_RENDERBUFFER_OES];
|
[context presentRenderbuffer:GL_RENDERBUFFER_OES];
|
||||||
|
|
||||||
status = true;
|
status = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user