title: Primitives and sprites Z index in Cocos2D-x 3.0 is not consistent?
body: <p>I have two layers. Each layer has a primitive drawing in it with OpenGL like this:</p>
  
  <pre><code>void Layer1::drawPolygon()
  {
      glLineWidth(1);
      DrawPrimitives::setDrawColor4B(255,255,255,255);
      DrawPrimitives::setPointSize(1);
  
      // Anti-Aliased
      glEnable(GL_LINE_SMOOTH);
  
      // filled poly
      glLineWidth(1);
      Point filledVertices[] = { Point(10,120), Point(50,120), Point(50,170), Point(25,200), Point(10,170) };
      DrawPrimitives::drawSolidPoly(filledVertices, 5, Color4F(0.5f, 0.5f, 1, 1 ) );
  }
  </code></pre>
  
  <p>When I addChild these layers to a scene and set Z orders 1 and 2, I see that I can bring one primitive on top of another and vice versa - when I exchange the Z order values. The strange things start when I addChild a sprite into one of these layers. If I addChild a sprite, then sprite lays on top of the primitive of that layer, and not only that layer. Even if the layer has smaller Z index, anyway its sprite is on top of other layer's primitive, while its primitive is below the other primitive shape - as was expected. Is this OK? How I should understand this? What if I want to draw primitives on top of all sprites?</p>
  
  <p>EDIT:</p>
  
  <p>I could manipulate their order, but not drawing order, with the following:</p>
  
  <pre><code>CCDirector::getInstance()-&gt;setDepthTest(true);
  myLayer-&gt;setVertexZ(-1);
  </code></pre>
  
  <p><strong>But I don't understand why sprites in a layer with smaller Z order are being drawn later than the primitives of the layer with bigger Z order. In other words, seems that all the primitives from all the layers is being drawn according to their order, then the same is being done for the sprites.</strong></p>