Voici mon code! J'ai réussi a corriger la position, cependant je sais pas si c'est la bonne méthode pour faire ce genre de choses? Merci à bientôt.
#include <SFML\Graphics.hpp>
#include <SFML\System.hpp>
#include <SFML\Window.hpp>
#include <iostream>
#include <sstream>
#pragma region Variables
sf::RenderWindow window; // set window
sf::Text fps_txt; // set fps inf
sf::Text info_txt;
sf::Font font; // set font
#pragma endregion Variables
const sf::Vector2f WINDOW_SIZE(1280, 720); // window size
int FRAMELIMIT = 60; // frames limit
float FRAMECOUNT = 0; // frames count
int main()
{
window.create(sf::VideoMode(WINDOW_SIZE.x, WINDOW_SIZE.y), "Ufact v1.0", sf::Style::Default); // create the window
window.setFramerateLimit(FRAMELIMIT); // set frames limit for reduce the CPU load
sf::Clock clock; // create clock
if (!font.loadFromFile("fonts/arial.ttf"))
{
// error...
}
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
{
window.close(); // close the window
}
break;
}
sf::Time time = clock.getElapsedTime();
FRAMECOUNT = 1.f / time.asSeconds();
clock.restart().asSeconds(); // restart clock
std::ostringstream fps; // string buffer to convert numbers to string
fps << "Frames : " << FRAMECOUNT; // put float into string buffer
// fps txt
fps_txt.setFont(font); // set font to txt
fps_txt.setCharacterSize(12); // set size
fps_txt.setPosition(5, 5); // set position of txt
fps_txt.setString(fps.str()); //ss.str() converts the string buffer into a regular string
// info txt
info_txt.setFont(font);
info_txt.setCharacterSize(12);
info_txt.setPosition(1175, 700);
info_txt.setString("Ufact v1.0 ©2017");
sf::Vertex ly[] =
{
sf::Vertex(sf::Vector2f(WINDOW_SIZE.x / 2, 0), sf::Color::Blue),
sf::Vertex(sf::Vector2f(WINDOW_SIZE.x / 2, WINDOW_SIZE.y), sf::Color::Blue)
};
sf::Vertex lx[] =
{
sf::Vertex(sf::Vector2f(WINDOW_SIZE.x, WINDOW_SIZE.y / 2), sf::Color::Red),
sf::Vertex(sf::Vector2f(0, WINDOW_SIZE.y / 2),sf::Color::Red)
};
window.draw(lx, 2, sf::Lines);
window.draw(ly, 2, sf::Lines);
window.draw(fps_txt);
window.draw(info_txt);
window.display();
window.clear();
}
return 0;
}