Cambiado de showFps a showInfo
This commit is contained in:
@@ -37,7 +37,7 @@ enum inputs_e
|
|||||||
input_video_shaders,
|
input_video_shaders,
|
||||||
input_reset,
|
input_reset,
|
||||||
input_mute,
|
input_mute,
|
||||||
input_showfps,
|
input_showinfo,
|
||||||
|
|
||||||
// Input obligatorio
|
// Input obligatorio
|
||||||
input_null,
|
input_null,
|
||||||
|
|||||||
@@ -39,14 +39,16 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer, Asset *asset, Input *
|
|||||||
fpsCounter = 0;
|
fpsCounter = 0;
|
||||||
fps = 0;
|
fps = 0;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
showFps = true;
|
showInfo = true;
|
||||||
#else
|
#else
|
||||||
showFps = false;
|
showInfo = false;
|
||||||
#endif
|
#endif
|
||||||
SDL_DisplayMode DM;
|
SDL_DisplayMode DM;
|
||||||
SDL_GetCurrentDisplayMode(0, &DM);
|
SDL_GetCurrentDisplayMode(0, &DM);
|
||||||
displayWidth = DM.w;
|
displayWidth = DM.w;
|
||||||
displayHeight = DM.h;
|
displayHeight = DM.h;
|
||||||
|
displayRefreshRate = DM.refresh_rate;
|
||||||
|
infoResolution = std::to_string(displayWidth) + " X " + std::to_string(displayHeight) + " AT " + std::to_string(displayRefreshRate) + " HZ";
|
||||||
|
|
||||||
// Crea los objetos
|
// Crea los objetos
|
||||||
notify = new Notify(renderer, asset->get("notify.png"), asset->get("8bithud.png"), asset->get("8bithud.txt"), asset->get("notify.wav"), options);
|
notify = new Notify(renderer, asset->get("notify.png"), asset->get("8bithud.png"), asset->get("8bithud.txt"), asset->get("notify.wav"), options);
|
||||||
@@ -93,23 +95,14 @@ void Screen::blit()
|
|||||||
// Atenua la pantalla
|
// Atenua la pantalla
|
||||||
doAttenuate();
|
doAttenuate();
|
||||||
|
|
||||||
// Pinta las notificaciones
|
|
||||||
notify->render();
|
|
||||||
|
|
||||||
// Actualiza el contador de FPS
|
// Actualiza el contador de FPS
|
||||||
fpsCounter++;
|
fpsCounter++;
|
||||||
|
|
||||||
// Pinta en pantalla el contador de FPS
|
// Muestra información por pantalla
|
||||||
if (showFps)
|
displayInfo();
|
||||||
{
|
|
||||||
// FPS
|
|
||||||
const std::string fpstext = std::to_string(fps) + " FPS";
|
|
||||||
dbg_print(0, 0, fpstext.c_str(), 255, 255, 255);
|
|
||||||
|
|
||||||
// Resolution
|
// Muestra las notificaciones
|
||||||
const std::string resolution = std::to_string(displayWidth) + " X " + std::to_string(displayHeight);
|
notify->render();
|
||||||
dbg_print(0, 8, resolution.c_str(), 255, 255, 255);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef NO_SHADERS
|
#ifdef NO_SHADERS
|
||||||
// Vuelve a dejar el renderizador en modo normal
|
// Vuelve a dejar el renderizador en modo normal
|
||||||
@@ -341,9 +334,9 @@ void Screen::checkInput()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (input->checkInput(input_showfps, DO_NOT_ALLOW_REPEAT))
|
if (input->checkInput(input_showinfo, DO_NOT_ALLOW_REPEAT))
|
||||||
{
|
{
|
||||||
showFps = !showFps;
|
showInfo = !showInfo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -459,3 +452,17 @@ void Screen::updateFPS()
|
|||||||
fpsCounter = 0;
|
fpsCounter = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Muestra información por pantalla
|
||||||
|
void Screen::displayInfo()
|
||||||
|
{
|
||||||
|
if (showInfo)
|
||||||
|
{
|
||||||
|
// FPS
|
||||||
|
const std::string fpstext = std::to_string(fps) + " FPS";
|
||||||
|
dbg_print(gameCanvasWidth - fpstext.length() * 8, 0, fpstext.c_str(), 255, 255, 0);
|
||||||
|
|
||||||
|
// Resolution
|
||||||
|
dbg_print(0, 0, infoResolution.c_str(), 255, 255, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -27,19 +27,21 @@ private:
|
|||||||
options_t *options; // Variable con todas las opciones del programa
|
options_t *options; // Variable con todas las opciones del programa
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
int windowWidth; // Ancho de la pantalla o ventana
|
int windowWidth; // Ancho de la pantalla o ventana
|
||||||
int windowHeight; // Alto de la pantalla o ventana
|
int windowHeight; // Alto de la pantalla o ventana
|
||||||
int gameCanvasWidth; // Resolución interna del juego. Es el ancho de la textura donde se dibuja el juego
|
int gameCanvasWidth; // Resolución interna del juego. Es el ancho de la textura donde se dibuja el juego
|
||||||
int gameCanvasHeight; // Resolución interna del juego. Es el alto de la textura donde se dibuja el juego
|
int gameCanvasHeight; // Resolución interna del juego. Es el alto de la textura donde se dibuja el juego
|
||||||
SDL_Rect dest; // Coordenadas donde se va a dibujar la textura del juego sobre la pantalla o ventana
|
SDL_Rect dest; // Coordenadas donde se va a dibujar la textura del juego sobre la pantalla o ventana
|
||||||
color_t borderColor; // Color del borde añadido a la textura de juego para rellenar la pantalla
|
color_t borderColor; // Color del borde añadido a la textura de juego para rellenar la pantalla
|
||||||
bool attenuateEffect; // Indica si la pantalla ha de estar atenuada
|
bool attenuateEffect; // Indica si la pantalla ha de estar atenuada
|
||||||
Uint32 fpsTicks; // Ticks para contar los frames por segundo
|
Uint32 fpsTicks; // Ticks para contar los frames por segundo
|
||||||
int fpsCounter; // Contador de frames por segundo
|
int fpsCounter; // Contador de frames por segundo
|
||||||
int fps; // Frames calculados en el último segundo
|
int fps; // Frames calculados en el último segundo
|
||||||
bool showFps; // Indica si ha de mostrar/ocultar la información de los frames por segundo en pantalla
|
bool showInfo; // Indica si ha de mostrar/ocultar la información de la pantalla
|
||||||
int displayWidth; // Anchura de la pantalla
|
int displayWidth; // Anchura de la pantalla
|
||||||
int displayHeight; // Altura de la pantalla
|
int displayHeight; // Altura de la pantalla
|
||||||
|
int displayRefreshRate; // Frecuencia de refresco de la pantalla
|
||||||
|
std::string infoResolution; // Texto con la informacion de la pantalla
|
||||||
|
|
||||||
struct effect_t
|
struct effect_t
|
||||||
{
|
{
|
||||||
@@ -74,6 +76,9 @@ private:
|
|||||||
// Calcula los frames por segundo
|
// Calcula los frames por segundo
|
||||||
void updateFPS();
|
void updateFPS();
|
||||||
|
|
||||||
|
// Muestra información por pantalla
|
||||||
|
void displayInfo();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Screen(SDL_Window *window, SDL_Renderer *renderer, Asset *asset, Input *input, options_t *options);
|
Screen(SDL_Window *window, SDL_Renderer *renderer, Asset *asset, Input *input, options_t *options);
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ void Director::initInput()
|
|||||||
input->bindKey(input_window_fullscreen, SDL_SCANCODE_F3);
|
input->bindKey(input_window_fullscreen, SDL_SCANCODE_F3);
|
||||||
input->bindKey(input_video_shaders, SDL_SCANCODE_F4);
|
input->bindKey(input_video_shaders, SDL_SCANCODE_F4);
|
||||||
input->bindKey(input_mute, SDL_SCANCODE_F5);
|
input->bindKey(input_mute, SDL_SCANCODE_F5);
|
||||||
input->bindKey(input_showfps, SDL_SCANCODE_F6);
|
input->bindKey(input_showinfo, SDL_SCANCODE_F6);
|
||||||
input->bindKey(input_reset, SDL_SCANCODE_F10);
|
input->bindKey(input_reset, SDL_SCANCODE_F10);
|
||||||
|
|
||||||
const int numGamePads = input->getNumControllers();
|
const int numGamePads = input->getNumControllers();
|
||||||
|
|||||||
Reference in New Issue
Block a user