Fix the visualization of unmerged batch geometries without index
authorJocelyn Turcotte <jocelyn.turcotte@digia.com>
Wed, 26 Nov 2014 14:58:12 +0000 (15:58 +0100)
committerJocelyn Turcotte <jocelyn.turcotte@digia.com>
Tue, 9 Dec 2014 13:36:38 +0000 (14:36 +0100)
indexData() is null for most QSGGeometryNodes subclasses in QtQuick,
make sure that we draw using vertex array data in that case.

The patch also increases the contrast of the line pattern, since it
is almost invisible with brighter hue values, to make it easier to
see which batches aren't merged.

Change-Id: Ife7b26692ee318feb0810ee0e787289eb151ea8a
Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
src/quick/scenegraph/shaders/visualization.frag

index 2f94bad..dbea0fa 100644 (file)
@@ -2766,7 +2766,10 @@ void Renderer::visualizeBatch(Batch *b)
             g = gn->geometry();
             shader->setUniformValue(shader->matrix, matrix * *gn->matrix());
             glVertexAttribPointer(a.position, a.tupleSize, a.type, false, g->sizeOfVertex(), (void *) (qintptr) offset);
-            glDrawElements(g->drawingMode(), g->indexCount(), g->indexType(), g->indexData());
+            if (g->indexCount())
+                glDrawElements(g->drawingMode(), g->indexCount(), g->indexType(), g->indexData());
+            else
+                glDrawArrays(g->drawingMode(), 0, g->vertexCount());
             offset += g->sizeOfVertex() * g->vertexCount();
             e = e->nextInBatch;
         }
index 205b726..15c81f2 100644 (file)
@@ -6,6 +6,6 @@ varying mediump vec2 pos;
 void main(void)
 {
     lowp vec4 c = color;
-    c.xyz += pow(max(sin(pos.x + pos.y), 0.0), 2.0) * tweak.z * 0.1;
+    c.xyz += pow(max(sin(pos.x + pos.y), 0.0), 2.0) * tweak.z * 0.25;
     gl_FragColor = c;
 }