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

Author Topic: sf::circleshape gradient..  (Read 5027 times)

0 Members and 1 Guest are viewing this topic.

Roose Bolton of the Dreadfort

  • Full Member
  • ***
  • Posts: 113
  • Full-time Procrastinator, Part-time programmer.
    • View Profile
    • Personal Portfolio/Website/Blog
sf::circleshape gradient..
« on: November 30, 2012, 02:23:18 pm »
is it possible to have a fall off from the center off a circleshape? Say I want to use it as an overlay on top of a laser projectile, to give it some glow?
Trying so very hard to finish at-least one project.

Watch out for the RAII police, they will get you.

www.bantersaurus-games.com

gyscos

  • Jr. Member
  • **
  • Posts: 69
    • View Profile
Re: sf::circleshape gradient..
« Reply #1 on: November 30, 2012, 02:49:34 pm »
A quick search returned :
http://en.sfml-dev.org/forums/index.php?topic=3473.0

Looking at his source, the guy basically draws each pixel separately. This, along with the absence of gradient class, makes me think SFML does not support gradient.

I think you're better off using a gradient bitmap, possibly re-colorizing it ; or perhaps some shader could do the trick.

Foaly

  • Sr. Member
  • ****
  • Posts: 453
    • View Profile
Re: sf::circleshape gradient..
« Reply #2 on: November 30, 2012, 02:49:43 pm »
It is not possible directly with one of the classes SFML provides (ie SFML does not provied gradient classes). That means you have to implement it yourself. Take a look at the wiki though. This class might be helpful to you.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: sf::circleshape gradient..
« Reply #3 on: November 30, 2012, 03:11:48 pm »
Custom shapes with gradients can easily be created with a vertex array: if you assign different colors to the vertices that compose a primitive (ie. a triangle or quad), these colors are linearly interpolated by the graphics card to fill the primitive, and you get a smooth gradient with no effort.
Laurent Gomila - SFML developer

gyscos

  • Jr. Member
  • **
  • Posts: 69
    • View Profile
Re: sf::circleshape gradient..
« Reply #4 on: November 30, 2012, 03:22:38 pm »
But this doesn't work with circular gradients... :(
Maybe your could approximate it with many star-shaped triangles... :-S

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: sf::circleshape gradient..
« Reply #5 on: November 30, 2012, 04:10:13 pm »
Everything is made of triangles, even circles.
Laurent Gomila - SFML developer

gyscos

  • Jr. Member
  • **
  • Posts: 69
    • View Profile
Re: sf::circleshape gradient..
« Reply #6 on: November 30, 2012, 04:25:22 pm »
I was actually comparing it with the "ColorGradient" class posted above, which builded the gradient pixel-by-pixel. At this level, approximation is... acceptable :p

 

anything