Ouzel openGL mode can't draw any content until moved/resized on macOS 10.14
woc2006 opened this issue · 3 comments
Code: master latest, sample project.
Hardware: Macbook pro 15inch 2018
Renderer: Opengl
I spent some time debugging how NSOpenGLView works and why it has no problems with rendering immediately. I disassembled the NSOpenGLView and found out that it is creating a custom layer (class: _NSOpenGLViewBackingLayer). I tried to create the same layer and it worked. I start to investigate the code of the _NSOpenGLViewBackingLayer and found out that it does some stuff in the display method and it is a subclass of CALayer. I tried to copy the functionality of the _NSOpenGLViewBackingLayer, but with no success. Then I tried to simply create an instance of CALayer and it worked!
PS. One call to [NSOpenGLContext update] must be made (it is done in [NSOpenGLView openGLContext] method.
Ok, my fix broke compatibility with older macOS which does not use layers for rendering. Did some more disassembling and came to a fix, that works both on Mojave and older versions on macOS: 7e70863
Calling [NSOpenGLContext update] without a layer attached to the view does nothing and usually, it is not attached to the view on the first frame (that is why you have to do it on the second one). This fix updates the NSOpenGLContext as soon as the layer is being set.