diff options
| author | Aldrik Ramaekers <aldrikboy@gmail.com> | 2024-03-16 18:46:05 +0100 |
|---|---|---|
| committer | Aldrik Ramaekers <aldrikboy@gmail.com> | 2024-03-16 18:46:05 +0100 |
| commit | 3c88bdf6a63e9cb9ba1453a47c5b59fa9873e925 (patch) | |
| tree | abbc8bd348190021697e2b9f56ed0fbc8213fa58 | |
| parent | 7c3b90eb9834ae605c679be2c240d36715225acc (diff) | |
fix elapsed time calc
| -rw-r--r-- | src/unix/main_unix.cpp | 17 |
1 files changed, 6 insertions, 11 deletions
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) { |
