Log FPS
This commit is contained in:
		@ -68,7 +68,10 @@ ForEachMacros:
 | 
			
		||||
  - BOOST_FOREACH
 | 
			
		||||
IncludeBlocks: Regroup
 | 
			
		||||
IncludeCategories:
 | 
			
		||||
  - Regex: '^[<"](fmt|SDL2)/'
 | 
			
		||||
  - Regex: '^[<"]SDL2/'
 | 
			
		||||
    Priority: 2
 | 
			
		||||
    SortPriority: 0
 | 
			
		||||
  - Regex: '^[<"](fmt|spdlog)/'
 | 
			
		||||
    Priority: 3
 | 
			
		||||
    SortPriority: 0
 | 
			
		||||
  - Regex: "^<"
 | 
			
		||||
 | 
			
		||||
@ -28,7 +28,17 @@ endif()
 | 
			
		||||
if (NOT DEFINED fmt_INCLUDE_DIR)
 | 
			
		||||
    set(fmt_INCLUDE_DIR ${fmt_SOURCE_DIR}/${FMT_INC_DIR})
 | 
			
		||||
endif()
 | 
			
		||||
set(BUILD_SHARED_LIBS ${lhotse_orig_BUILD_SHARED_LIBS})
 | 
			
		||||
set(BUILD_SHARED_LIBS ${stw_display_orig_BUILD_SHARED_LIBS})
 | 
			
		||||
 | 
			
		||||
# spdlog
 | 
			
		||||
set(CMAKE_POSITION_INDEPENDENT_CODE true)
 | 
			
		||||
set(SPDLOG_FMT_EXTERNAL_HO true)
 | 
			
		||||
FetchContent_Declare(
 | 
			
		||||
    spdlog
 | 
			
		||||
    GIT_REPOSITORY https://github.com/gabime/spdlog.git
 | 
			
		||||
    GIT_TAG v1.9.2
 | 
			
		||||
)
 | 
			
		||||
FetchContent_MakeAvailable(spdlog)
 | 
			
		||||
 | 
			
		||||
# }}}
 | 
			
		||||
 | 
			
		||||
@ -57,5 +67,6 @@ target_link_libraries(
 | 
			
		||||
    ${SDL2_LIBRARIES}
 | 
			
		||||
    ${SDL2TTF_LIBRARY}
 | 
			
		||||
    ${SDL2IMAGE_LIBRARY}
 | 
			
		||||
    fmt)
 | 
			
		||||
    fmt
 | 
			
		||||
    spdlog::spdlog)
 | 
			
		||||
add_dependencies(stw-display fmt)
 | 
			
		||||
							
								
								
									
										15
									
								
								src/App.cpp
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								src/App.cpp
									
									
									
									
									
								
							@ -7,7 +7,11 @@
 | 
			
		||||
#include <SDL2/SDL_events.h>
 | 
			
		||||
#include <SDL2/SDL_image.h>
 | 
			
		||||
#include <SDL2/SDL_keycode.h>
 | 
			
		||||
#include <SDL2/SDL_render.h>
 | 
			
		||||
#include <SDL2/SDL_timer.h>
 | 
			
		||||
 | 
			
		||||
#include <fmt/format.h>
 | 
			
		||||
#include <spdlog/spdlog.h>
 | 
			
		||||
 | 
			
		||||
#include <queue>
 | 
			
		||||
#include <stdexcept>
 | 
			
		||||
@ -42,9 +46,20 @@ int App::run() {
 | 
			
		||||
 | 
			
		||||
  running = true;
 | 
			
		||||
 | 
			
		||||
  uint32_t second_start = SDL_GetTicks();
 | 
			
		||||
  unsigned frames = 0;
 | 
			
		||||
  while (running) {
 | 
			
		||||
    uint32_t now = SDL_GetTicks();
 | 
			
		||||
    if (now - second_start > 5000) {
 | 
			
		||||
      spdlog::info("{} FPS", frames / 5);
 | 
			
		||||
      second_start = now;
 | 
			
		||||
      frames = 0;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    handle_events();
 | 
			
		||||
    render();
 | 
			
		||||
 | 
			
		||||
    frames++;
 | 
			
		||||
    SDL_Delay(1);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -5,6 +5,7 @@
 | 
			
		||||
 | 
			
		||||
#include <SDL2/SDL.h>
 | 
			
		||||
#include <SDL2/SDL_image.h>
 | 
			
		||||
 | 
			
		||||
#include <fmt/format.h>
 | 
			
		||||
 | 
			
		||||
#include <cstdint>
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user