SFML community forums

Help => Graphics => Topic started by: xRiccardoC++ on September 24, 2018, 02:51:01 pm

Title: I'm having problems with drawing
Post by: xRiccardoC++ on September 24, 2018, 02:51:01 pm
I'm trying to use a sf::CircleShape as a brush because i want to make a paint remake or something like that. Because of that i don't clear the window every frame and this causes a really weird thing to happen.

#include <SFML/Graphics.hpp>

int main()
{
    using namespace sf;
    RenderWindow window(VideoMode(800, 600), "Title_String");
    window.setFramerateLimit(60);

    CircleShape brush(16.0f);
    brush.setFillColor(Color::Red);

    window.clear(Color::Black);

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

        if (Mouse::isButtonPressed(Mouse::Button::Left))
        {
            int mx = Mouse::getPosition(window).x;
            int my = Mouse::getPosition(window).y;
            brush.setPosition(mx - 8, my - 8);
            window.draw(brush);
        }

        window.display();
    }


    return 0;
}
Title: Re: I'm having problems with drawing
Post by: eXpl0it3r on September 24, 2018, 03:01:53 pm
So what's the issue?
Title: Re: I'm having problems with drawing
Post by: Laurent on September 24, 2018, 03:18:13 pm
You must always clear the window every frame. If you want a persistent pixel buffer, then use a sf::RenderTexture.