![]() |
![]() |
#1 |
Registered User
Join Date: Sep 2007
Location: Melbourne/Australia
Posts: 4,452
|
Getting millisecond elapsed time using Bebbo's Amiga GCC toolchain
Hi,
Wonder if anyone can help. I need a fast way to tack how much time has passed in my main loop. I normally use https://www.tutorialspoint.com/c_sta...tion_clock.htm which has a high frequency on the old GCC 3.4 (milliseconds) but in my Bebbo build it seems to be limited to 50fps. I've hacked together the following code but I'm not really sure it's the best way to do it. Code:
gettimeofday(&lastFrameTime, NULL); while (true) { gettimeofday(¤tFrameTime, NULL); double elapsedtime = (currentFrameTime.tv_sec - lastFrameTime.tv_sec) * 1000.0; // sec to ms elapsedtime += (currentFrameTime.tv_usec - lastFrameTime.tv_usec) / 1000.0; // us to ms // Capture user input and update object positions. g_world->updateWorld(elapsedtime / 1000); g_world->updateFrame(); memcpy(&lastFrameTime, ¤tFrameTime, sizeof(struct timeval)); } Thanks ![]() |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Setting up a debugging environment for Bebbo's Amiga GCC toolchain | Nightfox | Coders. C/C++ | 3 | 12 July 2024 19:48 |
GCC 6.2 toolchain for AmigaOS 3 | Samurai_Crow | Coders. C/C++ | 1555 | 01 May 2024 19:56 |
Can't make bebbo's amiga-gcc work | Bren McGuire | Coders. General | 18 | 12 June 2023 01:09 |
bebbo gcc+eclipse problem | Raislin77it | Coders. C/C++ | 1 | 15 February 2022 08:37 |
gcc-bebbo: argc is always 0 | sparhawk | Coders. C/C++ | 8 | 31 January 2021 18:42 |
|
|