charcoal/OpenGLEngine/FPS.h
elipzer 3485bcb2a0 Improved Batch Functionality
Now batches are actually batches.

Also added the MeshFactory class.

Drawing modes are now specified with DrawMode instead of the
GLenum. Renderables must be specified with a draw mode.
2018-09-06 23:22:40 -04:00

44 lines
1.3 KiB
C++

#pragma once
#include <ctime>
//A class to handle the FPS of the game
//Calculations are done per the number of frames specified
//Frames must be a value from 2 - 255
//Recommended numbers for frames is 2 (Instant), 5 (Slightly Smoothed), 60 (Smoothed)
//Max number for frames = 255
//Lower frames = jumpy, instant updates
//Higher frames = smoother, flowing updates
class FPS final
{
public:
FPS(unsigned short frames = 2);
~FPS();
//Returns the clock of the last mark() call
const clock_t& get_clock() const;
//Returns FPS (frames per second) of the game (based on the last marked frame)
//CLOCKS_PER_SECOND / (m_clock - m_prevClock)
float get_spf() const;
//Returns FPS (frames per second) of the game (based on the last marked frame)
//CLOCKS_PER_SECOND / (m_clock - m_prevClock)
float get_fps() const;
//Fills the clocks with the current clock() value (to prevent unreasonable clock counts at the first few frames)
void prepare();
//Marks the end of the frame (resets the clock)
//Should be called right before the update() and render() functions
//Also calculates the seconds per frame (able to be considered the dTime)
//(m_clock - m_prevClock) / CLOCKS_PER_SEC
float mark();
private:
//m_iter marks the place of the next mark
unsigned short m_iter;
unsigned short m_frames;
clock_t* m_clocks = nullptr;
};