Fix swap buffers (update the visible window contents) on macOS#15
Fix swap buffers (update the visible window contents) on macOS#15michaliskambi wants to merge 2 commits intodaar:GL-versionfrom
Conversation
Since FPC 3.2.0, one has to use `ObjCBool` instead of `Boolean`, otherwise GLPT compilation fails at various overrides because the methods are declared in ancestor with `ObjCBool` (not compatible with Pascal `Boolean`). E.g. in latest FPC, `packages/cocoaint/src/appkit/NSWindow.inc` defines ``` function initWithContentRect_styleMask_backing_defer (contentRect: NSRect; aStyle: NSUInteger; bufferingType: NSBackingStoreType; flag: ObjCBOOL): instancetype; message 'initWithContentRect:styleMask:backing:defer:'; ``` In GLPT, this should be overridden with `flag: ObjCBool`, not `flag: Boolean`. See https://fpcwiki.coderetro.net/User_Changes_3.2.0#objcbase .
flushBuffer call is necessary from Cocoa_SwapBuffers
|
in |
Thank you!
|
|
Hi thanks for the PR! I’m now traveling without much access to internet. In two weeks I will return and will process your request. |
( 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.