I have two layers. Each layer has a primitive drawing in it with OpenGL as follows:
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 ) ); }
When I add these layers to the scene and set the Z-orders 1 and 2, I see that I can bring one primitive on top of the other and vice versa - when I exchange values ββof the Z order. Strange things start when I add a sprite sprite to one of these layers. If I add a sprite to a sprite, then the sprite lies on top of the primitive of this layer, and not just this layer. Even if the layer has a lower index Z, in any case, its sprite is on top of a primitive of a different level, and its primitive is below another primitive form - as expected. This is normal? How should I understand that? What if I want to draw primitives on top of all sprites?
EDIT:
I could manipulate their order, but not the drawing order, with the following:
CCDirector::getInstance()->setDepthTest(true); myLayer->setVertexZ(-1);
But I donβt understand why sprites in a layer with a lower Z-order are drawn later than primitives of a layer with a higher Z-order. In other words, it seems that all primitives from all layers are drawn in accordance with their order, the same thing is done for sprites.