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

Author Topic: 2.6.2 to 3.0.0 sf::Vertex AchseV[]  (Read 420 times)

0 Members and 1 Guest are viewing this topic.

HeinzK

  • Jr. Member
  • **
  • Posts: 57
    • View Profile
    • ZwiAner
    • Email
2.6.2 to 3.0.0 sf::Vertex AchseV[]
« on: January 20, 2025, 03:17:52 pm »
 After I edited some 100 places with sf::Vertex ...
 //> 2.6.2
 k_Vertexs.push_back
           (
             sf::Vertex
                 (
                   sf::Vector2f(fX1, fY1),
                   CoZ
                 )
           );

 //> 3.0.0
 k_Vertexs.push_back
           (
             {
               sf::Vector2f(fX1, fY1),
               CoZ
             }
           );

... I hope this is correct? (Unfortunately, I can only test it again once everything has been 'translated'!),

I have come across a problem!

//> 2.6.2
sf::Vertex AchseV[] =
{
  sf::Vertex(sf::Vector2f(0.0, 0.0)),
  sf::Vertex(sf::Vector2f(0.0, 0.0))
};

//> 3.0.0
sf::Vertex AchseV[] =
{
  sf::Vector2f({0.0, 0.0}),
  sf::Vector2f({0.0, 0.0})
};
...
AchseV[0].position.x = (float)k_pMaus->GetlMausX();
pWindow->draw(AchseV, 2, sf::Lines);
...

How will this be solved in 3.0.0?

Code:
 
(click to show/hide)
« Last Edit: January 20, 2025, 03:57:10 pm by eXpl0it3r »
The trees, that obstruct the view on the forest, can be allowed to fall! (Die Bäume, die die Sicht auf einen Wald versperren, dürfen gefällt werden!)

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11110
    • View Profile
    • development blog
    • Email
Re: 2.6.2 to 3.0.0 sf::Vertex AchseV[]
« Reply #1 on: January 21, 2025, 10:16:04 am »
You can use aggregate initialization like this:

sf::Vertex AchseV[] =
{
  { sf::Vector2f(0.f, 0.f) },
  { sf::Vector2f(0.f, 0.f) }
};
Official FAQ: https://www.sfml-dev.org/faq/
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

HeinzK

  • Jr. Member
  • **
  • Posts: 57
    • View Profile
    • ZwiAner
    • Email
Re: 2.6.2 to 3.0.0 sf::Vertex AchseV[]
« Reply #2 on: January 21, 2025, 10:20:00 am »
Thank you very much, but wy not:
sf::Vertex AchseV[] =
{
  { sf::Vector2f({0.0, 0.0}) },
  { sf::Vector2f({0.0, 0.0}) }
};
« Last Edit: January 21, 2025, 10:24:03 am by HeinzK »
The trees, that obstruct the view on the forest, can be allowed to fall! (Die Bäume, die die Sicht auf einen Wald versperren, dürfen gefällt werden!)

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11110
    • View Profile
    • development blog
    • Email
Re: 2.6.2 to 3.0.0 sf::Vertex AchseV[]
« Reply #3 on: January 21, 2025, 10:37:46 am »
The inner {0.0, 0.0} will create a sf::Vector2<double> instance, which you then pass to the sf::Vector2f constructor. The compiler will likely optimize this away, but it's completely redundant.

So it's better to directly call the sf::Vector2f constructor with float values.
Official FAQ: https://www.sfml-dev.org/faq/
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

HeinzK

  • Jr. Member
  • **
  • Posts: 57
    • View Profile
    • ZwiAner
    • Email
Re: 2.6.2 to 3.0.0 sf::Vertex AchseV[]
« Reply #4 on: January 21, 2025, 10:50:08 am »
Understood.
My next problem.
2.6.2
sf::IntRect View = pWindow->getViewport(pWindow->getView());
AxisV[0].position.y = (float)(View.top + View.height);
3.0.0 there is now sf::View ... so:
sf::IntRect Vw = pWindow->getViewport(pWindow->getView());
AxisV[0].position.y = (float)(Vw.top + Vw.height);
.. but this does not work (.top und .height not available)
.. please help.
The trees, that obstruct the view on the forest, can be allowed to fall! (Die Bäume, die die Sicht auf einen Wald versperren, dürfen gefällt werden!)

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11110
    • View Profile
    • development blog
    • Email
Re: 2.6.2 to 3.0.0 sf::Vertex AchseV[]
« Reply #5 on: January 21, 2025, 11:13:52 am »
You can check the migration guide for all the changes needed.

sf::Rect has changed and now offers position and size as properties, size contains the x and y properties
« Last Edit: January 21, 2025, 02:37:33 pm by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq/
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

HeinzK

  • Jr. Member
  • **
  • Posts: 57
    • View Profile
    • ZwiAner
    • Email
Re: 2.6.2 to 3.0.0 sf::Vertex AchseV[]
« Reply #6 on: January 21, 2025, 02:02:58 pm »
I work with the migration guide. I anderstood:
v2: sf::IntRect rect(250, 400, 50, 100);
v3: sf::IntRect rect({250, 400}, {50, 100});
.. but I don't find the 'width' and 'height' properties.

The trees, that obstruct the view on the forest, can be allowed to fall! (Die Bäume, die die Sicht auf einen Wald versperren, dürfen gefällt werden!)

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11110
    • View Profile
    • development blog
    • Email
Re: 2.6.2 to 3.0.0 sf::Vertex AchseV[]
« Reply #7 on: January 21, 2025, 02:38:13 pm »
Sorry, I derped size and position are vector2 instances, so you get x and y

width = size.x
height = size.y
Official FAQ: https://www.sfml-dev.org/faq/
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything