Reset frame counter properly.
This commit is contained in:
parent
dadd794ece
commit
6a260a57dd
|
@ -25,21 +25,26 @@ static float tv_to_fps(const struct timeval *tv, const struct timeval *new_tv, i
|
||||||
return frames/time;
|
return frames/time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static unsigned gl_frames = 0;
|
||||||
|
|
||||||
|
void gfx_window_title_reset(void)
|
||||||
|
{
|
||||||
|
gl_frames = 0;
|
||||||
|
}
|
||||||
|
|
||||||
bool gfx_window_title(char *buf, size_t size)
|
bool gfx_window_title(char *buf, size_t size)
|
||||||
{
|
{
|
||||||
static int frames = 0;
|
|
||||||
static struct timeval tv;
|
static struct timeval tv;
|
||||||
struct timeval new_tv;
|
struct timeval new_tv;
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
||||||
if (frames == 0)
|
if (gl_frames == 0)
|
||||||
{
|
{
|
||||||
gettimeofday(&tv, NULL);
|
gettimeofday(&tv, NULL);
|
||||||
snprintf(buf, size, "%s", g_extern.title_buf);
|
snprintf(buf, size, "%s", g_extern.title_buf);
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
|
else if ((gl_frames % 180) == 0)
|
||||||
if ((frames % 180) == 0 && frames > 0)
|
|
||||||
{
|
{
|
||||||
gettimeofday(&new_tv, NULL);
|
gettimeofday(&new_tv, NULL);
|
||||||
struct timeval tmp_tv = tv;
|
struct timeval tmp_tv = tv;
|
||||||
|
@ -47,11 +52,11 @@ bool gfx_window_title(char *buf, size_t size)
|
||||||
|
|
||||||
float fps = tv_to_fps(&tmp_tv, &new_tv, 180);
|
float fps = tv_to_fps(&tmp_tv, &new_tv, 180);
|
||||||
|
|
||||||
snprintf(buf, size, "%s || FPS: %6.1f || Frames: %d", g_extern.title_buf, fps, frames);
|
snprintf(buf, size, "%s || FPS: %6.1f || Frames: %d", g_extern.title_buf, fps, gl_frames);
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
frames++;
|
gl_frames++;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,5 +22,6 @@
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
bool gfx_window_title(char *buf, size_t size);
|
bool gfx_window_title(char *buf, size_t size);
|
||||||
|
void gfx_window_title_reset(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
9
gfx/gl.c
9
gfx/gl.c
|
@ -1051,6 +1051,11 @@ static void* gl_init(const video_info_t *video, const input_driver_t **input, vo
|
||||||
if (!SDL_SetVideoMode(video->width, video->height, g_settings.video.force_16bit ? 16 : 0, SDL_OPENGL | SDL_RESIZABLE | (video->fullscreen ? SDL_FULLSCREEN : 0)))
|
if (!SDL_SetVideoMode(video->width, video->height, g_settings.video.force_16bit ? 16 : 0, SDL_OPENGL | SDL_RESIZABLE | (video->fullscreen ? SDL_FULLSCREEN : 0)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
gfx_window_title_reset();
|
||||||
|
char buf[128];
|
||||||
|
if (gfx_window_title(buf, sizeof(buf)))
|
||||||
|
SDL_WM_SetCaption(buf, NULL);
|
||||||
|
|
||||||
// Remove that ugly mouse :D
|
// Remove that ugly mouse :D
|
||||||
SDL_ShowCursor(SDL_DISABLE);
|
SDL_ShowCursor(SDL_DISABLE);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
@ -1138,10 +1143,6 @@ static void* gl_init(const video_info_t *video, const input_driver_t **input, vo
|
||||||
glColor4f(1, 1, 1, 1);
|
glColor4f(1, 1, 1, 1);
|
||||||
glClearColor(0, 0, 0, 1);
|
glClearColor(0, 0, 0, 1);
|
||||||
|
|
||||||
char buf[128];
|
|
||||||
if (gfx_window_title(buf, sizeof(buf)))
|
|
||||||
SDL_WM_SetCaption(buf, NULL);
|
|
||||||
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue