我一直试图弄清楚如何在eaglview上调整绘图视图的大小,而不是默认的320x480尺寸。我的Eaglview附加到UIViewController。我真正想要做的是找出viewrenderbuffer从中调用宽度和高度参数的位置。
在下面的代码中,我可以看到支持的宽度和高度是从绑定的viewRenderbuffer和renderbufferstorage调用中获取的。我不想使用屏幕默认的320x480,因为如果我在纵向视图上显示风景照片,它将被拉伸,反之亦然。
- (void)reshapeFramebuffer
{
glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
[context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(CAEAGLLayer*)self.layer];
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth);
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight);
// This application only needs color. If depth and/or stencil are needed, ensure they are also resized here.
//Debug.h
rt_assert(GL_FRAMEBUFFER_COMPLETE_OES == glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES));
glCheckError();
}
答案 0 :(得分:1)
在上下文上调用renderbufferStorage:fromDrawable
会在Core Animation层上分配存储空间。随后的两个电话
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth);
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight);
然后获取在上下文中调用renderbufferStorage:fromDrawable
时设置的渲染缓冲区的高度和宽度。
如果要为UIView容器使用不同的大小,则应设置该容器。据推测,您的EAGLView实例有一些用于调整子视图大小的设置,例如: - (void)layoutSubviews
...