-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix swap buffers (update the visible window contents) on macOS #15
base: GL-version
Are you sure you want to change the base?
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.
./gears
run 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./simple
demo. The demo./two_windows
is 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.drawRect
callsopenGLContext.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_SwapBuffers
makes 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_SwapBuffers
works.