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

Author Topic: sf::Shape Compile() is private.  (Read 2547 times)

0 Members and 1 Guest are viewing this topic.

The_Cleaner

  • Newbie
  • *
  • Posts: 9
    • View Profile
sf::Shape Compile() is private.
« on: November 27, 2011, 05:21:28 pm »
Laurent,
I was wanting to make a few shapes using the sf::Shape as the base class, but since the Compile() is private and not protected, this is not as clean as it could be. While I know I can (and already have successfully) create a function which creates the shapes I want, and I could even derive since you put in the check to compile before rendering, I assume that since you explicitly call Compile() in your static functions, there is a benefit of doing that over letting the render function handle it automatically. That said, was there a reason you made Compile() private?

Love SFML by the way, keep up the excellent work!  
thanks,
Ben (AKA The_Cleaner)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
sf::Shape Compile() is private.
« Reply #1 on: November 27, 2011, 05:33:29 pm »
Quote
I assume that since you explicitly call Compile() in your static functions, there is a benefit of doing that over letting the render function handle it automatically

Not really. The only difference is that it is compiled during its creation rather than the first time you draw it.
Laurent Gomila - SFML developer

The_Cleaner

  • Newbie
  • *
  • Posts: 9
    • View Profile
sf::Shape Compile() is private.
« Reply #2 on: November 27, 2011, 05:48:48 pm »
Thanks for the fast reply Laurent. So that said, compiling at creation if possible would generally be preferred, so why not make Compile() protected, or even public for that matter! Not sure if I'm missing something about the class... Are we meant not to derive from sf::Shape?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
sf::Shape Compile() is private.
« Reply #3 on: November 27, 2011, 05:58:38 pm »
Well...

Is there an actual problem with that? No
Will the sf::Shape class be totally different in a few days? Yes
So should we really start a long discussion about this Compile() function now? No ;)
Laurent Gomila - SFML developer

The_Cleaner

  • Newbie
  • *
  • Posts: 9
    • View Profile
sf::Shape Compile() is private.
« Reply #4 on: November 27, 2011, 06:23:43 pm »
Fair enough...

I know SFML2 is still in development and many things will change. So one final question on the "future plans" for sf::Shape.

You just said the class will likely be changed soon, does that mean you will be likely adding more static shape functions, or is that outside the scope of what you are trying to provide in the sf::Shape class?

Or are you just referring to the simple nature of using something that is in development, and that it is simply in flux!

Again thanks for your time, I really like the API, so not really trying to give you a hard time or anything!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
sf::Shape Compile() is private.
« Reply #5 on: November 27, 2011, 07:37:47 pm »
In fact the new API is ready, and will be pushed soon. So I can already tell you about the details.

I've changed my strategy for shapes: there's now a base class (sf::Shape) and one derived class for each type of shape: circle, rectangle, convex polygon, star, ... All the complicated code is implemented in the base class, derived ones simply provide the list of points, and hide all this stuff behind a dedicated API (Circle::SetRadius, Rectangle::SetSize, ...).
Laurent Gomila - SFML developer

The_Cleaner

  • Newbie
  • *
  • Posts: 9
    • View Profile
sf::Shape Compile() is private.
« Reply #6 on: November 27, 2011, 07:57:18 pm »
Excellent!
I look forward to the release then.
Thanks again for the info.

OniLinkPlus

  • Hero Member
  • *****
  • Posts: 500
    • View Profile
sf::Shape Compile() is private.
« Reply #7 on: November 27, 2011, 09:34:23 pm »
Quote from: "Laurent"
In fact the new API is ready, and will be pushed soon. So I can already tell you about the details.

I've changed my strategy for shapes: there's now a base class (sf::Shape) and one derived class for each type of shape: circle, rectangle, convex polygon, star, ... All the complicated code is implemented in the base class, derived ones simply provide the list of points, and hide all this stuff behind a dedicated API (Circle::SetRadius, Rectangle::SetSize, ...).
HUZZAH!
I use the latest build of SFML2

bananu7

  • Newbie
  • *
  • Posts: 25
    • View Profile
sf::Shape Compile() is private.
« Reply #8 on: December 01, 2011, 05:19:25 pm »
finally...