GroveEngine/modules/BgfxRenderer/Passes/SpritePass.h
StillHammer 2f8e78b247 feat(BgfxRenderer): Phase 6 - Texture loading with stb_image
- Add TextureLoader class using stb_image for PNG/JPG/etc loading
- Integrate TextureLoader with ResourceCache for cached texture loading
- Add SpritePass::setTexture() for binding textures to sprites
- Add "defaultTexture" config option to load texture at startup
- Create assets/textures folder structure
- Add 1f440.png (eyes emoji) test texture

Visual test confirms textured sprites render correctly.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 19:44:13 +08:00

49 lines
1.7 KiB
C++

#pragma once
#include "../RenderGraph/RenderPass.h"
#include "../RHI/RHITypes.h"
namespace grove {
// ============================================================================
// Sprite Pass - Renders 2D sprites with batching
// ============================================================================
class SpritePass : public RenderPass {
public:
/**
* @brief Construct SpritePass with required shader
* @param shader The shader program to use for sprite rendering
*/
explicit SpritePass(rhi::ShaderHandle shader);
const char* getName() const override { return "Sprites"; }
uint32_t getSortOrder() const override { return 100; }
std::vector<const char*> getDependencies() const override { return {"Clear"}; }
void setup(rhi::IRHIDevice& device) override;
void shutdown(rhi::IRHIDevice& device) override;
void execute(const FramePacket& frame, rhi::IRHIDevice& device, rhi::RHICommandBuffer& cmd) override;
/**
* @brief Set a texture to use for all sprites (temporary API)
* @param texture The texture handle to use (must be valid)
*
* TODO: Replace with proper texture array / per-sprite texture support
*/
void setTexture(rhi::TextureHandle texture) { m_activeTexture = texture; }
private:
rhi::ShaderHandle m_shader;
rhi::BufferHandle m_quadVB;
rhi::BufferHandle m_quadIB;
rhi::BufferHandle m_instanceBuffer;
rhi::UniformHandle m_textureSampler;
rhi::TextureHandle m_defaultTexture; // White 1x1 texture fallback
rhi::TextureHandle m_activeTexture; // Currently active texture (if set)
static constexpr uint32_t MAX_SPRITES_PER_BATCH = 10000;
};
} // namespace grove