diff options
author | Alex Wilson <alex.wilson@nokia.com> | 2011-12-14 16:10:15 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-12-15 11:02:55 +0100 |
commit | 4bb5b4f01c1b38fce9f1a11346de5bd4ee3c6fd4 (patch) | |
tree | e95f5ea2bf8cff0a29cef8e59fa8481681f95e46 | |
parent | ad91ab8b7db93ee13db18b1284542b9853183092 (diff) |
Add lineWidth property to QSGGeometry
Allows users to set a line width when using drawingModes GL_LINES,
GL_LINE_LOOP etc. Only calls glLineWidth on these drawingModes, and
does it just before the glDrawElements/glDrawArrays.
Change-Id: I2af583970b2acf0ddb59025a454caa75a8ddbd4f
Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>
-rw-r--r-- | src/quick/scenegraph/coreapi/qsggeometry.cpp | 25 | ||||
-rw-r--r-- | src/quick/scenegraph/coreapi/qsggeometry.h | 5 | ||||
-rw-r--r-- | src/quick/scenegraph/coreapi/qsgrenderer.cpp | 4 |
3 files changed, 34 insertions, 0 deletions
diff --git a/src/quick/scenegraph/coreapi/qsggeometry.cpp b/src/quick/scenegraph/coreapi/qsggeometry.cpp index 8661c9af93..b747bb96e3 100644 --- a/src/quick/scenegraph/coreapi/qsggeometry.cpp +++ b/src/quick/scenegraph/coreapi/qsggeometry.cpp @@ -138,6 +138,7 @@ QSGGeometry::QSGGeometry(const QSGGeometry::AttributeSet &attributes, , m_owns_data(false) , m_index_usage_pattern(AlwaysUploadPattern) , m_vertex_usage_pattern(AlwaysUploadPattern) + , m_line_width(1.0) { Q_ASSERT(m_attributes.count > 0); Q_ASSERT(m_attributes.stride > 0); @@ -253,6 +254,30 @@ void QSGGeometry::setDrawingMode(GLenum mode) } /*! + Gets the current line width to be used for this geometry. This property only + applies where the drawingMode is GL_LINES or a related value. + + The default value is 1.0 + + \sa setLineWidth(), drawingMode() +*/ +float QSGGeometry::lineWidth() const +{ + return m_line_width; +} + +/*! + Sets the line width to be used for this geometry. This property only applies + where the drawingMode is GL_LINES or a related value. + + \sa lineWidth(), drawingMode() +*/ +void QSGGeometry::setLineWidth(float w) +{ + m_line_width = w; +} + +/*! \fn int QSGGeometry::drawingMode() const Returns the drawing mode of this geometry. diff --git a/src/quick/scenegraph/coreapi/qsggeometry.h b/src/quick/scenegraph/coreapi/qsggeometry.h index aea6f0b94b..85f48814ed 100644 --- a/src/quick/scenegraph/coreapi/qsggeometry.h +++ b/src/quick/scenegraph/coreapi/qsggeometry.h @@ -160,6 +160,9 @@ public: void markIndexDataDirty(); void markVertexDataDirty(); + float lineWidth() const; + void setLineWidth(float w); + private: friend class QSGGeometryData; @@ -181,6 +184,8 @@ private: uint m_reserved_bits : 27; float m_prealloc[16]; + + float m_line_width; }; inline uint *QSGGeometry::indexDataAsUInt() diff --git a/src/quick/scenegraph/coreapi/qsgrenderer.cpp b/src/quick/scenegraph/coreapi/qsgrenderer.cpp index 1b4f5da435..a7aac5f42c 100644 --- a/src/quick/scenegraph/coreapi/qsgrenderer.cpp +++ b/src/quick/scenegraph/coreapi/qsgrenderer.cpp @@ -701,6 +701,10 @@ void QSGRenderer::draw(const QSGMaterialShader *shader, const QSGGeometry *g) indexData = g->indexData(); } + // Set the line width if applicable + if (g->drawingMode() == GL_LINES || g->drawingMode() == GL_LINE_STRIP || g->drawingMode() == GL_LINE_LOOP) { + glLineWidth(g->lineWidth()); + } // draw the stuff... if (g->indexCount()) { |