feat(engine): 改进 Rust 纹理管理器
- 支持任意 ID 的纹理加载(非递增) - 添加纹理状态追踪 API - 优化纹理缓存清理机制 - 更新 TypeScript 绑定
This commit is contained in:
@@ -197,14 +197,6 @@ impl Engine {
|
||||
colors: &[u32],
|
||||
material_ids: &[u32],
|
||||
) -> Result<()> {
|
||||
// Debug: log once
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
static LOGGED: AtomicBool = AtomicBool::new(false);
|
||||
if !LOGGED.swap(true, Ordering::Relaxed) {
|
||||
let sprite_count = texture_ids.len();
|
||||
log::info!("Engine submit_sprite_batch: {} sprites, texture_ids: {:?}", sprite_count, texture_ids);
|
||||
}
|
||||
|
||||
self.renderer.submit_batch(
|
||||
transforms,
|
||||
texture_ids,
|
||||
@@ -382,6 +374,24 @@ impl Engine {
|
||||
self.texture_manager.clear_all();
|
||||
}
|
||||
|
||||
/// 获取纹理加载状态
|
||||
/// Get texture loading state
|
||||
pub fn get_texture_state(&self, id: u32) -> crate::renderer::texture::TextureState {
|
||||
self.texture_manager.get_texture_state(id)
|
||||
}
|
||||
|
||||
/// 检查纹理是否已就绪
|
||||
/// Check if texture is ready to use
|
||||
pub fn is_texture_ready(&self, id: u32) -> bool {
|
||||
self.texture_manager.is_texture_ready(id)
|
||||
}
|
||||
|
||||
/// 获取正在加载中的纹理数量
|
||||
/// Get the number of textures currently loading
|
||||
pub fn get_texture_loading_count(&self) -> u32 {
|
||||
self.texture_manager.get_loading_count()
|
||||
}
|
||||
|
||||
/// Check if a key is currently pressed.
|
||||
/// 检查某个键是否当前被按下。
|
||||
pub fn is_key_down(&self, key_code: &str) -> bool {
|
||||
|
||||
Reference in New Issue
Block a user