Hello,
Thanks for your answer.
This is not exact, this might be an issue with my bad english.
Each rectangle you see is a separate entity wich is drawn in a class.
The vertex array has 16 Vertex, Background (white), another over background (black) and foreground (the 2 blue rectangles). i don't use a texture, only colors for vertex because i want the colors to change dynamically.
Text is drawn after the vertex.
for the 2 screenshots, you have a vertex version (the one with only 1 rectangle and no text on it plus 9 text with no rectangle. This is the bug i don't understand.
The screenshot with the rectangles that are drawn correctly is a non vertex array version and is drawn with rectangles.
The question : Why is my vertex not repeated correctly ? it should, because it is in a class. And why is the text not dramwn on it ? i did respect the good drawing order, text is drawn after the vertex array.
Note that if i create a single object of the class, the render is OK but i want it to be ok with multiple objects of the class.
Here is my vertex array code :
sf::Vertex vertex;
//vertex.position = sf::Vector2f(0, 0);
sf::VertexArray ch_quad(sf::Quads, 16);
vertex.color = sf::Color(255, 0, 0);
// Draws under quad supposed to be outline (draw order)
ch_quad[0].position = sf::Vector2f(10, 10);
ch_quad[1].position = sf::Vector2f(60, 10);
ch_quad[2].position = sf::Vector2f(60, 80);
ch_quad[3].position = sf::Vector2f(10, 80);
//insert here if / else for select color change
ch_quad[0].color = sf::Color(255, 255, 255, 50);
ch_quad[1].color = sf::Color(255, 255, 255, 50);
ch_quad[2].color = sf::Color(255, 255, 255, 50);
ch_quad[3].color = sf::Color(255, 255, 255, 50);
//draws the inside under quad ad sets the color (black)
ch_quad[4].position = sf::Vector2f(12,12);
ch_quad[5].position = sf::Vector2f(58,12);
ch_quad[6].position = sf::Vector2f(58,78);
ch_quad[7].position = sf::Vector2f(12,78);
ch_quad[4].color = sf::Color(0, 0, 0);
ch_quad[5].color = sf::Color(0, 0, 0);
ch_quad[6].color = sf::Color(0, 0, 0);
ch_quad[7].color = sf::Color(0, 0, 0);
//draws the channel strip
ch_quad[8].position = sf::Vector2f(12,12);
ch_quad[9].position = sf::Vector2f(58,12);
ch_quad[10].position = sf::Vector2f(58,27);
ch_quad[11].position = sf::Vector2f(12,27);
ch_quad[8].color = sf::Color(20, 30, 60);
ch_quad[9].color = sf::Color(20, 30, 60);
ch_quad[10].color = sf::Color(20, 30, 60);
ch_quad[11].color = sf::Color(20, 30, 60);
//draws the info strip
ch_quad[12].position = sf::Vector2f(12,60);
ch_quad[13].position = sf::Vector2f(58,60);
ch_quad[14].position = sf::Vector2f(58,78);
ch_quad[15].position = sf::Vector2f(12,78);
ch_quad[12].color = sf::Color(20, 30, 60);
ch_quad[13].color = sf::Color(20, 30, 60);
ch_quad[14].color = sf::Color(20, 30, 60);
ch_quad[15].color = sf::Color(20, 30, 60);
window.draw(ch_quad);
ch.setFont(font);
ch.setString(std::string("ch ") + chnbr.str());
ch.setCharacterSize(12);
ch.setLetterSpacing(0.3);
ch.setFillColor(sf::Color(255, 255, 255));
ch.setPosition(x+12, y+12); // Positionnement
window.draw(ch);
// Level Text
lvl.setFont(font);
lvl.setString(std::string("") + lvlstr.str());
lvl.setCharacterSize(18);
lvl.setLetterSpacing(0.3);
lvl.setFillColor(sf::Color(255, 255, 255));
lvl.setPosition(x+14, y+28); // Positionnement
window.draw(lvl);
}
Regards,