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

Author Topic: Shape compile method  (Read 3287 times)

0 Members and 2 Guests are viewing this topic.

solgar

  • Newbie
  • *
  • Posts: 36
    • View Profile
Shape compile method
« on: November 25, 2009, 12:18:56 am »
Laurent, have you ever consider Shape::Compile() method to be public instead of private? I think, that Shape Compile() method should be public rather than private. If someone create his own shape it can be compiled only at render time. I think that user should have possibility to compile shape by himself. Plus in Java binding when I create predefined shapes I have to rewrite these static methods because those return object instead of pointer and these Shapes are not compiled (I cannot rewrite compile method because this method operate on private myPoints) - so there is difference between Java and C++ Shapes. I know that this is minor issue, but what do you think about it?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Shape compile method
« Reply #1 on: November 25, 2009, 12:47:36 am »
Quote
Laurent, have you ever consider Shape::Compile() method to be public instead of private?

No :)

Quote
I think, that Shape Compile() method should be public rather than private. If someone create his own shape it can be compiled only at render time. I think that user should have possibility to compile shape by himself

Hum, does it really matter? Is it done only one time anyway, it's not like if it was compiled before every Draw().

Quote
Plus in Java binding when I create predefined shapes I have to rewrite these static methods because those return object instead of pointer and these Shapes are not compiled (I cannot rewrite compile method because this method operate on private myPoints) - so there is difference between Java and C++ Shapes. I know that this is minor issue, but what do you think about it?

Sorry, I don't understand. Can you tell me more about this issue?
Laurent Gomila - SFML developer

solgar

  • Newbie
  • *
  • Posts: 36
    • View Profile
Shape compile method
« Reply #2 on: November 25, 2009, 09:24:16 pm »
Quote from: "Laurent"
Hum, does it really matter? Is it done only one time anyway, it's not like if it was compiled before every Draw().

Ok, you are right.

Quote from: "Laurent"
Sorry, I don't understand. Can you tell me more about this issue?

It is more difference than issue. Predefined shapes (like line or circle) in Java will be uncompiled - C++ predefined shapes are compiled during creation. They will be uncompiled because I have to rewrite these static methods (sf::Shape::Circle() and others) as jSFML native function because these methods return objects not created by "new" and because of that those objects cannot be deleted using "delete" - and native object is "deleted" when corresponding Java object is freed by GC. To rewrite those static methods i need to rewrite ComputeNormal() and Compile() because these are private and i cannot access them. I can rewrite ComputeNormal() but Compile() uses private myPoints which I cannot access. So i thought that it would be nice to have access to this method. But as you said compiling is not a performance killing task. Just a thought ;).

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Shape compile method
« Reply #3 on: November 25, 2009, 09:37:21 pm »
Well, so they are just like custom shapes, they will be compiled on first Draw.

And can't you just do something like this, instead of rewriting everything?
Code: [Select]
xxx Rectangle(...)
{
    sf::Shape* shape = new sf::Shape(sf::Shape::Rectangle(..));
    ...
}
Laurent Gomila - SFML developer

solgar

  • Newbie
  • *
  • Posts: 36
    • View Profile
Shape compile method
« Reply #4 on: November 25, 2009, 09:47:19 pm »
Quote from: "Laurent"
And can't you just do something like this, instead of rewriting everything?
Code: [Select]
xxx Rectangle(...)
{
    sf::Shape* shape = new sf::Shape(sf::Shape::Rectangle(..));
    ...
}


Of course I can. Stupid me. Thanks. :D

 

anything