Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Masking/Erasing Portions of a shape  (Read 1441 times)

0 Members and 1 Guest are viewing this topic.

veraFWC

  • Newbie
  • *
  • Posts: 1
    • View Profile
Masking/Erasing Portions of a shape
« on: February 18, 2016, 09:50:14 am »
Good Evening,

I'm almost dirt new to SFML, but I couldn't find any mention of what I wanted to do in the documentation, So I though I'd put it out here to see if it can actually be done.

I'm trying to used an object (preferably an sf::drawable derived object) to hide part of another. Specifically, I have a circle, and I'm trying to hide a sector of the circle, so that only the background is visible.

Intuitive I tried placing a transparent triangle over the circle, but it simply rendered an invisible triangle over top of the triangle as it was ment to. Is their any way I can subtract one shape from another, or erase part of a shape before drawing it?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Masking/Erasing Portions of a shape
« Reply #1 on: February 18, 2016, 02:18:33 pm »
Rendering masks are still to be implemented (see issue #1 on github), but there's a workaround. Draw your background on a sf::RenderTexture, then draw the mask with a transparent color (anything with alpha = 0) on top of it with the sf::BlendNone blending mode. The result is a masked image that you can then draw on your regular scene.
Laurent Gomila - SFML developer