summaryrefslogtreecommitdiffstats
path: root/src/datavisualization/engine/drawer.cpp
diff options
context:
space:
mode:
authorTomi Korpipää <tomi.korpipaa@digia.com>2013-11-06 10:28:35 +0200
committerTomi Korpipää <tomi.korpipaa@digia.com>2013-11-06 11:14:54 +0200
commitd493ae2fcef2ed63413b78e6afc16d13c82131ac (patch)
tree92d6bec4af629696a9f834f8e233f8436bdec7e4 /src/datavisualization/engine/drawer.cpp
parent582dc50a49c60d7224f9ebbf5b5cbdf687b5f8d0 (diff)
Added GL_POINTS for scatter
Task-number: QTRD-2535 Change-Id: Icf2d4ab1d8a46ea38864d2b587411ed05c58de38 Change-Id: Icf2d4ab1d8a46ea38864d2b587411ed05c58de38 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@digia.com>
Diffstat (limited to 'src/datavisualization/engine/drawer.cpp')
-rw-r--r--src/datavisualization/engine/drawer.cpp30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/datavisualization/engine/drawer.cpp b/src/datavisualization/engine/drawer.cpp
index 8643d6d9..93336e96 100644
--- a/src/datavisualization/engine/drawer.cpp
+++ b/src/datavisualization/engine/drawer.cpp
@@ -41,17 +41,22 @@ StaticLibInitializer staticLibInitializer;
QT_DATAVISUALIZATION_BEGIN_NAMESPACE
+// Vertex array buffer for point
+const GLfloat point_data[] = {0.0f, 0.0f, 0.0f};
+
Drawer::Drawer(const Theme &theme, const QFont &font, QDataVis::LabelStyle style)
: m_theme(theme),
m_font(font),
m_style(style),
- m_textureHelper(0)
+ m_textureHelper(0),
+ m_pointbuffer(0)
{
}
Drawer::~Drawer()
{
delete m_textureHelper;
+ glDeleteBuffers(1, &m_pointbuffer);
}
void Drawer::initializeOpenGL()
@@ -163,6 +168,29 @@ void Drawer::drawSurfaceGrid(ShaderHelper *shader, SurfaceObject *object)
glDisableVertexAttribArray(shader->posAtt());
}
+void Drawer::drawPoint(ShaderHelper *shader)
+{
+ // Generate vertex buffer for point if it does not exist
+ if (!m_pointbuffer) {
+ glGenBuffers(1, &m_pointbuffer);
+ glBindBuffer(GL_ARRAY_BUFFER, m_pointbuffer);
+ glBufferData(GL_ARRAY_BUFFER, sizeof(point_data), point_data, GL_STATIC_DRAW);
+ }
+
+ // 1st attribute buffer : vertices
+ glEnableVertexAttribArray(shader->posAtt());
+ glBindBuffer(GL_ARRAY_BUFFER, m_pointbuffer);
+ glVertexAttribPointer(shader->posAtt(), 3, GL_FLOAT, GL_FALSE, 0, (void*)0);
+
+ // Draw the point
+ glDrawArrays(GL_POINTS, 0, 1);
+
+ // Free buffers
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
+
+ glDisableVertexAttribArray(shader->posAtt());
+}
+
void Drawer::drawLabel(const AbstractRenderItem &item, const LabelItem &labelItem,
const QMatrix4x4 &viewmatrix, const QMatrix4x4 &projectionmatrix,
const QVector3D &positionComp, const QVector3D &rotation,