AronaCore/core/rhi/render_target.h
2024-02-20 14:09:44 +08:00

39 lines
862 B
C++

#pragma once
#include <vulkan/vulkan.hpp>
#include "render_resource.h"
enum class lock_state {
NONE,
WRITE,
READ,
READ_WRITE
};
class render_target : public render_resource {
public:
void resize(const uint32_t width, const uint32_t height) {
if (width_ == width && height_ == height)
return;
width_ = width;
height_ = height;
on_resize(width, height);
if (on_resize_callback)
on_resize_callback(shared_from_this());
}
void* lock(lock_state state) const;
void unlock();
void destroy() override;
std::function<void(std::shared_ptr<render_resource>)> on_resize_callback;
vk::Framebuffer framebuffer;
protected:
void create(uint32_t width, uint32_t height);
void on_init() override;
void on_resize(uint32_t width, uint32_t height);
};