Game of Ur 0.3.3
This is a computer adaptation of Game of Ur, written in C++ mainly using SDL and OpenGL.
|
A wrapper class over OpenGL framebuffers. More...
#include <framebuffer.hpp>
Public Member Functions | |
Framebuffer (GLuint framebuffer, glm::vec2 dimensions, GLuint nColorAttachments, const std::vector< std::shared_ptr< Texture > > &colorBuffers, std::unique_ptr< RBO > rbo) | |
Assuming an allocated OpenGL framebuffer already exists, constructs a Framebuffer object and hands over resources passed as arguments. | |
~Framebuffer () override | |
Destroys the framebuffer object. | |
Framebuffer (const Framebuffer &other) | |
Framebuffer (Framebuffer &&other) | |
Framebuffer & | operator= (const Framebuffer &other) |
Framebuffer & | operator= (Framebuffer &&other) |
std::size_t | addTargetColorBufferHandle (std::shared_ptr< Texture > colorBufferHandle) |
Attaches a new color buffer to this framebuffer. | |
std::vector< std::shared_ptr< const Texture > > | getTargetColorBufferHandles () const |
Returns a vector of handles to this framebuffer's color buffers. | |
const std::vector< std::shared_ptr< Texture > > & | getTargetColorBufferHandles () |
Returns a constant vector of handles to this framebuffer's color buffers. | |
bool | hasAttachedRBO () const |
Answers whether this framebuffer has an RBO attached. | |
bool | hasOwnRBO () const |
Answers whether an RBO description was specified when creating this framebuffer. | |
RBO & | getOwnRBO () |
Gets the RBO owned by this framebuffer. | |
void | attachRBO (RBO &rbo) |
Attaches the RBO (of possibly another framebuffer) to this framebuffer object. | |
void | detachRBO () |
Detaches any RBOs currently attached to this framebuffer. | |
void | bind () |
Makes this framebuffer the currently active framebuffer in this OpenGL context. | |
glm::u16vec2 | getDimensions () const |
Gets the dimensions specified for this framebuffer. | |
void | unbind () |
Unbind this framebuffer (or in other words, bind the default framebuffer) | |
![]() | |
std::string | getResourceTypeName_ () const override |
Get the resource type string for this resource. | |
![]() | |
virtual | ~IResource ()=default |
Destroy the IResource object. | |
Static Public Member Functions | |
static std::string | getResourceTypeName () |
Gets the resource type string associated with the Framebuffer resource. | |
Private Member Functions | |
void | attachRBO_ (RBO &rbo) |
Attaches an RBO associated with another Framebuffer to this object. | |
void | detachRBO_ () |
Unbinds any RBO currently attached to this framebuffer. | |
void | destroyResource () |
Destroys resources associated with this framebuffer. | |
void | releaseResource () |
Releases resources associated with this framebuffer, allowing other object(s) to manage them instead. | |
void | copyResource (const Framebuffer &other) |
Copies resources associated with another framebuffer. | |
void | stealResource (Framebuffer &other) |
Steals resources associated with another framebuffer. | |
Private Attributes | |
GLuint | mID {} |
The ID corresponding to this framebuffer. | |
std::unique_ptr< RBO > | mOwnRBO {} |
The RBO owned by this framebuffer, if such a one exists. | |
GLuint | mNColorAttachments {} |
The number of color attachments active on this framebuffer when render is called. | |
glm::vec2 | mDimensions {} |
The dimensions, in pixels, for textures attached to this framebuffer. | |
std::vector< std::shared_ptr< Texture > > | mTextureHandles {} |
All color buffers associated with this framebuffer, owned by this framebuffer. | |
bool | mHasAttachedRBO { false } |
Tracks whether an RBO was attached to this framebuffer (including ones that aren't owned by it). | |
Additional Inherited Members | |
![]() | |
Resource (int explicitlyInitializeMe) | |
Construct a new resource object. | |
![]() | |
IResource ()=default | |
Construct a new IResource object. | |
![]() | |
template<typename TResource> | |
static void | RegisterResource () |
Registers this resource as a Resource type with the ResourceDatabase. | |
A wrapper class over OpenGL framebuffers.
Framebuffers are, in essence, a collection of buffers that relate to each other in some way. Each framebuffer must have either an RBO or color buffer or both, and may have multiple color buffers. Their actual usage depends on the requirements of the program or module using them.
The window to which an application renders is also a texture belonging to a special framebuffer, managed by default by OpenGL itself, with an ID of 0.
Framebuffer::Framebuffer | ( | GLuint | framebuffer, |
glm::vec2 | dimensions, | ||
GLuint | nColorAttachments, | ||
const std::vector< std::shared_ptr< Texture > > & | colorBuffers, | ||
std::unique_ptr< RBO > | rbo ) |
Assuming an allocated OpenGL framebuffer already exists, constructs a Framebuffer object and hands over resources passed as arguments.
framebuffer | The ID of the framebuffer being given to this object. |
dimensions | The dimensions of the framebuffer, in pixels. |
nColorAttachments | The number of color attachments in use by this framebuffer. |
colorBuffers | Handles to the actual color buffers in use by this framebuffer. |
rbo | A reference to the RBO being used by this framebuffer. |
std::size_t Framebuffer::addTargetColorBufferHandle | ( | std::shared_ptr< Texture > | colorBufferHandle | ) |
Attaches a new color buffer to this framebuffer.
colorBufferHandle | A handle to the color buffer being attached. |
void Framebuffer::attachRBO | ( | RBO & | rbo | ) |
|
private |
Attaches an RBO associated with another Framebuffer to this object.
rbo | The RBO being attached. |
|
private |
Copies resources associated with another framebuffer.
other | The framebuffer being copied from. |
|
inline |
Gets the dimensions specified for this framebuffer.
RBO & Framebuffer::getOwnRBO | ( | ) |
|
inlinestatic |
Gets the resource type string associated with the Framebuffer resource.
const std::vector< std::shared_ptr< Texture > > & Framebuffer::getTargetColorBufferHandles | ( | ) |
Returns a constant vector of handles to this framebuffer's color buffers.
std::vector< std::shared_ptr< const Texture > > Framebuffer::getTargetColorBufferHandles | ( | ) | const |
Returns a vector of handles to this framebuffer's color buffers.
bool Framebuffer::hasAttachedRBO | ( | ) | const |
bool Framebuffer::hasOwnRBO | ( | ) | const |
|
private |
Steals resources associated with another framebuffer.
other | The framebuffer being stolen from. |