This commit is contained in:
Rob Loach 2024-08-28 11:27:50 -04:00
parent b3b400895d
commit 893750c797
No known key found for this signature in database
GPG Key ID: 627C60834A74A21A
4 changed files with 15 additions and 9 deletions

View File

@ -51,7 +51,7 @@ static struct nk_sdl {
struct nk_sdl_device ogl;
struct nk_context ctx;
struct nk_font_atlas atlas;
float time_of_last_frame;
float delta_time_seconds_last;
} sdl;
NK_INTERN void
@ -76,8 +76,8 @@ nk_sdl_render(enum nk_anti_aliasing AA)
struct nk_vec2 scale;
float now = ((float)SDL_GetTicks64()) / 1000;
sdl.ctx.delta_time_seconds = now - sdl.time_of_last_frame;
sdl.time_of_last_frame = now;
sdl.ctx.delta_time_seconds = now - sdl.delta_time_seconds_last;
sdl.delta_time_seconds_last = now;
SDL_GetWindowSize(sdl.win, &width, &height);
SDL_GL_GetDrawableSize(sdl.win, &display_width, &display_height);

View File

@ -67,7 +67,7 @@ static struct nk_sdl {
struct nk_sdl_device ogl;
struct nk_context ctx;
struct nk_font_atlas atlas;
float time_of_last_frame;
float delta_time_seconds_last;
} sdl;
#ifdef __APPLE__
@ -200,8 +200,8 @@ nk_sdl_render(enum nk_anti_aliasing AA, int max_vertex_buffer, int max_element_b
};
float now = ((float)SDL_GetTicks64()) / 1000;
sdl.ctx.delta_time_seconds = now - sdl.time_of_last_frame;
sdl.time_of_last_frame = now;
sdl.ctx.delta_time_seconds = now - sdl.delta_time_seconds_last;
sdl.delta_time_seconds_last = now;
SDL_GetWindowSize(sdl.win, &width, &height);
SDL_GL_GetDrawableSize(sdl.win, &display_width, &display_height);

View File

@ -71,7 +71,7 @@ static struct nk_sdl {
struct nk_sdl_device ogl;
struct nk_context ctx;
struct nk_font_atlas atlas;
float time_of_last_frame;
float delta_time_seconds_last;
} sdl;
@ -188,8 +188,8 @@ nk_sdl_render(enum nk_anti_aliasing AA, int max_vertex_buffer, int max_element_b
};
float now = ((float)SDL_GetTicks64()) / 1000;
sdl.ctx.delta_time_seconds = now - sdl.time_of_last_frame;
sdl.time_of_last_frame = now;
sdl.ctx.delta_time_seconds = now - sdl.delta_time_seconds_last;
sdl.delta_time_seconds_last = now;
SDL_GetWindowSize(sdl.win, &width, &height);
SDL_GL_GetDrawableSize(sdl.win, &display_width, &display_height);

View File

@ -64,6 +64,7 @@ static struct nk_sdl {
struct nk_sdl_device ogl;
struct nk_context ctx;
struct nk_font_atlas atlas;
float delta_time_seconds_last;
} sdl;
@ -113,6 +114,11 @@ nk_sdl_render(enum nk_anti_aliasing AA)
{NK_VERTEX_COLOR, NK_FORMAT_R8G8B8A8, NK_OFFSETOF(struct nk_sdl_vertex, col)},
{NK_VERTEX_LAYOUT_END}
};
float now = ((float)SDL_GetTicks64()) / 1000;
sdl.ctx.delta_time_seconds = now - sdl.delta_time_seconds_last;
sdl.delta_time_seconds_last = now;
NK_MEMSET(&config, 0, sizeof(config));
config.vertex_layout = vertex_layout;
config.vertex_size = sizeof(struct nk_sdl_vertex);