Yes, I'm sure that I'm not drawing it on a black background. If you took the time to check the additional information you would see that I'm able to see the first message without having characters missing >.>
If you took the time to actually post working compilable code that exhibits the problem...
but I actually
did take the time to check the additional information. Unfortunately it isn't clear.
What do you mean by first message? There are 6 messages at all times. If you can only see the top one which is printed in red (which one might assume you would call the "first" message), then it's a reasonable question to ask.
The following works perfectly fine for me (Note that if this is copy and pasted, you will likely need to change the font that's loaded:)
#include <SFML/Graphics.hpp>
#include <string>
sf::Text chatHistory[6] ;
sf::Font chatFont ;
void addChat(std::string username,int rights,std::string message) ;
void drawChat(sf::RenderWindow& window) ;
void chatInit() ;
std::string simulatedInput[] =
{
"Abracadabra!",
"I love m&ms!",
"No, skittles are the best.",
"Don't make me laugh.",
"Wouldn't dream of it.",
"I heard you dream about your mom.",
"Nah. It's your mom I dream about.",
"You must mean you have a nightmare.",
"Are you kidding? Your mom is hot.",
};
const unsigned inputSize = sizeof(simulatedInput) / sizeof(simulatedInput[0]) ;
unsigned inputIndex = 0 ;
int main()
{
sf::RenderWindow window( sf::VideoMode(800, 600), "sf::Text test" ) ;
chatInit() ;
while ( window.isOpen() )
{
sf::Event event ;
while ( window.pollEvent(event) )
{
if ( event.type == sf::Event::Closed )
window.close() ;
if ( event.type == sf::Event::KeyReleased && event.key.code == sf::Keyboard::Return )
{
addChat("cire", 0, simulatedInput[inputIndex]) ;
inputIndex = (inputIndex+1) % inputSize ;
}
}
window.clear(sf::Color::Blue) ;
drawChat(window) ;
window.display() ;
}
}
void drawChat(sf::RenderWindow& window) {
for(int i=0;i<=5;i++) {
window.draw(chatHistory[i]);
}
}
void chatInit() {
chatFont.loadFromFile("sketchflow.ttf");
for(int i=0;i<=5;i++) {
chatHistory[i].setFont(chatFont);
chatHistory[i].setColor(sf::Color::Black);
chatHistory[i].setCharacterSize(16);
chatHistory[i].setString("a");
chatHistory[i].setPosition(25,i*25+20);
}
addChat("SERVER",1,"Welcome to the server!");
}
void addChat(std::string username,int rights,std::string message) {
std::string chat;
if(rights>0) {
chat="[ADMIN] "+username+": "+message;
}
else {
chat=username+": "+message;
}
std::string tempChat[6];
for(int i=0;i<=5;i++) {
tempChat[i]=chatHistory[i].getString();
}
chatHistory[0].setColor(sf::Color::Red);
chatHistory[0].setString(chat);
chatHistory[1].setString(tempChat[0]);
chatHistory[2].setString(tempChat[1]);
chatHistory[3].setString(tempChat[2]);
chatHistory[4].setString(tempChat[3]);
chatHistory[5].setString(tempChat[4]);
}