#pragma once // ============================================================================ // texture.h - 纹理加载 (WIC) // ============================================================================ #include #include typedef struct { ID3D11Texture2D* texture; ID3D11ShaderResourceView* srv; uint32_t width; uint32_t height; uint32_t mip_levels; } Texture; // 创建/销毁 Texture* texture_create(void); void texture_destroy(Texture* texture); // 从文件加载 Texture* texture_load_from_file(ID3D11Device* device, const char* path); // 从内存加载 Texture* texture_load_from_memory(ID3D11Device* device, const uint8_t* data, uint32_t size); // 创建纯色纹理 Texture* texture_create_solid(ID3D11Device* device, uint32_t w, uint32_t h, uint8_t r, uint8_t g, uint8_t b, uint8_t a); // 创建棋盘格 Texture* texture_create_checkerboard(ID3D11Device* device, uint32_t size, uint32_t checks); // 绑定 void texture_bind(Texture* texture, ID3D11DeviceContext* ctx, uint32_t slot);