mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-12 07:03:34 +00:00
adding fps capper
This commit is contained in:
41
src/core/fps.h
git.filemode.normal_file
41
src/core/fps.h
git.filemode.normal_file
@@ -0,0 +1,41 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* fps.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/01/18 14:53:30 by maldavid #+# #+# */
|
||||
/* Updated: 2024/01/18 15:16:06 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef __MLX_FPS__
|
||||
#define __MLX_FPS__
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace mlx
|
||||
{
|
||||
class FpsManager
|
||||
{
|
||||
public:
|
||||
FpsManager() = default;
|
||||
|
||||
void init();
|
||||
bool update();
|
||||
inline void setMaxFPS(uint32_t fps) noexcept { _max_fps = fps; _ns = 1000000000.0 / fps; }
|
||||
|
||||
~FpsManager() = default;
|
||||
|
||||
private:
|
||||
double _ns = 1000000000.0 / 1'337'000.0;
|
||||
uint64_t _timer = 0;
|
||||
uint64_t _fps_before = 0;
|
||||
uint64_t _fps_now = 0;
|
||||
uint32_t _max_fps = 1'337'000;
|
||||
uint32_t _fps_elapsed_time = 0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user