feat: 添加 Live2D 渲染插件及相关依赖,优化构建和启动脚本
This commit is contained in:
@@ -75,6 +75,13 @@ impl Plugin for Live2DPlugin {
|
||||
message: Message::PluginReady(self.id().to_string()),
|
||||
})?;
|
||||
|
||||
// 如果初始配置就是 Live2D 模式,立即启动渲染
|
||||
let config = (*ctx.config).clone();
|
||||
if config.character.render_type == RenderType::Live2d {
|
||||
println!("[Live2DPlugin] 检测到初始配置为 Live2D 模式,启动渲染");
|
||||
self.start_live2d(&config)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -136,7 +143,23 @@ impl Live2DPlugin {
|
||||
));
|
||||
self.renderer = Some(Arc::clone(&renderer));
|
||||
|
||||
// 渲染器初始化(含 texture 上传)已完成,释放主线程的 EGL 上下文绑定
|
||||
// 让渲染子线程能重新绑定(同一个 EGL context 不能同时在两个线程 current)
|
||||
{
|
||||
let r = renderer.lock().unwrap();
|
||||
r.gl_ctx.release_current();
|
||||
}
|
||||
|
||||
let handle = std::thread::spawn(move || {
|
||||
// EGL 上下文是线程绑定的,需在渲染线程重新绑定
|
||||
{
|
||||
let r = renderer.lock().unwrap();
|
||||
if let Err(e) = r.gl_ctx.make_current() {
|
||||
eprintln!("[Live2DPlugin] eglMakeCurrent 失败: {e}");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// 渲染循环
|
||||
loop {
|
||||
if stop_flag.load(Ordering::SeqCst) {
|
||||
|
||||
Reference in New Issue
Block a user