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

Author Topic: Problem with Blending?  (Read 2369 times)

0 Members and 1 Guest are viewing this topic.

Austech

  • Newbie
  • *
  • Posts: 23
    • View Profile
Problem with Blending?
« on: August 22, 2010, 01:43:41 pm »
Since I found out about blending in sfml. I decided to put it to the test with a little program that represents a flashlight.

Code: [Select]
while(1)
{
while(window.GetEvent(event))
{
if(event.Type == sf::Event::Closed)
{
window.Close();
}
}
window.Clear();

sf::Shape hidden = sf::Shape::Rectangle(0,0,100,100,sf::Color(255,0,0,0));
hidden.SetBlendMode(sf::Blend::Add);

sf::Shape circ = sf::Shape::Circle(window.GetInput().GetMouseX(),window.GetInput().GetMouseY(), 40,sf::Color(255,255,255,100));
window.Draw(circ);
window.Draw(hidden);
window.Display();
}


I thought the Blend Mode, Add, would add the alpha of the hidden box, (0), to the alpha of the circle, (100). Wouldn't it?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Problem with Blending?
« Reply #1 on: August 22, 2010, 09:25:23 pm »
A blend operation is between a source (the shape, the hidden box) and a target (the window), not between two separate sources. So, each call to Draw adds the alpha of the corresponding shape to the alpha of the window, which is 255.

And I must say that I have no idea about what effect you're trying to achieve :D
Laurent Gomila - SFML developer

Austech

  • Newbie
  • *
  • Posts: 23
    • View Profile
Problem with Blending?
« Reply #2 on: August 22, 2010, 09:55:51 pm »
Quote from: "Laurent"
A blend operation is between a source (the shape, the hidden box) and a target (the window), not between two separate sources. So, each call to Draw adds the alpha of the corresponding shape to the alpha of the window, which is 255.

And I must say that I have no idea about what effect you're trying to achieve :D


Oh my bad. What I was trying to simulate was when the circle was over the shape (hidden), it would show the part of the shape in which the circle is over.

 

anything