English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. C/C++

 
 
Thread Tools
Old Today, 03:01   #1
NovaCoder
Registered User
 
NovaCoder's Avatar
 
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(&currentFrameTime, 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, &currentFrameTime, sizeof(struct timeval));
	}

Thanks
NovaCoder is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 15:22.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.07459 seconds with 15 queries