summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlex Wilson <alex.wilson@nokia.com>2011-12-20 12:02:15 +1000
committerQt by Nokia <qt-info@nokia.com>2011-12-20 03:41:25 +0100
commit6f80f1ab08168052c096dad86a92c685c38521f5 (patch)
tree9b0dc121aabf402e015bf3388d8852b900b8e35b /src
parentc0bab81c8a47d4a4f20d31f7d861c86c59235503 (diff)
downloadqtlocation-6f80f1ab08168052c096dad86a92c685c38521f5.tar.gz
Replacing GL_QUADS and GL_POLYGON with triangles
This is necessary for building against OpenGL ES, and is also generally just a Good Idea, as triangles are more friendly to almost all graphics hardware. Change-Id: Iabdec5d01a3a61c61990b39a6a94279c60a9731e Reviewed-by: David Laing <david.laing@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/imports/location/qdeclarativepolygonmapitem.cpp6
-rw-r--r--src/imports/location/qdeclarativerectanglemapitem.cpp9
2 files changed, 9 insertions, 6 deletions
diff --git a/src/imports/location/qdeclarativepolygonmapitem.cpp b/src/imports/location/qdeclarativepolygonmapitem.cpp
index d65f58a0..f3f510fa 100644
--- a/src/imports/location/qdeclarativepolygonmapitem.cpp
+++ b/src/imports/location/qdeclarativepolygonmapitem.cpp
@@ -273,7 +273,7 @@ MapPolygonNode::MapPolygonNode() :
border_(new MapPolylineNode()),
geometry_(QSGGeometry::defaultAttributes_Point2D(), 0)
{
- geometry_.setDrawingMode(GL_POLYGON);
+ geometry_.setDrawingMode(GL_TRIANGLE_FAN);
QSGGeometryNode::setMaterial(&fill_material_);
QSGGeometryNode::setGeometry(&geometry_);
@@ -296,13 +296,15 @@ void MapPolygonNode::update(const QColor& fillColor, const QPolygonF& shape,
int fillVertexCount = 0;
//note this will not allocate new buffer if the size has not changed
- fill->allocate(shape.size());
+ fill->allocate(shape.size() + 2);
Vertex *vertices = (Vertex *)fill->vertexData();
+ vertices[fillVertexCount++].position = QVector2D(shape.boundingRect().center());
for (int i = 0; i < shape.size(); ++i) {
vertices[fillVertexCount++].position = QVector2D(shape.at(i));
}
+ vertices[fillVertexCount++].position = QVector2D(shape.at(0));
Q_ASSERT(fillVertexCount == fill->vertexCount());
markDirty(DirtyGeometry);
diff --git a/src/imports/location/qdeclarativerectanglemapitem.cpp b/src/imports/location/qdeclarativerectanglemapitem.cpp
index 94b301a0..0908c3a0 100644
--- a/src/imports/location/qdeclarativerectanglemapitem.cpp
+++ b/src/imports/location/qdeclarativerectanglemapitem.cpp
@@ -231,7 +231,7 @@ void QDeclarativeRectangleMapItem::dragStarted()
MapRectangleNode::MapRectangleNode():
geometry_(QSGGeometry::defaultAttributes_Point2D(),0)
{
- geometry_.setDrawingMode(GL_QUADS);
+ geometry_.setDrawingMode(GL_TRIANGLE_STRIP);
QSGGeometryNode::setMaterial(&fillMaterial_);
QSGGeometryNode::setGeometry(&geometry_);
}
@@ -248,15 +248,16 @@ void MapRectangleNode::update(const QColor& fillColor, const QRectF& shape)
int fillVertexCount = 0;
//note this will not allocate new buffer if the size has not changed
- fill->allocate(4);
+ fill->allocate(5);
Vertex *vertices = (Vertex *)fill->vertexData();
//set corners
- vertices[fillVertexCount++].position = QVector2D(shape.left(),shape.top());
+ vertices[fillVertexCount++].position = QVector2D(shape.left(), shape.top());
vertices[fillVertexCount++].position = QVector2D(shape.right(),shape.top());
vertices[fillVertexCount++].position = QVector2D(shape.right(),shape.bottom());
- vertices[fillVertexCount++].position = QVector2D(shape.left(),shape.bottom());
+ vertices[fillVertexCount++].position = QVector2D(shape.left(), shape.bottom());
+ vertices[fillVertexCount++].position = QVector2D(shape.left(), shape.top());
Q_ASSERT(fillVertexCount == fill->vertexCount());