41 lines
1007 B
C++
41 lines
1007 B
C++
#pragma once
|
|
|
|
#include <renderer/rhi/rhi.h>
|
|
#include <glad/glad.h>
|
|
|
|
namespace extra2d {
|
|
|
|
/**
|
|
* @brief OpenGL 纹理实现
|
|
*/
|
|
class GLTexture : public RHITexture {
|
|
public:
|
|
explicit GLTexture(const TextureDesc& desc);
|
|
~GLTexture() override;
|
|
|
|
bool create();
|
|
void destroy();
|
|
|
|
TextureType getType() const override { return desc_.type; }
|
|
TextureFormat getFormat() const override { return desc_.format; }
|
|
uint32_t getWidth() const override { return desc_.width; }
|
|
uint32_t getHeight() const override { return desc_.height; }
|
|
uint32_t getMipLevels() const override { return desc_.mipLevels; }
|
|
|
|
bool update(const void* data, uint32_t mipLevel = 0) override;
|
|
void generateMipmap() override;
|
|
void bind(uint32_t slot) override;
|
|
void unbind() override;
|
|
|
|
bool isValid() const override;
|
|
bool isRenderTarget() const override;
|
|
|
|
GLuint getGLTexture() const { return texture_; }
|
|
|
|
private:
|
|
TextureDesc desc_;
|
|
GLuint texture_;
|
|
};
|
|
|
|
} // namespace extra2d
|