mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-08-09 02:07:04 +08:00
* refactor(render): move render files to subdirectory, add RAII vertex buffer/array classes * refactor(render): encapsulate OpenGL textures into Texture class * refactor(texture): encapsulate textures with unique_ptr and bind methods Replace raw GLuint framebuffer textures with std::unique_ptr<Texture>. Update TextureManager to return const Texture* instead of GLuint. Use Texture::bind() for active texture binding. Add RGBA16F and RGB formats. Add texture parameter methods. Update destructors accordingly. * refactor(render): use Texture, VertexBuffer, VertexArray classes * feat(render): add FrameBuffer class to encapsulate framebuffer operations * refactor(render): extract world rendering into WorldRenderer class * refactor(render): rename projection and model matrix members for clarity * chore(render): remove unused matrix members * fix(texture-manager): correct delet_texture typo and add null checks for textures
46 lines
1.2 KiB
C++
46 lines
1.2 KiB
C++
#pragma once
|
|
#include "Cubed/render/texture.hpp"
|
|
|
|
#include <glad/glad.h>
|
|
#include <span>
|
|
|
|
enum class Attachment : GLenum {
|
|
COLOR_ATTACHMENT0 = GL_COLOR_ATTACHMENT0,
|
|
COLOR_ATTACHMENT1 = GL_COLOR_ATTACHMENT1,
|
|
DEPTH_ATTACHMENT = GL_DEPTH_ATTACHMENT
|
|
};
|
|
|
|
enum class FrameBufferType : GLenum {
|
|
FRAMEBUFFER = GL_FRAMEBUFFER,
|
|
READ_FRAMEBUFFER = GL_READ_FRAMEBUFFER,
|
|
DRAW_FRAMEBUFFER = GL_DRAW_FRAMEBUFFER
|
|
};
|
|
|
|
namespace Cubed {
|
|
class FrameBuffer {
|
|
public:
|
|
FrameBuffer();
|
|
~FrameBuffer();
|
|
FrameBuffer(const FrameBuffer&) = delete;
|
|
FrameBuffer(FrameBuffer&&) noexcept;
|
|
FrameBuffer& operator=(const FrameBuffer&) = delete;
|
|
FrameBuffer& operator=(FrameBuffer&&) noexcept;
|
|
|
|
void bind(FrameBufferType type = FrameBufferType::FRAMEBUFFER) const;
|
|
GLuint id() const;
|
|
|
|
void attach(Attachment attachment, const Texture& texture,
|
|
GLint level = 0) const;
|
|
static void unbind();
|
|
|
|
bool check_status() const;
|
|
|
|
void draw_buffer(GLenum buf) const;
|
|
void read_buffer(GLenum src) const;
|
|
void draw_buffer(GLsizei n, const GLenum* bufs) const;
|
|
void draw_buffer(std::span<const GLenum> bufs) const;
|
|
|
|
private:
|
|
GLuint m_fbo = 0;
|
|
};
|
|
} // namespace Cubed
|