[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [analitza] /: Improve QQuickFramebufferObject usage
From: Aleix Pol <aleixpol () kde ! org>
Date: 2015-10-01 1:39:51
Message-ID: E1ZhSqd-0006Xk-Is () scm ! kde ! org
[Download RAW message or body]
Git commit 833ecef1078ba7008a6b26365f94be4b61a53e81 by Aleix Pol.
Committed on 30/09/2015 at 23:21.
Pushed by apol into branch 'master'.
Improve QQuickFramebufferObject usage
M +4 -5 analitzaplot/plotter3d_es.cpp
M +15 -0 declarative/graph3ditem.cpp
M +2 -0 declarative/graph3ditem.h
http://commits.kde.org/analitza/833ecef1078ba7008a6b26365f94be4b61a53e81
diff --git a/analitzaplot/plotter3d_es.cpp b/analitzaplot/plotter3d_es.cpp
index de38ba6..c26ecb9 100644
--- a/analitzaplot/plotter3d_es.cpp
+++ b/analitzaplot/plotter3d_es.cpp
@@ -95,11 +95,6 @@ void Plotter3DES::initGL()
{
initializeOpenGLFunctions();
- glEnable(GL_DEPTH_TEST);
-
- glClearColor(0, 0, 0, 1);
-// glEnable(GL_CULL_FACE);
-
//TODO: provide GLSL version
program.addShaderFromSourceCode(QOpenGLShader::Vertex,
"attribute highp vec4 vertex;\n"
@@ -164,6 +159,10 @@ void Plotter3DES::setViewport(const QRectF& vp)
void Plotter3DES::drawPlots()
{
+ glClearColor(0, 0, 0, 1);
+ glEnable(GL_DEPTH_TEST);
+ glDepthMask(true);
+
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
if(!m_model)
diff --git a/declarative/graph3ditem.cpp b/declarative/graph3ditem.cpp
index 94a7c82..7455b9a 100644
--- a/declarative/graph3ditem.cpp
+++ b/declarative/graph3ditem.cpp
@@ -20,6 +20,7 @@
#include <QQuickWindow>
#include <QOpenGLFramebufferObject>
#include <analitzaplot/plotsmodel.h>
+#include <QThread>
using namespace Analitza;
@@ -30,9 +31,15 @@ Plotter3DRenderer::Plotter3DRenderer(Graph3DItem* item)
void Plotter3DRenderer::renderGL()
{
+ Q_ASSERT(QThread::currentThread() == m_item->thread());
m_item->window()->update();
}
+QQuickWindow* Plotter3DRenderer::window() const
+{
+ return m_item->window();
+}
+
Graph3DItem::Graph3DItem(QQuickItem* parent)
: QQuickFramebufferObject(parent)
, m_plotter(new Plotter3DRenderer(this))
@@ -100,6 +107,14 @@ public:
void render() {
m_plotter->drawPlots();
+ m_plotter->window()->resetOpenGLState();
+ }
+
+ QOpenGLFramebufferObject *createFramebufferObject(const QSize &size)
+ {
+ QOpenGLFramebufferObjectFormat format;
+ format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
+ return new QOpenGLFramebufferObject(size, format);
}
private:
diff --git a/declarative/graph3ditem.h b/declarative/graph3ditem.h
index 87a20c2..2836364 100644
--- a/declarative/graph3ditem.h
+++ b/declarative/graph3ditem.h
@@ -33,6 +33,8 @@ public:
void modelChanged() override {}
void renderGL() override;
+ QQuickWindow* window() const;
+
private:
const Graph3DItem* m_item;
};
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic