简体   繁体   English

iPhone / iPad,OpenGL ES,CADisplayLink

[英]iPhone/iPad, OpenGL ES, CADisplayLink

I've just started playing with OpenGL ES, mostly on iPad and have noticed some problems I cannot find the answer to. 我刚刚开始在大多数iPad上使用OpenGL ES,并且发现了一些我找不到答案的问题。 First I've tried using two EAGLViews using separate renderers in the same window. 首先,我尝试在同一窗口中使用两个EAGLView,并使用单独的渲染器。 Basically think the OpenGL ES example project in XCode but with two EAGLViews and two renderers etc. Now this does not seem to work in the simulator, it only shows one of the views (it seems to run the rendering code, but only one view is displayed with openGL) but when run on the device (an iPad using iOS 4.2) it does work, at least kind of which leads to the next question. 基本上认为XCode中的OpenGL ES示例项目带有两个EAGLViews和两个渲染器等。现在这在模拟器中似乎不起作用,它仅显示其中一个视图(它似乎在运行渲染代码,但只有一个视图是使用openGL显示),但是在设备上运行(使用iOS 4.2的iPad)时,它确实可以正常工作,至少在某种程度上导致了下一个问题。

The updates to the rendering is triggered using CADisplayLink on both these views. 使用这两个视图上的CADisplayLink触发对渲染的更新。 This does however cause some problems. 但是,这确实会引起一些问题。 Most of the time, after just a short while, the updates on one of the views stops, its CADisplayLink stops triggering. 大多数情况下,不久之后,其中一个视图的更新就会停止,其CADisplayLink会停止触发。 This only happens on the device and not in simulator. 这只会在设备上发生,而不会在模拟器中发生。 It can be "fixed" by using timers instead of CADisplayLink, or timer on one view and DisplayLink on the other, I would like to know what is causing this though. 可以通过使用计时器而不是CADisplayLink来“固定”它,或者在一个视图上使用计时器,而在另一个视图上使用DisplayLink,我想知道是什么原因造成的。 I'm creating the display link like this (in both views): 我正在这样创建显示链接(在两个视图中):

self.displayLink = [NSClassFromString(@"CADisplayLink") displayLinkWithTarget:self selector:@selector(drawView:)];

[displayLink setFrameInterval:animationFrameInterval];

[displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];

Now the last question is about an odd thing I have noticed. 现在,最后一个问题是关于我注意到的一件奇怪的事情。 When running the OpenGL ES example project provided in Xcode in the iPad simulator with the view resized below 760 in width, it does not render anything to screen, It only concerns the width though, the height can be resized in any way. 当运行iPad模拟器中Xcode中提供的OpenGL ES示例项目时,视图的宽度调整为小于760的宽度时,它不会在屏幕上呈现任何内容,尽管它仅涉及宽度,但是可以通过任何方式调整高度。 It only happens in the simulator, not on the device. 它仅在模拟器中发生,而不在设备上发生。

So the questions are basically if the things mentioned above are bugs, features or if I'm just doing it wrong? 所以问题基本上是上面提到的东西是错误,功能还是我做错了?

Thanks /j0h 谢谢/ j0h

I found a similar problem running two OpenGL views at once, each running on a separate CADisplayLink, both running forMode: NSDefaultRunLoopMode. 我发现一次运行两个OpenGL视图的类似问题,每个视图在单独的CADisplayLink上运行,两个视图都运行forMode:NSDefaultRunLoopMode。 When testing on an iPhone 4S running iOS 5.1, there were no issues except for when exiting the MPMediaPickerController, one of the views would stop rendering. 在运行iOS 5.1的iPhone 4S上进行测试时,除了退出MPMediaPickerController之外,没有任何问题,其中一个视图将停止渲染。 However, on the iPod Touch 3rd gen running iOS 5.0.1, I did notice the issue where one or the other view would stop rendering randomly (due to CADisplayLink not firing). 但是,在运行iOS 5.0.1的iPod Touch第三代上,我确实注意到了一个视图或另一个视图将停止随机渲染(由于CADisplayLink无法触发)的问题。 I was able to fix it by switching to NSTimer for both views (just doing it for one or the other wouldn't work). 我可以通过切换到两个视图的NSTimer来解决此问题(仅对一个视图或另一个视图不起作用)。 Sizing to multiples of 32 did not make any difference for me. 调整为32的倍数对我没有任何影响。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM