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

Author Topic: Little sfml correction  (Read 5396 times)

0 Members and 1 Guest are viewing this topic.

Mr_Blame

  • Full Member
  • ***
  • Posts: 192
    • View Profile
    • Email
Little sfml correction
« on: September 24, 2015, 08:13:18 pm »
Hellow :)
After some hours of playing with SFML i noticed very strange api design, especially i am talking about sf::Sprite and sf::RectangleShape especially about setTexture method in Sprite it takes Texture reference but in Rectangleshape it reauires texture pointer. This prevnts rewriting code very fast because when you nedd to replace Sprite with Rectangleshape youmwill need to insert a lot of '&' symbols. If it is part of api style then sorry.

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Little sfml correction
« Reply #1 on: September 24, 2015, 08:21:43 pm »
This is indeed an odd little quirk but it's been mentioned here before and it's due to the fact that the sf::Shapes can be assigned a texture pointer of NULL as they can be used without textures whereas an sf::Sprite is not intended to be used without a texture.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Mr_Blame

  • Full Member
  • ***
  • Posts: 192
    • View Profile
    • Email
Re: Little sfml correction
« Reply #2 on: September 24, 2015, 08:31:49 pm »
i want to say that from tecnical side sprite can be without texture too :)
« Last Edit: September 24, 2015, 08:34:13 pm by Mr_Blame »

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Little sfml correction
« Reply #3 on: September 24, 2015, 08:40:17 pm »
If you have a decent IDE (qtcreator) or other halfway decent refactoring tools at your disposal (I use emacs and even there I have tools (like "M-x tags-query-replace" that gets stuff like this done in a jiffy), making such a change should take all of 30 seconds across your entire codebase.
I don't see the problem (except if you are editing code using Notepad or similar - but then you have other (bigger) problems).
« Last Edit: September 24, 2015, 08:44:10 pm by Jesper Juhl »

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Little sfml correction
« Reply #4 on: September 24, 2015, 08:43:58 pm »
i want to say that from tecnical side sprite can be without texture too :)
A sprite without a texture is just a rectangle  ::)

Sprites are designed to show parts of textures. That's what sprites are. If you want a rectangle, use a rectangle shape  :P
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Mr_Blame

  • Full Member
  • ***
  • Posts: 192
    • View Profile
    • Email
Re: Little sfml correction
« Reply #5 on: September 24, 2015, 08:51:11 pm »
Firstly, i think lience does not allows to modify SFML code
Secondly, rectangleshape as i remember weights more.
P.S. i am using visual studio 2015
« Last Edit: September 24, 2015, 08:59:11 pm by Mr_Blame »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Little sfml correction
« Reply #6 on: September 24, 2015, 09:08:56 pm »
Quote
This prevnts rewriting code very fast because when you nedd to replace Sprite with Rectangleshape youmwill need to insert a lot of '&' symbols.
The kind of thing you do everyday... ::)

Quote
Firstly, i think lience does not allows to modify SFML code
Have you actually read it? It's really short, and there's not such a limitation.

Quote
Secondly, rectangleshape as i remember weights more.
Slightly. 6 vertices / 2 triangles versus 6 vertices / 4 triangles.
Laurent Gomila - SFML developer

Mr_Blame

  • Full Member
  • ***
  • Posts: 192
    • View Profile
    • Email
Re: Little sfml correction
« Reply #7 on: September 25, 2015, 01:16:24 pm »
Quote
Firstly, i think lience does not allows to modify SFML code
Have you actually read it? It's really short, and there's not such a limitation
Yes? Sorry i just didnt understand it well. Need i to write something that says that have modified the code

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Little sfml correction
« Reply #8 on: September 25, 2015, 01:44:52 pm »
Only if you distribute your modifications.
Laurent Gomila - SFML developer

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: Little sfml correction
« Reply #9 on: September 25, 2015, 01:49:27 pm »
In short: "Do whatever you want, just don't pretend you've written it."

If you don't distribute the source, you don't have to document anything. And if you do, just track your changes in a repository (like a fork on GitHub) and you're fine.

Mr_Blame

  • Full Member
  • ***
  • Posts: 192
    • View Profile
    • Email
Re: Little sfml correction
« Reply #10 on: September 25, 2015, 02:31:44 pm »
can you please give me a look hoe this looks like(sorry I don't work with git much)

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Little sfml correction
« Reply #11 on: September 25, 2015, 03:12:58 pm »
Are you going to modify sfml? I would think you'd just modify your own code. At least that's what I hinted at would be simple if you use decent tools...

 

anything