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

Author Topic: Inherit from sf::Shape (sf::CircleShape)  (Read 7752 times)

0 Members and 3 Guests are viewing this topic.

Composer3

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: Inherit from sf::Shape (sf::CircleShape)
« Reply #15 on: February 12, 2020, 07:24:48 pm »
Just checked the docs again, and you're right, it does say "The texture rect is useful when you don't want to display the whole texture, but rather a part of it. By default, the texture rect covers the entire texture."

I first found out about setTextureRect in the shapes tutorial. Pasted from the section about texturing shapes:
"Shapes can also be textured, just like sprites. To specify a part of the texture to be mapped to the shape, you must use the setTextureRect function. It takes the texture rectangle to map to the bounding rectangle of the shape. This method doesn't offer maximum flexibility, but it is much easier to use than individually setting the texture coordinates of each point of the shape."

This is what had me confused: nowhere in the tutorial did it say that the default is to cover the entire section. Nor does it use a code example that does not use setTextureRect. I suppose if I had read it again I may have noticed that the language does sort of imply that setTextureRect is only necessary if you want to display a portion, but only if I had reason to believe so already. From what it said, I thought that setTextureRect was a mandatory function used to position the texture on the sf::Shape. I am sure that I am not the only one who was confused by this from the tutorial.
As soon as you expect a program to be perfect, it stops being good enough.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Inherit from sf::Shape (sf::CircleShape)
« Reply #16 on: February 12, 2020, 08:42:37 pm »
Tutorials are only meant to give an overview. The documentation is the only accurate and reliable source of information when it comes to use a function.

Whatever the tutorial says, the fact is that you called a function without fully understanding how to use it; if you did, you would have passed the right rectangle value and your code would have worked anyway ;)
Laurent Gomila - SFML developer

Composer3

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: Inherit from sf::Shape (sf::CircleShape)
« Reply #17 on: February 12, 2020, 08:56:28 pm »
Even the documentation does not explain what each parameter does in the function. It is missing a vital piece of information - it says what it does, and why you might want to do it, but it does not tell you how to do it. How am I to understand how to correctly use a function if even the docs don't explain it? There are no examples, and the tutorial, which is the only place I've seen an actual call to the function, doesn't explain what the parameters are doing.
As soon as you expect a program to be perfect, it stops being good enough.

Composer3

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: Inherit from sf::Shape (sf::CircleShape)
« Reply #18 on: February 12, 2020, 09:03:16 pm »
Btw, I didn't fully understand what it was supposed to do until G.'s post. I thought it was the other way around: if I wanted to apply a 400*400 texture to a 300*300 sprite, then I would need a texture rect of 300*300. In other words, what the docs didn't explain was whether the intRect was in local or global coordinates and if local, then of the texture or of the sprite.
As soon as you expect a program to be perfect, it stops being good enough.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Inherit from sf::Shape (sf::CircleShape)
« Reply #19 on: February 12, 2020, 09:20:39 pm »
Quote
I thought it was the other way around: if I wanted to apply a 400*400 texture to a 300*300 sprite, then I would need a texture rect of 300*300
There's no way you can understand this from that:

Quote from: the API documentation
Set the sub-rectangle of the texture that the shape will display.

The texture rect is useful when you don't want to display the whole texture, but rather a part of it. By default, the texture rect covers the entire texture.

But anyway, I don't really like to argue like this. You spotted a lack in the tutorials, and it's true that we could easily improve it to avoid such a confusion. If you want to submit a PR for this (only the english part of course, we take care of the french translation), you're more than welcome :)
Laurent Gomila - SFML developer

Composer3

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: Inherit from sf::Shape (sf::CircleShape)
« Reply #20 on: February 12, 2020, 09:29:19 pm »
Quote
I thought it was the other way around: if I wanted to apply a 400*400 texture to a 300*300 sprite, then I would need a texture rect of 300*300
There's no way you can understand this from that:

Quote from: the API documentation
Set the sub-rectangle of the texture that the shape will display.

The texture rect is useful when you don't want to display the whole texture, but rather a part of it. By default, the texture rect covers the entire texture.

I didn't understand that from the docs, I understood that from the tutorial. The docs didn't help any, because I was just kinda skimming over them, but they were not the source of the confusion.

But anyway, I don't really like to argue like this. You spotted a lack in the tutorials, and it's true that we could easily improve it to avoid such a confusion. If you want to submit a PR for this (only the english part of course, we take care of the french translation), you're more than welcome :)

How do I do this?
As soon as you expect a program to be perfect, it stops being good enough.

Composer3

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: Inherit from sf::Shape (sf::CircleShape)
« Reply #21 on: February 12, 2020, 09:42:45 pm »
Also, I believe beyond a shadow of a doubt that it was not my fault that I was confused by the tutorial. However, I do admit that it may have been my fault that reading the docs did not correct my confusion, or at least point me in the right direction.
As soon as you expect a program to be perfect, it stops being good enough.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Inherit from sf::Shape (sf::CircleShape)
« Reply #22 on: February 13, 2020, 07:59:42 am »
Quote
How do I do this?
There's a github repository for the website. You can clone/fork it and submit PRs, like you would do with the SFML repo.

If you don't want to do that, you can just open a new issue and describe your proposed improvement.
Laurent Gomila - SFML developer

Composer3

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: Inherit from sf::Shape (sf::CircleShape)
« Reply #23 on: February 13, 2020, 07:35:57 pm »
Thanks.

Sorry, I know almost nothing about GitHub. I have an account but the only thing I use it for is creating/replying to issues :). How exactly do I create a PR? If it's too complicated to explain on this issue, could you point me to a tutorial on a different site?
As soon as you expect a program to be perfect, it stops being good enough.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Inherit from sf::Shape (sf::CircleShape)
« Reply #24 on: February 14, 2020, 07:51:29 am »
I'm sure you can find many tutorials by searching "create github pull request", the first link should even be the official github tutorial :)

I can't give you more details, as I never make PRs myself ;D
Laurent Gomila - SFML developer

 

anything