When resizing a GLKView in buffers and the context of that GLKView there are some off-screen operations. During the time required to complete these backstage operations, drawing on GLKView does not produce the correct results.
In my script, I have a GLKView that has setNeedsDisplay enabled, so anytime I need to update its contents on the screen, I just call -setNeedsDisplay on that GLKView . I use GLKView to draw images, so if I need to draw an image with a different size, I also need to resize the GLKView .
Problem: when I resize GLKView and call setNeedsDisplay in this view, the result on the screen is incorrect. This is because GLKView did not complete the off-screen operations caused by the new resizing before attempting to draw a new image.
I found a workaround for this by calling performSelector:@selector(setNeedsDisplay) withObject:nil afterDelay:0 instead of setNeedsDisplay on GLKView . This basically makes the main thread wait for all openGL operations to complete before calling setNeedsDisplay . Although this works fine, I wonder if there is a better solution. For example, is there an openGL call so that the thread waits for all OpenGL operations to complete before continuing?
source share