afegit comptador de frames per segon
This commit is contained in:
@@ -22,6 +22,35 @@ enum class ScreenFilter : Uint32
|
||||
class Screen
|
||||
{
|
||||
private:
|
||||
// Estructuras
|
||||
struct FPS
|
||||
{
|
||||
Uint32 ticks; // Tiempo en milisegundos desde que se comenzó a contar.
|
||||
int frameCount; // Número acumulado de frames en el intervalo.
|
||||
int lastValue; // Número de frames calculado en el último segundo.
|
||||
|
||||
// Constructor para inicializar la estructura.
|
||||
FPS() : ticks(0), frameCount(0), lastValue(0) {}
|
||||
|
||||
// Incrementador que se llama en cada frame.
|
||||
void increment()
|
||||
{
|
||||
frameCount++;
|
||||
}
|
||||
|
||||
// Método para calcular y devolver el valor de FPS.
|
||||
int calculate(Uint32 currentTicks)
|
||||
{
|
||||
if (currentTicks - ticks >= 1000) // Si ha pasado un segundo o más.
|
||||
{
|
||||
lastValue = frameCount; // Actualizamos el valor del último FPS.
|
||||
frameCount = 0; // Reiniciamos el contador de frames.
|
||||
ticks = currentTicks; // Actualizamos el tiempo base.
|
||||
}
|
||||
return lastValue;
|
||||
}
|
||||
};
|
||||
|
||||
// Constantes
|
||||
static constexpr int WINDOWS_DECORATIONS_ = 35;
|
||||
|
||||
@@ -46,6 +75,14 @@ private:
|
||||
std::vector<std::string> palettes_; // Listado de los ficheros de paletta disponibles
|
||||
Uint8 current_palette_ = 0; // Indice para el vector de paletas
|
||||
bool notifications_enabled_ = false; // indica si se muestran las notificaciones
|
||||
FPS fps_; // Variable para gestionar los frames por segundo
|
||||
std::string info_resolution_; // Texto con la informacion de la pantalla
|
||||
|
||||
#ifdef DEBUG
|
||||
bool show_debug_info_ = false; // Indica si ha de mostrar/ocultar la información de la pantalla
|
||||
#else
|
||||
bool show_debug_info_ = false; // Indica si ha de mostrar/ocultar la información de la pantalla
|
||||
#endif
|
||||
|
||||
// Dibuja las notificaciones
|
||||
void renderNotifications();
|
||||
@@ -80,6 +117,9 @@ private:
|
||||
// Recrea la textura para los shaders
|
||||
void createShadersTexture();
|
||||
|
||||
// Muestra información por pantalla
|
||||
void renderInfo();
|
||||
|
||||
// Constructor
|
||||
Screen(SDL_Window *window, SDL_Renderer *renderer);
|
||||
|
||||
@@ -166,4 +206,7 @@ public:
|
||||
|
||||
// Establece la visibilidad de las notificaciones
|
||||
void setNotificationsEnabled(bool value) { notifications_enabled_ = value; }
|
||||
|
||||
// Activa / desactiva la información de debug
|
||||
void toggleDebugInfo() { show_debug_info_ = !show_debug_info_; }
|
||||
};
|
||||
Reference in New Issue
Block a user