Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Legacy MacOS NSOpenGLPixelFormat failure and fix  (Read 2702 times)

0 Members and 1 Guest are viewing this topic.

j.keller51

  • Newbie
  • *
  • Posts: 17
    • View Profile
Legacy MacOS NSOpenGLPixelFormat failure and fix
« on: February 03, 2020, 06:54:32 pm »
Hi,

I'm building an app with SFML and we are targeting older versions of MacOS (back to 10.10). However, using SFML to create the window crashes or hangs in MacOS 10.10.

It seems to be caused by this line:

SFContext.mm
NSOpenGLPixelFormat* pixFmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:&attrs[0]];

pixFmt returns nill which causes the function to return without setting m_context, which is still uninitialized, and then other code tries to use it.

Through more investigation, I found that if I changed this line:

attrs.push_back(NSOpenGLPFAAccelerated);

to

if (@available(macOS 10.14, *))
    attrs.push_back(NSOpenGLPFAAccelerated);

The window opens and draws my objects correctly on 10.10.

I don't know anything about OpenGL, but this test suggests to me that hardware acceleration for antialiasing wasn't supported in earlier versions of MacOS. Can somebody who is more familiar with OpenGL or MacOS comment? And, should this be a patch in future versions of SFML?

Jonny

  • Full Member
  • ***
  • Posts: 114
    • View Profile
    • Email
Re: Legacy MacOS NSOpenGLPixelFormat failure and fix
« Reply #1 on: February 03, 2020, 11:58:03 pm »
Related issue: https://github.com/SFML/SFML/issues/161

Looking at the documentation it seems like NSOpenGLPFANoRecovery disables the fallback (software?) renderer, and I quote: "This attribute is not generally useful."

And the docs for NSOpenGLPFAAccelerated: "If present, this attribute indicates that only hardware-accelerated renderers are considered. If not present, accelerated renderers are still preferred."

Based on this, I'm wondering if we can just remove the line altogether rather than just putting it in a version check? If you want to open an issue (or a PR with that change if you like) then feel free, otherwise I'll put something together this weekend

j.keller51

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: Legacy MacOS NSOpenGLPixelFormat failure and fix
« Reply #2 on: February 04, 2020, 03:59:25 pm »
I don't have access to push a branch to the git repo. I'll open an issue.

Thanks

 

anything