1
Window / Re: Fullscreen mode not working
« on: June 13, 2012, 03:02:54 pm »
Bump...
Anyone would have a brilliant idea to help me find the problem here ?
Anyone would have a brilliant idea to help me find the problem here ?
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.
#include <iostream>
#include <list>
#include <vector>
#include <SFML/Graphics.hpp>
using namespace std;
int main()
{
sf::Font font;
// Create a window and its view
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML Game");
// Load font
if (!font.LoadFromFile("comic.ttf"))
{
std::cout << "Could not load font." << std::endl;
return EXIT_FAILURE;
}
typedef std::list<std::string> StringList;
StringList stringList;
stringList.push_back("Test avec le texte");
stringList.push_back("éèàêzZaA ù");
stringList.push_back("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
stringList.push_back("abcdefghijklmnopqrstuvwxyz");
stringList.push_back("éèàê");
std::vector<sf::Text> textLines;
float lastLinePosition = 0.f;
for(std::list<std::string>::iterator line = stringList.begin(); line != stringList.end();
++ line)
{
sf::Text textLine(*line, font, 20);
textLine.SetColor(sf::Color::Red);
sf::Vector2f position;
position.x = 10.f;
position.y = std::floor(10.f + lastLinePosition + 0.5);
textLine.SetPosition(position);
textLines.push_back(textLine);
lastLinePosition += font.GetLineSpacing(20);
}
// Start the game loop
while (window.IsOpened())
{
// Process events
sf::Event event;
while (window.PollEvent(event))
{
// Close window : exit
if (event.Type == sf::Event::Closed)
window.Close();
}
// Clear screen
window.Clear();
for(std::vector<sf::Text>::iterator line = textLines.begin(); line != textLines.end();
++line)
{
window.Draw(*line);
}
// Update the window
window.Display();
}
return EXIT_SUCCESS;
}
void sf::View::Move( const Vector2f & offset )
member function. You cannot apply it directly on the View of the window. You must create another View on the side, which is a replicate of the window View, move it, and every time copy it back with SetView().
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML test");
sf::View camera(sf::FloatRect(0.f, 0.f, 800.f, 600.f));
camera.SetViewport(sf::FloatRect(0.f, 0.f, 1.f, 1.f));
window.SetView(camera);
//and then later on
camera.Move(20.f, 0.f);
//But nothing happen until I call
window.SetView(camera);