Fix GL detection without a parent window.
This commit is contained in:
parent
95ee92088e
commit
ca5b2e6746
3 changed files with 8 additions and 17 deletions
|
|
@ -18,7 +18,6 @@
|
||||||
namespace Ui::GL {
|
namespace Ui::GL {
|
||||||
|
|
||||||
Capabilities CheckCapabilities(QWidget *widget) {
|
Capabilities CheckCapabilities(QWidget *widget) {
|
||||||
auto created = QOpenGLContext();
|
|
||||||
auto format = QSurfaceFormat();
|
auto format = QSurfaceFormat();
|
||||||
format.setAlphaBufferSize(8);
|
format.setAlphaBufferSize(8);
|
||||||
if (widget) {
|
if (widget) {
|
||||||
|
|
@ -33,19 +32,11 @@ Capabilities CheckCapabilities(QWidget *widget) {
|
||||||
LOG_ONCE(("OpenGL: Not supported for window."));
|
LOG_ONCE(("OpenGL: Not supported for window."));
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
created.setFormat(format);
|
|
||||||
if (!created.create()) {
|
|
||||||
LOG_ONCE(("OpenGL: Could not create context with alpha."));
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
auto tester = QOpenGLWidget(widget);
|
auto tester = QOpenGLWidget(widget);
|
||||||
if (widget) {
|
tester.setFormat(format);
|
||||||
tester.setFormat(format);
|
tester.grabFramebuffer(); // Force initialize().
|
||||||
tester.grabFramebuffer(); // Force initialize().
|
const auto context = tester.context();
|
||||||
}
|
|
||||||
const auto context = (widget ? tester.context() : &created);
|
|
||||||
if (!context) {
|
if (!context) {
|
||||||
LOG_ONCE(("OpenGL: Could not create widget in a window."));
|
LOG_ONCE(("OpenGL: Could not create widget in a window."));
|
||||||
return {};
|
return {};
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@
|
||||||
#include "ui/gl/gl_surface.h"
|
#include "ui/gl/gl_surface.h"
|
||||||
|
|
||||||
#include "ui/rp_widget.h"
|
#include "ui/rp_widget.h"
|
||||||
|
#include "ui/painter.h"
|
||||||
|
|
||||||
#include <QtGui/QPainter>
|
|
||||||
#include <QtGui/QtEvents>
|
#include <QtGui/QtEvents>
|
||||||
#include <QtGui/QOpenGLContext>
|
#include <QtGui/QOpenGLContext>
|
||||||
#include <QtWidgets/QOpenGLWidget>
|
#include <QtWidgets/QOpenGLWidget>
|
||||||
|
|
@ -72,7 +72,7 @@ SurfaceRaster::SurfaceRaster(
|
||||||
}
|
}
|
||||||
|
|
||||||
void SurfaceRaster::paintEvent(QPaintEvent *e) {
|
void SurfaceRaster::paintEvent(QPaintEvent *e) {
|
||||||
_renderer->paintFallback(QPainter(this), e->region(), Backend::Raster);
|
_renderer->paintFallback(Painter(this), e->region(), Backend::Raster);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
@ -80,7 +80,7 @@ void SurfaceRaster::paintEvent(QPaintEvent *e) {
|
||||||
void Renderer::paint(
|
void Renderer::paint(
|
||||||
not_null<QOpenGLWidget*> widget,
|
not_null<QOpenGLWidget*> widget,
|
||||||
not_null<QOpenGLFunctions*> f) {
|
not_null<QOpenGLFunctions*> f) {
|
||||||
paintFallback(QPainter(widget.get()), widget->rect(), Backend::OpenGL);
|
paintFallback(Painter(widget.get()), widget->rect(), Backend::OpenGL);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<RpWidgetWrap> CreateSurface(
|
std::unique_ptr<RpWidgetWrap> CreateSurface(
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
#include "ui/gl/gl_detection.h"
|
#include "ui/gl/gl_detection.h"
|
||||||
|
|
||||||
class QPainter;
|
class Painter;
|
||||||
class QOpenGLWidget;
|
class QOpenGLWidget;
|
||||||
class QOpenGLFunctions;
|
class QOpenGLFunctions;
|
||||||
|
|
||||||
|
|
@ -42,7 +42,7 @@ public:
|
||||||
not_null<QOpenGLFunctions*> f);
|
not_null<QOpenGLFunctions*> f);
|
||||||
|
|
||||||
virtual void paintFallback(
|
virtual void paintFallback(
|
||||||
QPainter &&p,
|
Painter &&p,
|
||||||
const QRegion &clip,
|
const QRegion &clip,
|
||||||
Backend backend) {
|
Backend backend) {
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue