feat(engine): 重构游戏引擎核心逻辑
- 重新设计了引擎的初始化和运行流程 - 引入了实体组件系统(ECS)和物理系统 - 优化了渲染系统和输入系统 - 移除了不必要的资源管理系统 - 调整了日志系统的实现
This commit is contained in:
31
game_engine/interface/timer/ge_fps.h
Normal file
31
game_engine/interface/timer/ge_fps.h
Normal file
@@ -0,0 +1,31 @@
|
||||
#ifndef __GE_FPS_H__
|
||||
#define __GE_FPS_H__
|
||||
|
||||
#include <ge_common.h>
|
||||
struct ge_fps_controller;
|
||||
typedef struct ge_fps_controller ge_fps_controller_t;
|
||||
|
||||
typedef ge_u32_t (*ge_fps_get_us_func_t)(void);
|
||||
typedef void (*ge_fps_sleep_us_func_t)(ge_u32_t us);
|
||||
|
||||
void ge_fps_init(ge_fps_controller_t* fps_ctrl, ge_u32_t target_fps,
|
||||
ge_fps_get_us_func_t get_ms, ge_fps_sleep_us_func_t sleep_ms);
|
||||
void ge_fps_begin_frame(ge_fps_controller_t* fps_ctrl);
|
||||
void ge_fps_end_frame(ge_fps_controller_t* fps_ctrl);
|
||||
|
||||
// FPS控制器结构体
|
||||
struct ge_fps_controller {
|
||||
ge_u32_t target_fps; // 目标帧率
|
||||
ge_u32_t frame_duration; // 目标每帧时长(毫秒)
|
||||
ge_u32_t last_frame_time; // 上一帧开始时间
|
||||
ge_u32_t frame_time; // 当前帧耗时
|
||||
ge_u32_t sleep_time; // 需要休眠的时间
|
||||
ge_u32_t frame_count; // 帧计数器
|
||||
ge_u32_t fps; // 实际帧率
|
||||
ge_u32_t last_fps_time; // 上次计算FPS的时间
|
||||
|
||||
ge_fps_get_us_func_t call_get_us;
|
||||
ge_fps_sleep_us_func_t call_sleep_us;
|
||||
};
|
||||
|
||||
#endif // __GE_FPS_H__
|
||||
Reference in New Issue
Block a user