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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Tsirppa

Pages: [1]
1
Graphics / [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;
};

2
General / Re: Can't get SFML working with OS X
« on: May 20, 2013, 10:45:19 am »
You need to tell clang you're using libc++ (the implementation of the standard library that supports C++11). The default implementation of the standard library doesn't support C++11, so SFML was built with libc++. By not specifying libc++ in your building options, clang is using the other implementation, so you get conflicts that result in weird errors (because SFML wants one, but you're using the other).

Add -stdlib=libc++ to you call to clang++
Well that was simple. Thanks! Now off to learning SFML, a lot of stuff to cover :P

3
General / Can't get SFML working with OS X
« on: May 20, 2013, 06:50:03 am »
Hey,

I downloaded SFML 2.0 for OS X with clang for C++11. I installed the 'lib' and the 'include' in my '/usr/local/' folder. After that, I installed the dependencies from the 'extlibs'-folder to my '/Library/Frameworks'. SFML should be correctly installed now? However, I tried the sample program given at http://sfml-dev.org/documentation/2.0/ but I can't get it to compile. Any idea what's going on?

Here's the compile log:
Code: [Select]
clang++ -c main.cpp
clang++ main.o -o sfmltesti -lsfml-graphics -lsfml-window -lsfml-system -lsfml-audio
Undefined symbols for architecture x86_64:
  "sf::Font::loadFromFile(std::string const&)", referenced from:
      _main in main.o
  "sf::Music::openFromFile(std::string const&)", referenced from:
      _main in main.o
  "sf::String::String(char const*, std::locale const&)", referenced from:
      _main in main.o
  "sf::Texture::loadFromFile(std::string const&, sf::Rect<int> const&)", referenced from:
      _main in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [all] Error 1
[Finished in 0.3s with exit code 2]

Pages: [1]