Skip to content

Commit

Permalink
Fix setting alpha buffer size in Ui::GL::CheckCapabilities fo Qt 6.4+
Browse files Browse the repository at this point in the history
  • Loading branch information
ilya-fedin authored and john-preston committed Jun 21, 2024
1 parent 899b1db commit 3fb4226
Showing 1 changed file with 13 additions and 19 deletions.
32 changes: 13 additions & 19 deletions ui/gl/gl_detection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,30 +90,24 @@ Capabilities CheckCapabilities(QWidget *widget) {
return true;
}();

auto format = QSurfaceFormat();
if (widget) {
if (!widget->window()->windowHandle()) {
widget->window()->createWinId();
}
if (!widget->window()->windowHandle()) {
LOG(("OpenGL: Could not create window for widget."));
return {};
}
format = widget->window()->windowHandle()->format();
format.setAlphaBufferSize(8);
widget->window()->windowHandle()->setFormat(format);
} else {
format.setAlphaBufferSize(8);
}

CrashCheckStart();
const auto guard = gsl::finally([=] {
CrashCheckFinish();
});

auto tester = QOpenGLWidget(widget);
tester.setFormat(format);
tester.grabFramebuffer(); // Force initialize().
if (!tester.window()->windowHandle()) {
tester.window()->createWinId();
}
CrashCheckFinish();
if (!tester.window()->windowHandle()) {
LOG(("OpenGL: Could not create window for widget."));
return {};
}
auto format = tester.window()->windowHandle()->format();
format.setAlphaBufferSize(8);
tester.window()->windowHandle()->setFormat(format);
tester.setFormat(format);
tester.grabFramebuffer(); // Force initialize().

const auto context = tester.context();
if (!context
Expand Down

0 comments on commit 3fb4226

Please sign in to comment.