feat(engine): 重构游戏引擎核心逻辑
- 重新设计了引擎的初始化和运行流程 - 引入了实体组件系统(ECS)和物理系统 - 优化了渲染系统和输入系统 - 移除了不必要的资源管理系统 - 调整了日志系统的实现
This commit is contained in:
57
game_engine/interface/ge_input.h
Normal file
57
game_engine/interface/ge_input.h
Normal file
@@ -0,0 +1,57 @@
|
||||
#ifndef __GE_INPUT_H__
|
||||
#define __GE_INPUT_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
struct ge_input;
|
||||
typedef struct ge_input ge_input_t;
|
||||
typedef union ge_input_event {
|
||||
void* ctx;
|
||||
uintptr_t num;
|
||||
} ge_input_event_t;
|
||||
|
||||
typedef int(*ge_input_send_func_t)(ge_input_t* ctx, ge_input_event_t event);
|
||||
typedef int(*ge_input_peek_func_t)(ge_input_t* ctx, ge_input_event_t* event);
|
||||
typedef int(*ge_input_recv_func_t)(ge_input_t* ctx, ge_input_event_t* event);
|
||||
|
||||
struct ge_input {
|
||||
void* context;
|
||||
ge_input_send_func_t func_send;
|
||||
ge_input_peek_func_t func_peek;
|
||||
ge_input_recv_func_t func_recv;
|
||||
};
|
||||
|
||||
#ifdef __GE_INPUT_EASY_IMPLIMENT_H__
|
||||
|
||||
DECLARE_GE_KFIFO(ge_input_fifo, ge_input_event_t, 16, ge_input_fifo_t);
|
||||
|
||||
static int ge_input_send (ge_input_t* ctx, ge_input_event_t event) {
|
||||
struct ge_input_fifo_t* fifo = (struct ge_input_fifo_t*)ctx->context;
|
||||
if (ge_kfifo_is_full(fifo)) {
|
||||
return -1;
|
||||
}
|
||||
ge_kfifo_put(fifo, event);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ge_input_peek (ge_input_t* ctx, ge_input_event_t* event) {
|
||||
struct ge_input_fifo_t* fifo = (struct ge_input_fifo_t*)ctx->context;
|
||||
if (ge_kfifo_is_empty(fifo)) {
|
||||
return -1;
|
||||
}
|
||||
ge_kfifo_peek(fifo, event);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ge_input_recv (ge_input_t* ctx, ge_input_event_t* event) {
|
||||
struct ge_input_fifo_t* fifo = (struct ge_input_fifo_t*)ctx->context;
|
||||
if (ge_kfifo_is_empty(fifo)) {
|
||||
return -1;
|
||||
}
|
||||
ge_kfifo_get(fifo, event);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif // __GE_INPUT_H__
|
||||
Reference in New Issue
Block a user