| 1234567891011121314151617181920212223242526272829303132333435363738 |
- //
- // fps_counter.hpp
- // engine
- //
- // Created by Sam Jaffe on 5/24/19.
- // Copyright © 2019 Sam Jaffe. All rights reserved.
- //
- #pragma once
- #include <vector>
- #include "game/graphics/graphics_fwd.h"
- #include "game/util/time.hpp"
- namespace engine {
- class text_engine;
- class fps_counter {
- public:
- fps_counter(std::shared_ptr<text_engine> text_engine,
- std::size_t precision = 3);
- ~fps_counter();
- void set_frame_step(env::clock::duration const & since);
- void render(graphics::renderer & renderer) const;
- std::vector<graphics::object> const & glyphs() const { return glyphs_; }
- private:
- std::string fps(env::clock::duration const & since) const;
- int counter_{0}, change_after_{10};
- std::size_t digits_;
- std::size_t magnitude_;
- std::shared_ptr<text_engine> text_engine_;
- std::vector<graphics::object> glyphs_;
- };
- }
|