Skip to content

Commit

Permalink
[Mac] Minor fixes on Mac platform.
Browse files Browse the repository at this point in the history
- Don't make NSWindow initially visibile if it's not explcitily shown.
- Clamp GL context sample count to 1 if a default context is created.
  • Loading branch information
LukasBanana committed Sep 14, 2024
1 parent ca579f2 commit cda6e4d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
13 changes: 9 additions & 4 deletions sources/Platform/MacOS/MacOSWindow.mm
Original file line number Diff line number Diff line change
Expand Up @@ -439,17 +439,22 @@ static void SetRelativeNSWindowPosition(NSWindow* wnd, const Offset2D& position,
#endif

const bool isCentered = ((desc.flags & WindowFlags::Centered) != 0);
const bool isVisible = ((desc.flags & WindowFlags::Visible) != 0);

/* Make this the new key window but only put it into the front if it's initially visible */
if (isVisible)
[wnd makeKeyAndOrderFront:nil];
else
[wnd makeKeyWindow];

/* Move this window to the front of the screen list and center if requested */
[wnd makeKeyAndOrderFront:nil];
if (isCentered)
[wnd center];
else
SetRelativeNSWindowPosition(wnd, desc.position);

/* Show window */
if ((desc.flags & WindowFlags::Visible) != 0)
[wnd setIsVisible:YES];
/* Show or hide window */
[wnd setIsVisible:(isVisible ? YES : NO)];

return wnd;
}
Expand Down
2 changes: 1 addition & 1 deletion sources/Renderer/Metal/Shader/MTShader.mm
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ static MTLLanguageVersion GetMTLLanguageVersion(const ShaderDescriptor& desc)
return opt;
}

bool MTShader::CompileFromDefaultLibrary(id<MTLDevice> device, const ShaderDescriptor &shaderDesc)
bool MTShader::CompileFromDefaultLibrary(id<MTLDevice> device, const ShaderDescriptor& shaderDesc)
{
library_ = [device newDefaultLibrary];
return LoadShaderFunction(shaderDesc.entryPoint);
Expand Down
2 changes: 1 addition & 1 deletion sources/Renderer/OpenGL/Platform/MacOS/MacOSGLContext.mm
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ static NSOpenGLPixelFormatAttribute TranslateNSOpenGLProfile(const RendererConfi
const NSOpenGLPixelFormatAttribute profileAttrib = TranslateNSOpenGLProfile(profile);

/* Find suitable pixel format (for samples > 0) */
for (samples_ = pixelFormat.samples; samples_ > 0; --samples_)
for (samples_ = std::max<int>(1, pixelFormat.samples); samples_ > 0; --samples_)
{
NSOpenGLPixelFormatAttribute attribs[] =
{
Expand Down

0 comments on commit cda6e4d

Please sign in to comment.