From 3c88bdf6a63e9cb9ba1453a47c5b59fa9873e925 Mon Sep 17 00:00:00 2001 From: Aldrik Ramaekers Date: Sat, 16 Mar 2024 18:46:05 +0100 Subject: fix elapsed time calc --- src/unix/main_unix.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'src/unix/main_unix.cpp') diff --git a/src/unix/main_unix.cpp b/src/unix/main_unix.cpp index ef8dd88..c291ee5 100644 --- a/src/unix/main_unix.cpp +++ b/src/unix/main_unix.cpp @@ -30,6 +30,7 @@ void ts_init(); GLFWwindow* glfw_window; bool program_running = true; ts_dragdrop_data dragdrop_data = {0}; +uint64_t frequency; char config_path[MAX_INPUT_LENGTH]; static const char* _ts_platform_get_config_file_path(char* buffer) { @@ -95,6 +96,8 @@ int main(int, char**) return 1; } + frequency = glfwGetTimerFrequency(); + ts_init(); // Decide GL+GLSL versions @@ -340,19 +343,11 @@ void ts_platform_list_files_block(ts_search_result* result, wchar_t* start_dir) } uint64_t ts_platform_get_time(uint64_t compare) { - struct timespec tms; - if (clock_gettime(CLOCK_PROCESS_CPUTIME_ID,&tms)) { - return -1; - } - uint64_t result = 0; - result = tms.tv_sec * 1000; - result += tms.tv_nsec / 1000000; - + uint64_t stamp = glfwGetTimerValue(); if (compare != 0) { - return (result - compare); + return (stamp - compare) * 1000 / frequency; } - - return result; + return stamp; } void ts_platform_open_file_as(utf8_int8_t* str) { -- cgit v1.2.3-70-g09d2