开发者

Trying to Resize Eaglview Displayed Image Dependent on Landscape or Portrait Photo

I've been trying to figure out how to resize the drawing view on eaglview as opposed to the default 320x480 dimension. My Eaglview is attached to a UIViewController. What I really want to do is find out where viewrenderbuffer is calling its width and height parameters from.

In the code below I can see that the backing width and height are being taken from the binded viewRenderbuffer开发者_如何学运维 and through the renderbufferstorage call. I don't want to use the screen default 320x480 though because if I display a landscape photo on portrait view it will be stretched out and vice versa.

- (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();

}


Calling renderbufferStorage:fromDrawable on the context allocates storage on the Core Animation layer. The two subsequent calls

glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth);
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight);

then obtains the height and width of the renderbuffer which was set when calling renderbufferStorage:fromDrawable on the context.

If you want to use a different size for the UIView container, you should set that. Presumably your EAGLView instance has some provision for resizing subviews, e.g. - (void)layoutSubviews...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜