here look at this code, its from that tutorial I told you about how to use sf::Text.
#include <SFML/Graphics.hpp>
const float SCREENWIDTH = 800.0f;
const float SCREENHEIGHT = 600.0f;
int main()
{
sf::VideoMode VMode(SCREENWIDTH, SCREENHEIGHT, 32);
sf::RenderWindow Window(VMode, "SFML made easy 23");
sf::Vector2f fontPosition(SCREENWIDTH / 2.0f, SCREENHEIGHT / 2.0f);
sf::Font gameFont;
gameFont.loadFromFile("fonts/DoktorTerror.ttf");
sf::Text gameText("DoktorTerror", gameFont, 100);
gameText.setColor(sf::Color(255, 0, 0));
sf::FloatRect textRect = gameText.getLocalBounds();
gameText.setOrigin(textRect.width / 2, textRect.height / 2);
gameText.setPosition(fontPosition);
while (Window.isOpen())
{
sf::Event Event;
while(Window.pollEvent(Event))
{
switch (Event.type)
{
case sf::Event::Closed:
{
Window.close();
break;
}
case sf::Event::KeyPressed:
{
if (Event.key.code == sf::Keyboard::Escape)
Window.close();
break;
}
}
}
Window.clear();
Window.draw(gameText);
Window.display();
}
return 0;
}
change the font to your own compile it and run it. Then try and understand the code by modifying it for yourself. That is what I do when I want to understand something new.
I tried out your code...
It does not print text in middle of the screen...
I added lines to middle of the screen

, please make sure the code is correct before posting.
Tho, thanks for the helpful code.
#include <SFML/System.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/window.hpp>
#define SCREENWIDTH 800
#define SCREENHEIGHT 600
int main()
{
sf::VideoMode VMode(SCREENWIDTH, SCREENHEIGHT, 32);
sf::RenderWindow Window(VMode, "SFML made easy 23");
sf::Vector2f fontPosition(SCREENWIDTH / 2.0f, SCREENHEIGHT / 2.0f);
sf::Font gameFont;
gameFont.loadFromFile("Font.ttf");
sf::Text gameText("Hello", gameFont, 128);
gameText.setColor(sf::Color(255, 255, 255));
sf::FloatRect textRect = gameText.getLocalBounds();
gameText.setOrigin(textRect.width / 2, textRect.height / 2);
gameText.setPosition(fontPosition);
sf::RectangleShape RectW;
RectW.setSize(sf::Vector2f(SCREENWIDTH, 0.0));
RectW.setOutlineColor(sf::Color::Red);
RectW.setOutlineThickness(1);
RectW.setPosition(0, SCREENHEIGHT / 2);
sf::RectangleShape RectH;
RectH.setSize(sf::Vector2f(0.0, SCREENHEIGHT));
RectH.setOutlineColor(sf::Color::Red);
RectH.setOutlineThickness(1);
RectH.setPosition(SCREENWIDTH / 2, 0);
while (Window.isOpen())
{
sf::Event Event;
while(Window.pollEvent(Event))
{
switch (Event.type)
{
case sf::Event::Closed:
{
Window.close();
break;
}
case sf::Event::KeyPressed:
{
if (Event.key.code == sf::Keyboard::Escape)
Window.close();
break;
}
default:
break;
}
}
Window.clear();
Window.draw(gameText);
Window.draw(RectW);
Window.draw(RectH);
Window.display();
}
return 0;
}
Edited by BaneTrapper, 19 September 2012 - 06:41 AM.