#ifndef RENDER_SKYBOX_RENDERER_H
#define RENDER_SKYBOX_RENDERER_H

#include <d3d11.h>
#include <filesystem>
#include <wrl/client.h>

class TextureCube;

// [新增] 使用导入的 TextureCube 绘制相机背景。
// 天空盒在不透明物体之后绘制，深度固定在远平面，且不写入深度。
class SkyboxRenderer final {
public:
    static constexpr UINT TextureSlot = 12; // t12，避开材质、阴影与 IBL 槽位。
    static constexpr UINT SamplerSlot = 4;  // s4。

    [[nodiscard]] bool Initialize(
        ID3D11Device *device,
        const std::filesystem::path &shaderPath);

    void SetTexture(const TextureCube *textureCube) noexcept;
    void ClearTexture() noexcept;

    [[nodiscard]] bool IsReady() const noexcept;
    void Draw(ID3D11DeviceContext *context) const;

private:
    Microsoft::WRL::ComPtr<ID3D11VertexShader> m_vertexShader;
    Microsoft::WRL::ComPtr<ID3D11PixelShader> m_pixelShader;
    Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> m_cubeSrv;
    Microsoft::WRL::ComPtr<ID3D11SamplerState> m_sampler;
    Microsoft::WRL::ComPtr<ID3D11RasterizerState> m_rasterizerState;
    Microsoft::WRL::ComPtr<ID3D11DepthStencilState> m_depthStencilState;
};

#endif // RENDER_SKYBOX_RENDERER_H
