Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: sf::Text not drawing to window at all  (Read 2886 times)

0 Members and 1 Guest are viewing this topic.

ElysianShadow

  • Newbie
  • *
  • Posts: 15
    • View Profile
    • Email
sf::Text not drawing to window at all
« on: September 16, 2013, 08:24:20 pm »
It's been a while since I've programmed, and so I though I'd get back into it. I noticed that SFML 2.1 came out so I downloaded it and decided to mess around a bit by doing some basic stuff like rendering text. However, for some reason the text does not draw at all in my window. Maybe someone can tell me what I'm doing wrong by taking a look at my code? Thanks



#include <SFML/Graphics.hpp>

int main()
{
        sf::RenderWindow window( sf::VideoMode( 800, 600 ), "Text Test" );
       
        sf::Event ev;

        sf::Text text;

        text.setString( "Test String" );
        text.setCharacterSize( 30 );
        text.setPosition( 400, 300 );
        text.setColor( sf::Color::Red );

        while ( window.isOpen() )
        {
                while ( window.pollEvent( ev ) )
                {
                        if ( ev.type == sf::Event::Closed )
                        {
                                window.close();
                        }

                        if ( sf::Keyboard::isKeyPressed( sf::Keyboard::Escape ) )
                        {
                                window.close();
                        }
                }

                window.clear();
                window.draw( text );
                window.display();
        }

        return 0;
}

 

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: sf::Text not drawing to window at all
« Reply #1 on: September 16, 2013, 08:30:19 pm »
Well how should it get displayed? You're not using any font and the default font has been removed for quite a while now. ;)

There's also other stuff that got changed slightly, thus I really advise you to read the official tutorials or at least skim through them, they hold a lot of important information. :)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

ElysianShadow

  • Newbie
  • *
  • Posts: 15
    • View Profile
    • Email
Re: sf::Text not drawing to window at all
« Reply #2 on: September 16, 2013, 08:39:07 pm »
Ohh that makes sense  ::) So I guess I have to put my own font file in there then? I'll be sure to look at the tutorials to see what else changed.

 

anything