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

Pages: [1]
1
Graphics / Re: Learning sf::View ; can't display a single thing
« on: June 12, 2014, 03:33:33 pm »
Thanks for your answer, that worked.

I can't believe it was something so simple.

2
Graphics / Learning sf::View ; can't display a single thing
« on: June 12, 2014, 02:56:07 pm »
Hello everyone!

I tried using sf::View with the example of the tutorials but it seems that using sf::RenderWindow::setView doesn't work with me. If I use it, i can't display the red quare as I want in the following code, I only get a black window:


#include<SFML/Graphics.hpp>

int main()
{
        sf::RectangleShape rect (sf::Vector2f(100,100));
        rect.setFillColor(sf::Color::Red);

        sf::RenderWindow window (sf::VideoMode(1000,800), "ViewTest");

        // Initialize the view to a rectangle located at (100, 100) and with a size of 400x200
        sf::View view (sf::FloatRect(100, 100, 400, 200));

// Apply it
        window.setView(view);
// Render stuff

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

        return 0;
}
 

Pages: [1]
anything