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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Keith99

Pages: [1]
1
Feature requests / Re: add setPoints
« on: June 26, 2018, 10:18:33 pm »
Good point yes, I had forgotten SFML shape class can be user extended.

2
Feature requests / add setPoints
« on: June 26, 2018, 01:32:16 pm »
Hi, I hope this is the right place for this. I would like to request a small addition to the ConvexShape:

Add a setPoints function (with an s at the end) to it.

Currently I am doing some experiments involving drawing convex shapes with 1000s of points and calling addPoint for each one kills performance (I think due to SFML updating internal data each time a point is added). All I would like is:

void ConvexShape::setPoints(std::vector<Vector2f> points)
{
     m_points=points;
     Update();
}

(points could be passed by reference but there may be a case for by value if std::move can be used?)

thanks

3
Graphics / Re: sf::Text setString slow
« on: July 23, 2016, 02:40:34 pm »
Just for completeness my tests in release mode show sf:String copying to be 20 times slower than std::string

4
Graphics / Re: sf::Text setString slow
« on: July 23, 2016, 02:30:23 pm »
Since I am comparing two things and not interested in absolute values it makes no difference. I have profiled in release mode and while the absolute numbers are naturally lower the scale of slowdown is identical.

By the way searching this forum I have found other posts from the past where people have obviously suffered the same issue with sf::Text (although sometimes without realising what it is). I am very busy but hope to explore this further and see if I can tweak the SFML code to reduce the problem and then suggest a possible fix.

5
Graphics / Re: sf::Text setString slow
« on: July 21, 2016, 04:00:28 pm »
OK I created a basic test case just passing a vector of std::string into a function that converted it to a sf::string. For 1 million items:

With project set to use Unicode:
Copying to a std::string took 4.9 seconds
Copying to a sf::String took 40.3 seconds

With project set to use Multibyte:
Copying to a std::string took 5.1 seconds
Copying to a sf::String took 40.3 seconds

Note: done in debug mode so no optimization but of course I have not factored in things like caching etc.

void SpeedTestToSFString(const std::vector<std::string> &lotsOfStrings)
{
   // Convert to sf::String
   for (auto &p : lotsOfStrings)
   {
      sf::String sfString(p);      
   }   
}

I will do another test but next time using the text output but it will need to wait until I have a minute

6
Graphics / Re: sf::Text setString slow
« on: July 21, 2016, 03:26:30 pm »
By the way if I drill down using a profiler I see that sf::Text::setString() takes 21.9% of my program's time
Within that String() takes 21.2%
Within that fromAnsi() takes 20.4%
Within that operator= takes 19.8%
Within that push_back takes 19.7%
Within that Insert takes 16% made up of:
  insert 6.3%
  operator+ 4.2%
  begin 3.5%

If I use sf::String the problem goes away so it must be to do with the conversion from std::string to sf::String. I will try to knock up a test case now

7
Graphics / Re: sf::Text setString slow
« on: July 21, 2016, 03:15:08 pm »
I will look to create a minimal example. The environment is Visual Studio 2015 with configuration properties set to "Use Multi-Byte Character Set" rather than Unicode.

8
Graphics / sf::Text setString slow
« on: July 20, 2016, 11:53:12 pm »
Hi, loving SFML but text processing is very slow. I expected it to be slow to a degree (I have worked with Freetype directly myself) however one thing that stands out in SFML is the setString function of sf::Text which takes a very big chunk of CPU time. On investigation I have found the slow down is actually in the copy constructor converting from std::string to sf::String. I can hold things as sf::String internally to a degree and then all is fine but at times I must use std::string and hence suffer the conversion to sf::String.

I wondered if there was a way of speeding this up? Oddly I find if I pass the return from c_str() of std::string (i.e. a char*) then it is slightly quicker.

thanks for any advice

Pages: [1]