SFML community forums

Help => Graphics => Topic started by: sfmlhelperguy on January 16, 2012, 06:22:44 pm

Title: Why wont my code for making text work?
Post by: sfmlhelperguy on January 16, 2012, 06:22:44 pm
Code: [Select]
#include<SFML/Graphics.hpp>
int main()
{
    sf::VideoMode Vmode(640,480,32);
    sf::RenderWindow Window(Vmode,"Hello There");
    sf::Text text("Something");
    while(Window.IsOpened())
    {
        sf::Event Event;
        while(Window.GetEvent(Event))
        {
            if(Event.Type == sf::Event::Closed || Event.Key.Code == sf::Key::Escape)
            {
                Window.Close();
            }
        }
            Window.Clear();
            Window.Draw(text);
            Window.Display();
    }
    return 0;
}

And here are the errors:

Quote
In function 'int main()':
line 6  error: 'Text' is not a member of 'sf'
line 6 error: expected ';' before 'text'
line 18  error: 'text' was not declared in this scope

I dont know what the problem is please help me
Title: Why wont my code for making text work?
Post by: Laurent on January 16, 2012, 06:48:05 pm
Are you sure that you have SFML 2.0 headers?
Title: Why wont my code for making text work?
Post by: sfmlhelperguy on January 16, 2012, 07:15:15 pm
Quote from: "Laurent"
Are you sure that you have SFML 2.0 headers?


Idk that's why im asking do I need another header or something because I have every dll I need in my program folder
Title: Why wont my code for making text work?
Post by: Laurent on January 16, 2012, 08:26:01 pm
Quote
Idk

Which version of SFML are you using? You must know that ;)
Title: Why wont my code for making text work?
Post by: sfmlhelperguy on January 16, 2012, 08:28:52 pm
Quote from: "Laurent"
Quote
Idk

Which version of SFML are you using? You must know that ;)

version 1.6 from what I see
Title: Why wont my code for making text work?
Post by: Laurent on January 16, 2012, 08:34:46 pm
The code in your first message is 2.0. You probably read the wrong documentation or tutorials.
Title: Why wont my code for making text work?
Post by: sfmlhelperguy on January 16, 2012, 11:07:42 pm
Quote from: "Laurent"
The code in your first message is 2.0. You probably read the wrong documentation or tutorials.

Oh really wow so then how do you make text in sfml 2.0?
Title: Why wont my code for making text work?
Post by: coolhome on January 17, 2012, 04:57:59 am
Take a look at the example at the link below. It has a perfect example.
http://sfml-dev.org/documentation/2.0/
Title: Why wont my code for making text work?
Post by: Tex Killer on January 17, 2012, 06:32:53 am
Quote from: "sfmlhelperguy"
Quote from: "Laurent"
The code in your first message is 2.0. You probably read the wrong documentation or tutorials.

Oh really wow so then how do you make text in sfml 2.0?


Your code is already designed for SFML2. If you want to know how to make text in SFML 1.6, that is the one you are using, check the 1.6 tutorials on SFML site.
Title: Why wont my code for making text work?
Post by: Nexus on January 17, 2012, 12:27:20 pm
And if you want to know how to realize it in SFML 2, you should first get SFML 2 ;)

Download it on the GitHub page. There's an installation tutorial that shows you how to build the library with CMake.