GLKView怎么不让controller自动调用DrawRect啊

heyyg 2016-04-07 04:36:21
代码如下 :
- (void)viewDidLoad {
[super viewDidLoad];

context = [self CreateBestEAGLContext];
if (!context) {
NSLog(@"Failed to create ES context");
}
GLKView *view = (GLKView *)self.view;
view.context = context;
view.drawableDepthFormat = GLKViewDrawableDepthFormat24;
view.drawableStencilFormat = GLKViewDrawableStencilFormat8;
view.enableSetNeedsDisplay = NO;
[EAGLContext setCurrentContext:context];
int w = view.frame.size.width;
int h = view.frame.size.height;
}

-(void)glkView:(GLKView *)view drawInRect:(CGRect)rect
{
// glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //清除surface内容,恢复至初始状态。
NSLog(@"drawBegin");
// renderFrame();
glDraw(token, true);
NSLog(@"drawEnd");
}

drawInRect会不停的调用,我想我需要的时候 调用display来显示。
...全文
269 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
ssssssssssssaaaaa 2017-09-26
  • 打赏
  • 举报
回复
将enableSetNeedsDisplay设置为false,来关闭GLKView的这一缺省行为。之后可以调用GLKView的display方法来控制什么时候重新绘制。

29,027

社区成员

发帖
与我相关
我的任务
社区描述
主要讨论与iOS相关的软件和技术
社区管理员
  • iOS
  • 大熊猫侯佩
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧