frame buffer

main
Brett 2024-04-16 03:20:35 -04:00
parent 722ae6fa6f
commit 321379fb12
3 changed files with 50 additions and 3 deletions

View File

@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.25) cmake_minimum_required(VERSION 3.25)
set(BLT_GRAPHICS_VERSION 0.9.12) set(BLT_GRAPHICS_VERSION 0.9.13)
set(BLT_GRAPHICS_TEST_VERSION 0.0.1) set(BLT_GRAPHICS_TEST_VERSION 0.0.1)
project(BLT_WITH_GRAPHICS VERSION ${BLT_GRAPHICS_VERSION}) project(BLT_WITH_GRAPHICS VERSION ${BLT_GRAPHICS_VERSION})

View File

@ -19,9 +19,32 @@
#ifndef BLT_WITH_GRAPHICS_FRAMEBUFFER_H #ifndef BLT_WITH_GRAPHICS_FRAMEBUFFER_H
#define BLT_WITH_GRAPHICS_FRAMEBUFFER_H #define BLT_WITH_GRAPHICS_FRAMEBUFFER_H
#include "blt/gfx/gl_includes.h"
namespace blt::gfx namespace blt::gfx
{ {
class fbo_t
{
public:
enum class fbo_draw_t : GLuint
{
DRAW = GL_DRAW_FRAMEBUFFER,
READ = GL_READ_FRAMEBUFFER,
BOTH = GL_FRAMEBUFFER
};
private:
GLuint fboID;
public:
void create();
void bind(fbo_draw_t type = fbo_draw_t::BOTH) const;
bool validate();
static void unbind();
void destroy();
};
} }
#endif //BLT_WITH_GRAPHICS_FRAMEBUFFER_H #endif //BLT_WITH_GRAPHICS_FRAMEBUFFER_H

View File

@ -18,5 +18,29 @@
namespace blt::gfx namespace blt::gfx
{ {
void fbo_t::create()
{
glGenFramebuffers(1, &fboID);
}
void fbo_t::bind(fbo_draw_t type) const
{
glBindFramebuffer(static_cast<GLuint>(type), fboID);
}
void fbo_t::unbind()
{
glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
void fbo_t::destroy()
{
}
bool fbo_t::validate()
{
return glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE;
}
} }