0

I've just started playing with OpenGL ES, mostly on iPad and have noticed some problems I cannot find the answer to. First I've tried using two EAGLViews using separate renderers in the same window. 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.

The updates to the rendering is triggered using CADisplayLink on both these views. 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. 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. 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. 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
  • 1
  • 1
  • For the Simulator, does one of the views have dimensions that are not multiples of 32? If so, you may be hitting this issue: http://stackoverflow.com/questions/4430288/why-cant-i-see-certain-opengl-es-charts-in-the-4-2-simulator/4430726#4430726 , which would cause the OpenGL content not to be rendered. – Brad Larson Jan 11 '11 at 15:21
  • Why do you need to have two OpenGL ES layers? Your performance may suffer by doing this, due to compositing: http://developer.apple.com/library/ios/#documentation/3DDrawing/Conceptual/OpenGLES_ProgrammingGuide/WorkingwithEAGLContexts/WorkingwithEAGLContexts.html%23//apple_ref/doc/uid/TP40008793-CH103-SW29 . If possible, I'd recommend combining the two views into one OpenGL ES scene. – Brad Larson Jan 11 '11 at 15:27
  • Ah, thanks for the links! I can confirm that the width problem was indeed that the view weren't a multiple of 32. If it is, the simulator renders as it should, at least as long as there is only one opengl layer. I would like to use only one layer too, however in this case, since I'm using a 3rd party component which uses its own OpenGL layer, I am forced to create my own. But thanks again for the answers! – j0h Jan 18 '11 at 11:43
  • Using two layers also seem to work in the simulator now, at least if one is fullscreen and the other 96x96. So using a view size other than a multiple of 32 seem to have been the cause of both problems. Thanks again! – j0h Jan 18 '11 at 11:56

1 Answers1

0

I found a similar problem running two OpenGL views at once, each running on a separate CADisplayLink, both running 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. 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). I was able to fix it by switching to NSTimer for both views (just doing it for one or the other wouldn't work). Sizing to multiples of 32 did not make any difference for me.

jeremywhuff
  • 2,911
  • 3
  • 29
  • 33