The iOS OpenGL ES context's color Renderbuffer Object is no longer completely destroyed and recreated in layoutSubviews. Its storage is now only reallocated when the actual size of the layer changes. The framebuffer object and renderbuffer object binding states are no longer clobbered by the storage reallocation code in layoutSubviews.
parent
38c6e9d13b
commit
6d85f52228
|
@ -183,15 +183,11 @@
|
||||||
|
|
||||||
- (void)updateFrame
|
- (void)updateFrame
|
||||||
{
|
{
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, viewFramebuffer);
|
GLint prevRenderbuffer = 0;
|
||||||
glBindRenderbuffer(GL_RENDERBUFFER, 0);
|
glGetIntegerv(GL_RENDERBUFFER_BINDING, &prevRenderbuffer);
|
||||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 0);
|
|
||||||
glDeleteRenderbuffers(1, &viewRenderbuffer);
|
|
||||||
|
|
||||||
glGenRenderbuffers(1, &viewRenderbuffer);
|
|
||||||
glBindRenderbuffer(GL_RENDERBUFFER, viewRenderbuffer);
|
glBindRenderbuffer(GL_RENDERBUFFER, viewRenderbuffer);
|
||||||
[context renderbufferStorage:GL_RENDERBUFFER fromDrawable:(CAEAGLLayer*)self.layer];
|
[context renderbufferStorage:GL_RENDERBUFFER fromDrawable:(CAEAGLLayer*)self.layer];
|
||||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, viewRenderbuffer);
|
|
||||||
|
|
||||||
glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, &backingWidth);
|
glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, &backingWidth);
|
||||||
glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT, &backingHeight);
|
glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT, &backingHeight);
|
||||||
|
@ -201,9 +197,7 @@
|
||||||
glRenderbufferStorage(GL_RENDERBUFFER, depthBufferFormat, backingWidth, backingHeight);
|
glRenderbufferStorage(GL_RENDERBUFFER, depthBufferFormat, backingWidth, backingHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
glBindRenderbuffer(GL_RENDERBUFFER, viewRenderbuffer);
|
glBindRenderbuffer(GL_RENDERBUFFER, prevRenderbuffer);
|
||||||
|
|
||||||
[self setDebugLabels];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setDebugLabels
|
- (void)setDebugLabels
|
||||||
|
@ -278,8 +272,15 @@
|
||||||
{
|
{
|
||||||
[super layoutSubviews];
|
[super layoutSubviews];
|
||||||
|
|
||||||
|
CGSize layersize = self.layer.bounds.size;
|
||||||
|
int width = (int) (layersize.width * self.layer.contentsScale);
|
||||||
|
int height = (int) (layersize.height * self.layer.contentsScale);
|
||||||
|
|
||||||
|
/* Update the color and depth buffer storage if the layer size has changed. */
|
||||||
|
if (width != backingWidth || height != backingHeight) {
|
||||||
[EAGLContext setCurrentContext:context];
|
[EAGLContext setCurrentContext:context];
|
||||||
[self updateFrame];
|
[self updateFrame];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)destroyFramebuffer
|
- (void)destroyFramebuffer
|
||||||
|
|
Loading…
Reference in New Issue