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 - Star

Pages: [1]
1
Window / Re: How to display numbers in a window?
« on: March 27, 2015, 12:15:32 am »
The problem was in the font, but not in the location of the font.
Font does not contain numbers, so I guess there was no picture.

Thank you for your participation, dejan.geci, Laurent, eXpl0it3r

2
Window / How to display numbers in a window?
« on: March 26, 2015, 12:56:46 pm »
Hi everyone!

I am using SFML 2.2 and VS 13.
My OS: Win 8.1 x64

I am trying to display some numbers in a window. But my window still stay black
I am trying it with the following code
#include <string>
#include <sstream>
#include <iostream>
#include <SFML/Graphics.hpp>

int main()
{
        sf::RenderWindow window(sf::VideoMode(800, 600, 32), "Test", sf::Style::Default);

        int number = 1000;

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

                sf::Font font;
                if (!font.loadFromFile("font.ttf"))
                {
                        std::cerr << "error";
                }

                std::ostringstream oss;
                oss << number;

                sf::Text text;
                text.setFont(font);
                text.setString(oss.str());
                text.setColor(sf::Color::Red);
                text.setPosition(400, 300);

                window.clear();

                window.draw(text);

                window.display();
        }

        return 0;
}
 

I am sending this code my friends and he work perfect!
What is my problem?

P.S. Sorry for my english, but i hope you understand me!

Pages: [1]