Start of windowed OpenGL rendering
This commit is contained in:
@@ -17,6 +17,12 @@ void HardwareRenderer::initializeGL()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void HardwareRenderer::paintGL() {
|
void HardwareRenderer::paintGL() {
|
||||||
|
//onPaint(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HardwareRenderer::paintUnderGL() {
|
||||||
|
glClearColor(0.f, 0.f, 0.f, 1.f);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
onPaint(this);
|
onPaint(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,11 +30,9 @@ void HardwareRenderer::setRenderType(RenderType type) {
|
|||||||
QSurfaceFormat format;
|
QSurfaceFormat format;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case RenderType::OpenGL:
|
case RenderType::OpenGL:
|
||||||
setTextureFormat(GL_RGB);
|
|
||||||
format.setRenderableType(QSurfaceFormat::OpenGL);
|
format.setRenderableType(QSurfaceFormat::OpenGL);
|
||||||
break;
|
break;
|
||||||
case RenderType::OpenGLES:
|
case RenderType::OpenGLES:
|
||||||
setTextureFormat((QApplication::platformName().contains("wayland") || QApplication::platformName() == "cocoa") ? GL_RGB : GL_RGBA);
|
|
||||||
format.setRenderableType(QSurfaceFormat::OpenGLES);
|
format.setRenderableType(QSurfaceFormat::OpenGLES);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -45,5 +49,5 @@ void HardwareRenderer::onBlit(const QImage& img, int x, int y, int w, int h, std
|
|||||||
|
|
||||||
void HardwareRenderer::resizeEvent(QResizeEvent *event) {
|
void HardwareRenderer::resizeEvent(QResizeEvent *event) {
|
||||||
onResize(width(), height());
|
onResize(width(), height());
|
||||||
QOpenGLWidget::resizeEvent(event);
|
QOpenGLWindow::resizeEvent(event);
|
||||||
}
|
}
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <QOpenGLFunctions>
|
#include <QOpenGLFunctions>
|
||||||
#include <QOpenGLWidget>
|
#include <QOpenGLWidget>
|
||||||
|
#include <QOpenGLWindow>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
@@ -16,7 +17,7 @@
|
|||||||
#include "wl_mouse.hpp"
|
#include "wl_mouse.hpp"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class HardwareRenderer : public QOpenGLWidget, protected QOpenGLFunctions, public RendererCommon
|
class HardwareRenderer : public QOpenGLWindow, protected QOpenGLFunctions, public RendererCommon
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -26,10 +27,12 @@ public:
|
|||||||
void resizeGL(int w, int h) override;
|
void resizeGL(int w, int h) override;
|
||||||
void initializeGL() override;
|
void initializeGL() override;
|
||||||
void paintGL() override;
|
void paintGL() override;
|
||||||
HardwareRenderer(QWidget* parent = nullptr)
|
void paintUnderGL() override;
|
||||||
: QOpenGLWidget(parent), QOpenGLFunctions()
|
HardwareRenderer(QWindow* parent = nullptr)
|
||||||
|
: QOpenGLWindow(QOpenGLWindow::PartialUpdateBlend, parent), QOpenGLFunctions()
|
||||||
{
|
{
|
||||||
setMinimumSize(16, 16);
|
setMinimumSize(QSize(16, 16));
|
||||||
|
setFlags(Qt::FramelessWindowHint);
|
||||||
}
|
}
|
||||||
~HardwareRenderer()
|
~HardwareRenderer()
|
||||||
{
|
{
|
||||||
|
@@ -183,18 +183,20 @@ void RendererStack::switchRenderer(Renderer renderer) {
|
|||||||
break;
|
break;
|
||||||
case Renderer::OpenGL:
|
case Renderer::OpenGL:
|
||||||
{
|
{
|
||||||
auto hw = new HardwareRenderer(this);
|
this->createWinId();
|
||||||
|
auto hw = new HardwareRenderer(this->windowHandle());
|
||||||
connect(this, &RendererStack::blitToRenderer, hw, &HardwareRenderer::onBlit, Qt::QueuedConnection);
|
connect(this, &RendererStack::blitToRenderer, hw, &HardwareRenderer::onBlit, Qt::QueuedConnection);
|
||||||
hw->setRenderType(HardwareRenderer::RenderType::OpenGL);
|
hw->setRenderType(HardwareRenderer::RenderType::OpenGL);
|
||||||
current.reset(hw);
|
current.reset(this->createWindowContainer(hw, this));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Renderer::OpenGLES:
|
case Renderer::OpenGLES:
|
||||||
{
|
{
|
||||||
auto hw = new HardwareRenderer(this);
|
this->createWinId();
|
||||||
|
auto hw = new HardwareRenderer(this->windowHandle());
|
||||||
connect(this, &RendererStack::blitToRenderer, hw, &HardwareRenderer::onBlit, Qt::QueuedConnection);
|
connect(this, &RendererStack::blitToRenderer, hw, &HardwareRenderer::onBlit, Qt::QueuedConnection);
|
||||||
hw->setRenderType(HardwareRenderer::RenderType::OpenGLES);
|
hw->setRenderType(HardwareRenderer::RenderType::OpenGLES);
|
||||||
current.reset(hw);
|
current.reset(this->createWindowContainer(hw, this));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user