GroveEngine/modules/BgfxRenderer/BgfxRendererModule.h
StillHammer 5cef0e25b0 fix: UIModule button interaction + JsonDataNode array children support
- Fix JsonDataNode::getChildReadOnly() to handle JSON array access by numeric index
- Fix test_ui_showcase to use JSON array for children (matching test_single_button pattern)
- Add visual test files: test_single_button, test_ui_showcase, test_sprite_debug
- Clean up debug logging from SpritePass, SceneCollector, UIButton, BgfxDevice

The root cause was that UITree couldn't access array children in JSON layouts.
UIButton hover/click now works correctly in both test files.

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

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-05 18:23:16 +07:00

96 lines
2.7 KiB
C++

#pragma once
#include <grove/IModule.h>
#include <grove/IDataNode.h>
#include <grove/IIO.h>
#include <memory>
#include <string>
namespace spdlog { class logger; }
namespace grove {
namespace rhi { class IRHIDevice; }
class FrameAllocator;
class RenderGraph;
class SceneCollector;
class ResourceCache;
class ShaderManager;
class SpritePass;
class DebugOverlay;
// ============================================================================
// BgfxRenderer Module - 2D rendering via bgfx
// ============================================================================
class BgfxRendererModule : public IModule {
public:
BgfxRendererModule();
~BgfxRendererModule() override;
// ========================================
// IModule Interface
// ========================================
void setConfiguration(const IDataNode& config, IIO* io, ITaskScheduler* scheduler) override;
void process(const IDataNode& input) override;
void shutdown() override;
std::unique_ptr<IDataNode> getState() override;
void setState(const IDataNode& state) override;
const IDataNode& getConfiguration() override;
std::unique_ptr<IDataNode> getHealthStatus() override;
std::string getType() const override { return "bgfx_renderer"; }
bool isIdle() const override { return true; }
private:
// Logger
std::shared_ptr<spdlog::logger> m_logger;
// Core systems
std::unique_ptr<rhi::IRHIDevice> m_device;
std::unique_ptr<FrameAllocator> m_frameAllocator;
std::unique_ptr<ShaderManager> m_shaderManager;
std::unique_ptr<RenderGraph> m_renderGraph;
std::unique_ptr<SceneCollector> m_sceneCollector;
std::unique_ptr<ResourceCache> m_resourceCache;
std::unique_ptr<DebugOverlay> m_debugOverlay;
// Pass references (non-owning, owned by RenderGraph)
SpritePass* m_spritePass = nullptr;
// IIO (non-owning)
IIO* m_io = nullptr;
// Config (from IDataNode)
uint16_t m_width = 1280;
uint16_t m_height = 720;
std::string m_backend = "opengl";
std::string m_shaderPath = "./shaders";
bool m_vsync = true;
int m_maxSprites = 10000;
std::unique_ptr<IDataNode> m_configCache;
// Stats
uint64_t m_frameCount = 0;
};
} // namespace grove
// ============================================================================
// C Export (required for dlopen)
// ============================================================================
#ifdef _WIN32
#define GROVE_MODULE_EXPORT __declspec(dllexport)
#else
#define GROVE_MODULE_EXPORT
#endif
extern "C" {
GROVE_MODULE_EXPORT grove::IModule* createModule();
GROVE_MODULE_EXPORT void destroyModule(grove::IModule* module);
}