Skip to content

Instantly share code, notes, and snippets.

@eXpl0it3r
Created July 19, 2025 18:30
Show Gist options
  • Select an option

  • Save eXpl0it3r/ac3b0388dba853ae7f8c161359972493 to your computer and use it in GitHub Desktop.

Select an option

Save eXpl0it3r/ac3b0388dba853ae7f8c161359972493 to your computer and use it in GitHub Desktop.
AA with SFML Shape
#include <SFML/Graphics.hpp>
int main()
{
auto window = sf::RenderWindow(
sf::VideoMode({400u, 400u}),
"CMake SFML Project",
sf::Style::Default,
sf::State::Windowed,
sf::ContextSettings{24, 8, 8});
window.setFramerateLimit(144);
auto shape = sf::CircleShape(5.f, 3);
shape.setFillColor(sf::Color::Green);
shape.setPosition({10.f, 10.f});
shape.setOutlineColor(sf::Color::Red);
shape.setOutlineThickness(1.f);
auto renderTexture = sf::RenderTexture(
{400u, 400u},
sf::ContextSettings{24, 8, 8});
renderTexture.clear();
renderTexture.draw(shape);
renderTexture.display();
auto sprite = sf::Sprite(renderTexture.getTexture());
shape.setPosition({30.f, 10.f});
while (window.isOpen())
{
while (const std::optional event = window.pollEvent())
{
if (event->is<sf::Event::Closed>())
{
window.close();
}
}
window.clear();
window.draw(sprite);
window.draw(shape);
window.display();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment