black screen / no events in iOS OpenGL ES 2

扶醉桌前 提交于 2019-12-10 15:36:49

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!