Skip to content
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

Open
wants to merge 2 commits into
base: GL-version
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions GLPT_Cocoa.inc
Original file line number Diff line number Diff line change
Expand Up @@ -230,23 +230,23 @@ end;
type
TBorderlessWindow = objcclass (NSWindow)
public
function initWithContentRect_styleMask_backing_defer (contentRect: NSRect; aStyle: NSUInteger; bufferingType: NSBackingStoreType; flag: boolean): id; override;
function initWithContentRect_styleMask_backing_defer (contentRect: NSRect; aStyle: NSUInteger; bufferingType: NSBackingStoreType; flag: ObjCBool): id; override;
function initWithContentRect(contentRect: NSRect): id; message 'initWithContentRect:';
function canBecomeKeyWindow: boolean; override;
function canBecomeMainWindow: boolean; override;
function canBecomeKeyWindow: ObjCBool; override;
function canBecomeMainWindow: ObjCBool; override;
procedure setKeepFullScreenAlways (newValue: boolean); message 'setKeepFullScreenAlways:';
private
keepFullScreenAlways: boolean;
procedure screenParametersChanged (notification: NSNotification); message 'screenParametersChanged:';
procedure dealloc; override;
end;

function TBorderlessWindow.canBecomeKeyWindow: boolean;
function TBorderlessWindow.canBecomeKeyWindow: ObjCBool;
begin
result := true;
end;

function TBorderlessWindow.canBecomeMainWindow: boolean;
function TBorderlessWindow.canBecomeMainWindow: ObjCBool;
begin
result := true;
end;
Expand All @@ -271,7 +271,7 @@ begin
inherited dealloc;
end;

function TBorderlessWindow.initWithContentRect_styleMask_backing_defer (contentRect: NSRect; aStyle: NSUInteger; bufferingType: NSBackingStoreType; flag: boolean): id;
function TBorderlessWindow.initWithContentRect_styleMask_backing_defer (contentRect: NSRect; aStyle: NSUInteger; bufferingType: NSBackingStoreType; flag: ObjCBool): id;
begin
result := inherited initWithContentRect_styleMask_backing_defer(contentRect, aStyle, bufferingType, flag);
if result <> nil then
Expand Down Expand Up @@ -442,7 +442,7 @@ type
TOpenGLView = objcclass (NSView)
public
function initWithFrame(frameRect: NSRect): id; override;
function isOpaque: Boolean; override;
function isOpaque: ObjCBool; override;
private
openGLContext: NSOpenGLContext;
trackingArea: NSTrackingArea;
Expand Down Expand Up @@ -537,7 +537,8 @@ end;

procedure TOpenGLView.drawRect(dirtyRect: NSRect);
begin
openGLContext.flushBuffer;
// This has to be done in Cocoa_SwapBuffers, at least on macOS 12
// openGLContext.flushBuffer;
end;

procedure TOpenGLView.reshape;
Expand All @@ -556,7 +557,7 @@ begin
end;
end;

function TOpenGLView.isOpaque: Boolean;
function TOpenGLView.isOpaque: ObjCBool;
begin
// return false to make the view transparent
result := window.backgroundColor.alphaComponent > 0;
Expand Down Expand Up @@ -725,6 +726,7 @@ end;
procedure Cocoa_SwapBuffers(win: pGLPTwindow);
begin
win^.ref.contentView.display;
win^.glcontext.flushBuffer;
end;

procedure Cocoa_GetFrameBufferSize(win: pGLPTwindow; out width, height: integer);
Expand Down