Fix swap buffers (update the visible window contents) on macOS #15
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
( Note: This branch is done on top of #14 . Once you apply #14 , this PR will contain only 1 commit. )
I'm testing GLPT on macOS 12.3.1 x86_64 . (I do not have a physical machine, I'm actually using remote session to a macOS machine provided by MacStadium for Castle Game Engine development.)
Observed problem: The screen contents do not update. E.g.
./gearsrun and look like a static image, even though adding logs shows thatangle += 0.02;is done and the screen is redrawn. Same with triangle in./simpledemo. The demo./two_windowsis a bit weird, with windows updating irregularly once you move them.This suggests a problem with not doing OpenGL "swap buffers". I see that
TOpenGLView.drawRectcallsopenGLContext.flushBuffer(which should swap buffers, https://developer.apple.com/documentation/appkit/nsopenglcontext/1436211-flushbuffer ), but it does not seem to do anything on my setup. Doing it fromCocoa_SwapBuffersmakes things update reliably.Reading Apple docs, and with my zero Cocoa knowledge today, I cannot really tell why does the change work. Reading docs https://developer.apple.com/library/archive/documentation/GraphicsImaging/Conceptual/OpenGL-MacProgGuide/opengl_drawing/opengl_drawing.html , they show using
[context flushBuffer];from-(void) drawRect, so exactly what you're doing before the PR. Yet it doesn't work for me, moving it toCocoa_SwapBuffersworks.