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

Author Topic: Translate French pages into English.  (Read 16945 times)

0 Members and 1 Guest are viewing this topic.

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Translate French pages into English.
« Reply #15 on: November 27, 2008, 10:36:52 pm »
I just go through the source and I think I've understood the working of sf::Drawable.

If I'm right, we have only to define the Render  function and it will be all right. But I know nothing of OGL, so I cannot do anything. I can copy the sf::Sprite::Render but I don't know if there will be some thing to do (except remove the myIsFlipped[X/Y] adjustments). Or if it will be some changes in the future versions.
SFML / OS X developer

Imbue

  • Full Member
  • ***
  • Posts: 104
    • View Profile
Translate French pages into English.
« Reply #16 on: November 27, 2008, 11:20:59 pm »
Quote from: "Laurent"
Quote
I think this is a small problem with SFML's design. If you don't publicly inherit from the sprite, then how do you position, rotate, scale, and center?
then you feel like you should inherit from sf::Sprite to save writing a lot of one-line functions. So that's probably more a laziness issue than a design problem in SFML ;)
I agree that laziness is part of it. It's also part of what makes a pragmatic programmer. (Is it lazy to use SFML instead of OpenGL directly?) The bigger issue in my mind is the violation of the DRY principle. Having hundreds of one liner Get/Set functions for a myriad of classes is just asking for a maintenance nightmare, IMHO.

This is why using a public matrix class would be nice. Then the total issue of location and positioning could be made into one Get/Set function pair. There are other solutions though (e.g. virtual inheritance, templated interface classes).

Quote from: "Hiura"
If I'm right, we have only to define the Render function and it will be all right.
Yes, if you inherit from sf::Drawable, then anything you draw in the Render function is shifted. So just draw the sprite member in the Render function. That's it.

If you only inherit from sf::Drawable and have a sf::Sprite as a member, then you'll never need to move the member sprite at all. You just draw it in sf::Drawable::Render and SFML takes care of the rest. You don't need to know any OpenGL.

That does mean that you're paying twice for positioning (Animated's position and the sprite's position), but it should work as expected and give a clean interface.

Wizzard

  • Full Member
  • ***
  • Posts: 213
    • View Profile
Translate French pages into English.
« Reply #17 on: November 28, 2008, 07:28:53 am »
Quote from: "Imbue"
Having hundreds of one liner Get/Set functions for a myriad of classes is just asking for a maintenance nightmare, IMHO.

What if at some point in development a public variable needs to be limited to a certain range?

Imbue

  • Full Member
  • ***
  • Posts: 104
    • View Profile
Translate French pages into English.
« Reply #18 on: November 28, 2008, 09:33:07 am »
Quote from: "Wizzard"
What if at some point in development a public variable needs to be limited to a certain range?
Check/assert that's it's within range inside of the Set function? I guess that's a valid reason to avoid public inheritance of sf::Drawable.

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Translate French pages into English.
« Reply #19 on: November 28, 2008, 01:47:13 pm »
Quote from: "Imbue"
That does mean that you're paying twice for positioning (Animated's position and the sprite's position), but it should work as expected and give a clean interface.
Moreover there is a loop-like :
If we look at the function call stack in the next example we see a kind of redundancy with Draw call.
Code: [Select]
int main(...) {
  Animated a(...);
  // ...
  /* Main loop */ {
    // ...
    // Drawing.
    window.Clear();
    window.Draw(a);
    window.Display();
  }
  // ...
}

If Animated::Render is
Code: [Select]
/* ... */ {
  Target.Draw(my_own_sprite);
}

The stack will be :
Code: [Select]
main
  sf::RenderTarget::Draw            <-->        sf::Window::Draw
    sf::Drawable::Draw              <-->        Animated::Draw
      sf::Drawable::Render          <-->        Animated::Render
        sf::RenderTarget::Draw
          sf::Drawable::Draw        <-->        sf::Sprite::Draw
            sf::Drawable::Render    <-->        sf::Sprite::Render


It's twice or so longer than copying sf::Sprite::Render in Animated::Render :
Code: [Select]
main
  sf::RenderTarget::Draw            <-->        sf::Window::Draw
    sf::Drawable::Draw              <-->        Animated::Draw
      sf::Drawable::Render          <-->        Animated::Render


PS : to me, the stack size does not really matter, but the principle of these redundancy calls does.
SFML / OS X developer

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Translate French pages into English.
« Reply #20 on: November 28, 2008, 04:29:46 pm »
I had some free time today. I try and succeed the inheritance of sf::Drawable.

I've updated the wiki. Just have a look, and give me your feedback please.
SFML / OS X developer

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Translate French pages into English.
« Reply #21 on: November 30, 2008, 01:45:55 am »
The article is translated, with some changes.

Have fun.  :)

PS : I also added PausableClock article.
SFML / OS X developer

 

anything