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

Author Topic: i guess it's about textures (loading circle problem)  (Read 2252 times)

0 Members and 2 Guests are viewing this topic.

paul.mihaita

  • Newbie
  • *
  • Posts: 16
    • View Profile
i guess it's about textures (loading circle problem)
« 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

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: i guess it's about textures (loading circle problem)
« Reply #1 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.

paul.mihaita

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: i guess it's about textures (loading circle problem)
« Reply #2 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

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: i guess it's about textures (loading circle problem)
« Reply #3 on: November 07, 2014, 09:01:09 pm »

paul.mihaita

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: i guess it's about textures (loading circle problem)
« Reply #4 on: November 07, 2014, 09:12:05 pm »
so i have to learn GLSL?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
AW: i guess it's about textures (loading circle problem)
« Reply #5 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
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: i guess it's about textures (loading circle problem)
« Reply #6 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.
Laurent Gomila - SFML developer