Files
2026-06-08 19:58:35 +08:00

35 lines
806 B
C++

#pragma once
#include <frostbite2D/base/RefObject.h>
#include <frostbite2D/graphics/texture.h>
namespace frostbite2D {
class Renderer;
/// @brief 2D 离屏渲染目标,封装颜色纹理和对应的 framebuffer。
class RenderTexture : public RefObject {
public:
RenderTexture() = default;
~RenderTexture() override;
bool Init(int width, int height);
bool Resize(int width, int height);
void Reset();
bool IsValid() const { return framebufferID_ != 0 && texture_ != nullptr; }
int GetWidth() const { return width_; }
int GetHeight() const { return height_; }
Ptr<Texture> GetTexture() const { return texture_; }
private:
Ptr<Texture> texture_ = nullptr;
uint32 framebufferID_ = 0;
int width_ = 0;
int height_ = 0;
friend class Renderer;
};
} // namespace frostbite2D