问题
I'm dealing with an error for about 45 days. I already tried dozens of method calls, change the whole program, but nothing works.
I use GLES 2, with a UIViewController that is the rootViewController, that has a view of type UIView, whose layerclass is CAEAGLLayer.
When i run the application, the screen gets black and if i press the screen, no events are generated.
If i rotate the application, the screen appears and the events work. Even worst, if i dont rotate the application, but put a breakpoint right after the presentRenderbuffer, and press the "Capture OpenGL ES Frame" button inside Xcode, the screen appears and the events start working!!!
What i feel is that the view is not actually shown, however, i implemented the viewWillLayoutSubviews, viewWillAppear, viewDidAppear, loadView (where i start everything), all these methods gets called in this order:
load view view will appear view will layout subviews view did appear
Also, the view has actually a valid frame size.
Any help is greatly appreciated for this desperate user.
guich
回答1:
The solution to this problem was: setup the context in the main thread, where all windows are created, and then share the open gl context between all threads by calling
[EAGLContext setCurrentContext:glcontext]
at each thread
来源:https://stackoverflow.com/questions/14074511/black-screen-no-events-in-ios-opengl-es-2