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 - Hedgeberry

Pages: [1]
1
Graphics / Shift HSV-color
« on: July 12, 2022, 12:55:55 pm »
Is there any built-in HSV-color shift functionality?
Let's say I need to shift the color shade by 32, is there any simple way to do it or will I have to write my own RGB to HSV conversions, shift and convert back there?

2
Window / Re: RenderTarget slower RenderWindow
« on: July 10, 2022, 07:38:30 pm »
I tried to write code that reproduces the problem, but it does not reproduce it, apparently the problem is still somewhere, thank you
#include <SFML/Graphics.hpp>

float calculateMediumFPS(std::vector<float>& lastFPS) {
        float sum = 0.0f;
        for(const auto &fps: lastFPS) {
                sum += fps;
        }
        return sum / static_cast<float>(lastFPS.size());
}

int main()
{
        sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
        sf::CircleShape shape(100.f);
        shape.setFillColor(sf::Color::Green);
       
        sf::RenderTarget* renderTarget = &window; //When the pointer type is sf::RenderWindow, it works faster
       
        sf::Clock clock;
        std::vector<float> lastFPS(60, 0.0f);
       
        while (window.isOpen())
        {
                lastFPS[0] = 1.f / clock.restart().asSeconds();
                std::rotate(lastFPS.begin(), lastFPS.begin() + 1, lastFPS.end());
                float mediumFPS = calculateMediumFPS(lastFPS);
                window.setTitle(std::to_string(static_cast<int>(mediumFPS)));
                clock.restart(); //to count only the game cycle, not taking into account the cost of the FPS meter
               
                sf::Event event;
                while (window.pollEvent(event))
                {
                        if (event.type == sf::Event::Closed)
                                window.close();
                }
               
                window.clear();
                renderTarget->draw(shape);
                window.display();
        }
       
        return 0;
}

3
Window / Re: RenderTarget slower RenderWindow
« on: July 06, 2022, 07:04:59 pm »
The timer is trivially reset at the beginning of each frame, so it takes everything into account. We don't re-render the texture, because we still render directly to the RenderWindow, it's just that now the reference to the RenderWindow has the type RenderTarget& instead of RenderWindow& as it was before, we haven't changed anything else. Thanks for the help, but apparently you don't know what this problem is.

4
Window / RenderTarget slower RenderWindow
« on: June 29, 2022, 07:53:33 pm »
We have a hierarchy of classes that store a reference where they are rendered. This can be either RenderTexture or RenderWindow (passed during initialization), so we store a reference to RenderTarget, after we changed the reference type from RenderWindow to RenderTarget (but the reference still passes the same window) our program has halved the FPS we were counting with sf::Clock. Is the problem somewhere in us or in SFML and the libraries on which it depends?

5
Window / Re: RenderTarget slow
« on: June 27, 2022, 11:10:18 pm »
Sorry, I work with this person it in the project, we have a hierarchy of classes that store a reference where they are rendered. This can be either RenderTexture or RenderWindow (passed during initialization), so we store a reference to RenderTarget, after we changed the reference type from RenderWindow to RenderTarget (but the reference still passes the same window) our program has halved the FPS we were counting with sf::Clock.

Pages: [1]