SFML community forums

Help => Graphics => Topic started by: sknnywhiteman on December 10, 2011, 11:57:24 pm

Title: SF::Text problem..
Post by: sknnywhiteman on December 10, 2011, 11:57:24 pm
I'm making a multiplayer game right now, and everything is running smoothly, except one thing. I have everyone in a vector with my Player class, and one of the things is a name. I want the name to be displayed above the player, (which is right now just a green square, for testing purposes.) but it's not working. After some testing, I see what is happening. OpenGL is rendering the squares correctly, but the letters that are supposed to be there, are changing into green squares the size of the letters.. It seems like OpenGL and SFML are having conflicts on my screen. The actual drawing part of my game, minus the OpenGL stuff is here:

Code: [Select]
for(unsigned int a = 0; a < players.size(); a++){
        sf::Text Name;
        Name.SetString(players.at(a).getName());
        Name.SetColor(sf::Color::Black);
        Name.SetCharacterSize(14);
        Name.SetPosition(players.at(a).getX(), players.at(a).getY() - 20);
        Window->Draw(Name);
    }
    Window->Display();

(Notice that when I actually get rid of the Name.SetColor(sf::Color::Black) part, it changes it to green, but when I put that there, it changes the green square, and the text, to black.

EDIT:
Let me also clarify that when I get rid of the Window->Draw(Name) part, it also makes my game look normal. The drawing method is doing weird things to    the game.. :(
Title: SF::Text problem..
Post by: Laurent on December 11, 2011, 12:01:17 am
If you mix OpenGL and SFML, you must call some specific functions to make sure that the OpenGL states are not messed up.
Title: SF::Text problem..
Post by: sknnywhiteman on December 11, 2011, 12:31:08 am
Alright, Thanks! I figured it out, and now it draws perfect! I <3 SFML! =D