iOS OpenGL 函数renderbufferStorage:fromDrawable:

来源:互联网 发布:软件安全性测试工具 编辑:程序博客网 时间:2024/05/16 10:49
Create a color renderbuffer. Allocate its storage by calling the context’srenderbufferStorage:fromDrawable: method, passing the layer object as the parameter. The width,height and pixel format are taken from the layer and used to allocate storage for the renderbuffer.
page32image11544
myEAGLLayer = (CAEAGLLayer*)self.layer;
page32image14088

GLuint colorRenderbuffer;


glGenRenderbuffers(1, &colorRenderbuffer);glBindRenderbuffer(GL_RENDERBUFFER, colorRenderbuffer);


[myContext renderbufferStorage:GL_RENDERBUFFER fromDrawable:myEAGLLayer];


glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,GL_RENDERBUFFER, colorRenderbuffer);
page32image17264

NoteWhentheCoreAnimationlayer’sboundsorpropertieschange,yourapplicationshouldreallocate the renderbuffer’s storage. If you do not reallocate the renderbuffers, the renderbuffersize won’t match the size of the view; in this case, Core Animation may scale the image’s contentsto fit in the view. To prevent this, the Xcode template reallocates the framebuffer and renderbufferwhenever the view layout changes.