SFML community forums

Help => Graphics => Topic started by: paul.mihaita on November 07, 2014, 07:53:07 pm

Title: i guess it's about textures (loading circle problem)
Post by: paul.mihaita on November 07, 2014, 07:53:07 pm
Hey guys. I am making an Space invaders type of game, and i want to make some power-ups.I want to make an animation for that, like an loading circle so that user can know how much time left he has to take the power-up.I know how to do that by sprites(5-6 sprites with 1/5-1/6 of circle and just display the images after a time) but i want to do it smoothly, and by that i mean to calculate the % of circle to fill based on the time i want.I guess it can be done with texture updating...but i don't know
Title: Re: i guess it's about textures (loading circle problem)
Post by: Ixrec on November 07, 2014, 08:11:53 pm
Updating the texture directly is probably not the best idea.  I believe the "best" way of implementing this (in terms of performance and flexibility) is to draw the circle using a shader that takes a number like 1/5 as input and then only "lets through" those pixels that are in the first 1/5 of the circle.
Title: Re: i guess it's about textures (loading circle problem)
Post by: paul.mihaita on November 07, 2014, 08:52:58 pm
and how i can do that shader? i'm new into this kind of program, i've heard about but never did it
Title: Re: i guess it's about textures (loading circle problem)
Post by: Ixrec on November 07, 2014, 09:01:09 pm
The basics are in the tutorials: http://sfml-dev.org/tutorials/2.1/graphics-shader.php
Title: Re: i guess it's about textures (loading circle problem)
Post by: paul.mihaita on November 07, 2014, 09:12:05 pm
so i have to learn GLSL?
Title: AW: i guess it's about textures (loading circle problem)
Post by: eXpl0it3r on November 07, 2014, 09:18:35 pm
If you want to use shaders, then yes.

There should also be ways to achieve such an effect with triangle fans or a special implementation of circle shape.

Also this question has been asked before, search the forum a bit or even google for it, you're not the only one who wanted that. :D
Title: Re: i guess it's about textures (loading circle problem)
Post by: Laurent on November 07, 2014, 10:17:11 pm
The triangle fan will be the easiest and most efficient solution, yes. More details are given in the other topic, if you can find it.