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

Author Topic: [SOLVED]Text doesn't render at all  (Read 1348 times)

0 Members and 1 Guest are viewing this topic.

Tsirppa

  • Newbie
  • *
  • Posts: 3
    • View Profile
[SOLVED]Text doesn't render at all
« on: May 21, 2013, 08:45:30 pm »
Hey,

I'm working on this game and I have a simple state manager and game loop set up. It seems to function correctly in every other way except for the text rendering. I can play sounds, draw sprites and get events but the text doesn't render at all. Everthing else in Render() works fine and also the sound in Init() plays correctly. There is no error messages in the console. The font is in the same folder as the executable.

PS. Now that I made a topic, is there a reason why std::cout output appears in the console only after I close the program? I can output a lot of stuff in to cout but they only appear in the console I launched the application from only after I close it.

EDIT: Never loaded the font... Never do this at 3am, lesson learned

#include "MenuState.hpp"
#include <string>

void MenuState::Init() {

        font.loadFromFile("Arial.ttf");
        text.setString("TITLE!");
        text.setColor(sf::Color::Red);
        text.setCharacterSize(48);
        run = 0;
       
        sound.loadFromFile("nice_music.ogg");
        music.setBuffer(sound);
        music.play();
        tekstuuri.loadFromFile("cute_image.jpg");
        kuva.setTexture(tekstuuri);
}

void MenuState::Render(GameWindow* window) {
        window->clear(sf::Color::Blue);
        window->draw(kuva);
        window->draw(text);
        window->display();
}
 

#include "GameState.hpp"

class MenuState : public GameState {
        public:
                void Init();
                void CleanUp() {}

                void Pause() {}
                void Resume() {}

                void HandleEvents(GameWindow* window);
                void Update(GameWindow* window);
                void Render(GameWindow* window);

        private:
                sf::Font font;
                sf::Text text;
                int run;
               
                sf::SoundBuffer sound;
                sf::Sound music;
                sf::Sprite kuva;
                sf::Texture tekstuuri;
};
« Last Edit: May 21, 2013, 09:07:04 pm by Tsirppa »