Extra2D/include/renderer/rhi_module.h

114 lines
2.5 KiB
C
Raw Normal View History

#pragma once
#include <event/events.h>
#include <module/module.h>
#include <module/module_registry.h>
#include <renderer/rhi/rhi.h>
#include <memory>
namespace extra2d {
/**
* @brief RHI
*
* RHI API
* 1 WindowModule
*/
class RHIModule : public Module {
E2D_REGISTER_MODULE(RHIModule, "RHI", 1)
public:
RHIModule();
~RHIModule() override;
/**
* @brief RHI
* @return
*/
bool init() override;
/**
* @brief RHI
*/
void shutdown() override;
/**
* @brief RHI
* @return RHI
*/
RHIDevice* getDevice() const { return device_.get(); }
/**
* @brief RHI
* @return RHI
*/
RHIContext* getContext() const { return context_; }
/**
* @brief RHIModule
* @return RHIModule
*/
static RHIModule* get();
/**
* @brief RHI
* @return
*/
bool isInitialized() const { return initialized_; }
/**
* @brief
* @param desc
* @return
*/
std::unique_ptr<RHIBuffer> createBuffer(const BufferDesc& desc);
/**
* @brief
* @param desc
* @return
*/
std::unique_ptr<RHITexture> createTexture(const TextureDesc& desc);
/**
* @brief
* @param desc
* @return
*/
std::unique_ptr<RHIShader> createShader(const ShaderDesc& desc);
/**
* @brief 线
* @param desc 线
* @return 线
*/
std::unique_ptr<RHIPipeline> createPipeline(const PipelineDesc& desc);
/**
* @brief
* @param desc
* @return
*/
std::unique_ptr<RHIFramebuffer> createFramebuffer(const RenderPassDesc& desc);
/**
* @brief
* @return
*/
std::unique_ptr<RHICommandList> createCommandList();
private:
/**
* @brief - OpenGL
*/
void onWindowShow();
private:
std::unique_ptr<RHIDevice> device_;
RHIContext* context_;
bool initialized_ = false;
std::unique_ptr<events::OnShow::Listener> onShowListener_;
};
} // namespace extra2d