mirror of
				https://github.com/luanti-org/luanti.git
				synced 2025-11-04 09:15:29 +01:00 
			
		
		
		
	Add FPS limit to menu clouds
This commit is contained in:
		
							
								
								
									
										24
									
								
								src/main.cpp
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								src/main.cpp
									
									
									
									
									
								
							@@ -1597,7 +1597,7 @@ int main(int argc, char *argv[])
 | 
			
		||||
				if(skip_main_menu == false)
 | 
			
		||||
				{
 | 
			
		||||
					video::IVideoDriver* driver = device->getVideoDriver();
 | 
			
		||||
					
 | 
			
		||||
					float fps_max = g_settings->getFloat("fps_max");
 | 
			
		||||
					infostream<<"Waiting for other menus"<<std::endl;
 | 
			
		||||
					while(device->run() && kill == false)
 | 
			
		||||
					{
 | 
			
		||||
@@ -1690,8 +1690,28 @@ int main(int argc, char *argv[])
 | 
			
		||||
						
 | 
			
		||||
						// On some computers framerate doesn't seem to be
 | 
			
		||||
						// automatically limited
 | 
			
		||||
						if (!cloud_menu_background)
 | 
			
		||||
						if (cloud_menu_background) {
 | 
			
		||||
							// Time of frame without fps limit
 | 
			
		||||
							float busytime;
 | 
			
		||||
							u32 busytime_u32;
 | 
			
		||||
							// not using getRealTime is necessary for wine
 | 
			
		||||
							u32 time = device->getTimer()->getTime();
 | 
			
		||||
							if(time > lasttime)
 | 
			
		||||
								busytime_u32 = time - lasttime;
 | 
			
		||||
							else
 | 
			
		||||
								busytime_u32 = 0;
 | 
			
		||||
							busytime = busytime_u32 / 1000.0;
 | 
			
		||||
 | 
			
		||||
							// FPS limiter
 | 
			
		||||
							u32 frametime_min = 1000./fps_max;
 | 
			
		||||
			
 | 
			
		||||
							if(busytime_u32 < frametime_min) {
 | 
			
		||||
								u32 sleeptime = frametime_min - busytime_u32;
 | 
			
		||||
								device->sleep(sleeptime);
 | 
			
		||||
							}
 | 
			
		||||
						} else {
 | 
			
		||||
							sleep_ms(25);
 | 
			
		||||
						}
 | 
			
		||||
					}
 | 
			
		||||
					
 | 
			
		||||
					infostream<<"Dropping main menu"<<std::endl;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user