QOpenGL on Mac - QCocoaGLContext: Falling back to unshared context
-
I'm working on a opengl-based application in qt. It renders scenes fine on linux and windows, but on mac I end up with a black window. I used QOpenGLDebugLogger to give me some clarity on the issue and it outputs this error:
QCocoaGLContext: Falling back to unshared context
What does it mean and is this the cause of my scene not being rendered on mac specifically? If so how can i fix the issue?
The source for the project is here:
https://github.com/jahshaka/VRThanks in advance.
-
Hi
200% mac noob but it seems to come fromhttp://code.qt.io/cgit/qt/qtbase.git/tree/src/plugins/platforms/cocoa/qcocoaglcontext.mm
// retry without sharing on context creation failure.
if (!m_context && m_shareContext) {
m_shareContext = nil;
m_context = [[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:nil];
if (m_context)
qWarning("QCocoaGLContext: Falling back to unshared context.");
}and its just a warning.
Did you check that openGL do work on the mac?
https://forum.qt.io/topic/70082/qt-5-7-opengl-core-profile-2-1-on-os-x-functions-don-t-work
-
You were right, it's just a warning @mrjj .
I fixed the issue by setting the default surface format in the main function before the gui is created.
QSurfaceFormat format; format.setDepthBufferSize(32); format.setMajorVersion(3); format.setMinorVersion(2); format.setProfile(QSurfaceFormat::CoreProfile); QSurfaceFormat::setDefaultFormat(format);
Maybe this is needed so the UI and the QOpenGLWidget has the same version opengl contexts so they play nice. I'm not entirely sure what goes on the background.