AronaCore/core/rhi/render_target.h
2024-02-19 01:33:18 +08:00

42 lines
991 B
C++

#pragma once
#include "render_resource.h"
#include "rhi_defintion.h"
enum class lock_state {
NONE,
WRITE,
READ,
READ_WRITE
};
class render_target : public render_resource {
public:
[[nodiscard]] int get_height() const override { return height_; }
[[nodiscard]] int get_width() const override { return width_; }
virtual void init(int width, int height, texture_format format) = 0;
virtual void resize(const int width, const int 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());
}
virtual void* lock(lock_state state) = 0;
virtual void unlock() = 0;
std::function<void(std::shared_ptr<render_resource>)> on_resize_callback;
protected:
virtual void on_resize(int width, int height) = 0;
int width_ = 0;
int height_ = 0;
};