feat: major engine overhaul - scene demo with lighting, sphere, ground

- Scene Demo: cube + sphere + ground plane with proper lighting
- Audio: XAudio2 dynamic loading + WAV playback
- Physics: expanded collision system
- Renderer: improved pipeline with materials
- UI: extended widget system
- VisualScript: enhanced serializer + block interactions
- ASM: optimized math/memory/profiling routines
- Window: mouse input + scroll support
This commit is contained in:
shuiyu1123 committed 2026-07-12 08:21:07 +08:00
1 parent 2653926d85
commit 0669d102ce
35 files changed
+1844 -314

No files matched your search

+66 -1
View File
@@ -6,6 +6,8 @@
#include "logger.h"
#include "timer.h"
#include "../Window/window.h"
#include "../Rendering/renderer.h"
#include "../Rendering/graphics_device.h"
#include "../include/engine_api.h"
#include <stdlib.h>
#include <Windows.h>
@@ -18,6 +20,8 @@ static EngineUpdateCallback g_update_callback = NULL;
static EngineRenderCallback g_render_callback = NULL;
static EngineKeyCallback g_key_callback = NULL;
static EngineResizeCallback g_resize_callback = NULL;
static EngineMouseMoveCallback g_mouse_move_callback = NULL;
static EngineMouseButtonCallback g_mouse_button_callback = NULL;
// 内部函数
static void on_key(int key) {
@@ -35,6 +39,18 @@ static void on_resize(int width, int height) {
}
}
static void on_mouse_move(int x, int y) {
if (g_mouse_move_callback) {
g_mouse_move_callback(&g_engine, x, y);
}
}
static void on_mouse_button(int button, int pressed) {
if (g_mouse_button_callback) {
g_mouse_button_callback(&g_engine, button, pressed);
}
}
Engine* engine_create(void) {
return &g_engine;
}
@@ -73,9 +89,37 @@ int engine_init(Engine* engine, const EngineConfig* config) {
// 设置回调
window_set_key_callback(engine->window, on_key);
window_set_resize_callback(engine->window, on_resize);
window_set_mouse_move_callback(engine->window, on_mouse_move);
window_set_mouse_button_callback(engine->window, on_mouse_button);
LOG_INFO("Window created: %dx%d", config->window_width, config->window_height);
// 创建 D3D11 图形设备
engine->graphics_device = graphics_device_create();
if (!graphics_device_init(engine->graphics_device,
window_get_handle(engine->window),
config->window_width,
config->window_height,
config->vsync)) {
LOG_ERROR("Failed to initialize D3D11 graphics device!");
window_destroy(engine->window);
engine->window = NULL;
return 0;
}
// 创建渲染器
engine->renderer = renderer_create(engine->graphics_device);
if (!engine->renderer) {
LOG_ERROR("Failed to create renderer!");
graphics_device_destroy(engine->graphics_device);
engine->graphics_device = NULL;
window_destroy(engine->window);
engine->window = NULL;
return 0;
}
LOG_INFO("Graphics device and renderer ready.");
engine->initialized = 1;
engine->running = 1;
engine->frame_count = 0;
@@ -143,10 +187,15 @@ void engine_shutdown(Engine* engine) {
LOG_INFO("Shutting down MiMo Engine ASM...");
if (engine->renderer) {
// renderer_destroy(engine->renderer);
renderer_destroy(engine->renderer);
engine->renderer = NULL;
}
if (engine->graphics_device) {
graphics_device_destroy(engine->graphics_device);
engine->graphics_device = NULL;
}
if (engine->window) {
window_destroy(engine->window);
engine->window = NULL;
@@ -177,3 +226,19 @@ void engine_set_key_callback(Engine* engine, EngineKeyCallback callback) {
void engine_set_resize_callback(Engine* engine, EngineResizeCallback callback) {
g_resize_callback = callback;
}
void engine_set_mouse_move_callback(Engine* engine, EngineMouseMoveCallback callback) {
g_mouse_move_callback = callback;
}
void engine_set_mouse_button_callback(Engine* engine, EngineMouseButtonCallback callback) {
g_mouse_button_callback = callback;
}
GraphicsDevice* engine_get_graphics_device(Engine* engine) {
return engine ? engine->graphics_device : NULL;
}
Renderer* engine_get_renderer(Engine* engine) {
return engine ? (Renderer*)engine->renderer : NULL;
}