Jopnal Engine  alpha 0.4
Simple Component Based 2D/3D Game Engine
Public Types | Public Member Functions | Static Public Member Functions | List of all members
jop::RenderTexture Class Reference

#include <RenderTexture.hpp>

Inheritance diagram for jop::RenderTexture:
jop::RenderTarget jop::MainRenderTarget

Public Types

enum  Slot {
  Slot::Depth, Slot::Stencil, Slot::DepthStencil, Slot::Color0,
  Slot::__Count
}
 
- Public Types inherited from jop::RenderTarget
enum  { ColorBit = 1, DepthBit = 1 << 1, StencilBit = 1 << 2, AllBit = ColorBit | DepthBit | StencilBit }
 

Public Member Functions

 RenderTexture ()
 Constructor. More...
 
 ~RenderTexture () override
 Destructor. More...
 
bool addTextureAttachment (const Slot slot, const Texture::Format format)
 Add a texture attachment. More...
 
bool addCubemapAttachment (const Slot slot, const Texture::Format format)
 Add a cube map attachment. More...
 
bool addRenderbufferAttachment (const Slot slot, const Texture::Format format)
 Add a render buffer attachment. More...
 
void destroy (const bool framebuffer, const bool attachments)
 Destroy this frame buffer. More...
 
bool bind () const override
 Bind this frame buffer for drawing. More...
 
bool bindRead () const
 Bind this frame buffer for reading. More...
 
bool bindDraw () const
 Bind this frame buffer for drawing. More...
 
bool bindCubeFace (const Slot slot, const Cubemap::Face face) const
 Bind cube map face. More...
 
void setSize (const glm::uvec2 &size)
 Set the size for attachments. More...
 
glm::uvec2 getSize () const override
 Get the frame buffer texture size. More...
 
bool isValid () const
 Check if this frame buffer is valid. More...
 
TexturegetTextureAttachment (const Slot slot)
 Get a texture attachment. More...
 
const TexturegetTextureAttachment (const Slot slot) const
 Get a texture attachment. More...
 
- Public Member Functions inherited from jop::RenderTarget
 RenderTarget ()
 Constructor. More...
 
virtual ~RenderTarget ()=0
 Virtual destructor. More...
 
void clear (const unsigned int bits)
 Clear the selected buffers. More...
 
RenderTargetsetClearColor (const Color &color)
 Set the clear color. More...
 
Color getClearColor () const
 Get the clear color. More...
 
RenderTargetsetClearDepth (const float depth)
 Set the clear depth. More...
 
float getClearDepth () const
 Get the clear depth value. More...
 
RenderTargetsetClearStencil (const int stencil)
 Set the clear stencil. More...
 
int getClearStencil () const
 Get the clear stencil value. More...
 

Static Public Member Functions

static void unbind ()
 Unbind the currently bound draw frame buffer. More...
 
static unsigned int getMaximumRenderbufferSize ()
 Get the maximum render buffer size. More...
 

Additional Inherited Members

- Protected Attributes inherited from jop::RenderTarget
std::recursive_mutex m_mutex
 Mutex. More...
 

Detailed Description

Definition at line 42 of file RenderTexture.hpp.

Member Enumeration Documentation

Color attachment slot

Enumerator
Depth 

Depth attachment slot.

Stencil 

Stencil attachment slot.

DepthStencil 

Depth-stencil attachment slot.

Color0 

First color attachment slot.

__Count 

For internal functionality, do not use.

Definition at line 52 of file RenderTexture.hpp.

Constructor & Destructor Documentation

jop::RenderTexture::RenderTexture ( )

Constructor.

Doesn't initialize the frame buffer.

jop::RenderTexture::~RenderTexture ( )
override

Destructor.

Member Function Documentation

bool jop::RenderTexture::addCubemapAttachment ( const Slot  slot,
const Texture::Format  format 
)

Add a cube map attachment.

Parameters
slotThe attachment slot
formatThe cube map format
Returns
True if added successfully
bool jop::RenderTexture::addRenderbufferAttachment ( const Slot  slot,
const Texture::Format  format 
)

Add a render buffer attachment.

This will always return false when the size hasn't been set.

Parameters
slotThe attachment slot
formatThe render buffer format
Returns
True if added successfully
See also
getMaximumRenderbufferSize()
setSize()
bool jop::RenderTexture::addTextureAttachment ( const Slot  slot,
const Texture::Format  format 
)

Add a texture attachment.

This will always return false when the size hasn't been set.

Parameters
slotThe attachment slot
formatThe texture format
Returns
True if added successfully
See also
setSize()
bool jop::RenderTexture::bind ( ) const
overridevirtual

Bind this frame buffer for drawing.

Returns
True if successful

Implements jop::RenderTarget.

bool jop::RenderTexture::bindCubeFace ( const Slot  slot,
const Cubemap::Face  face 
) const

Bind cube map face.

Note
This will also bind the frame buffer object as the draw frame buffer
Warning
If the texture in the slot is not actually a cube map, but a regular 2D texture, it will be bound instead
Parameters
slotThe attachment slot
faceThe cube map face to bind
Returns
True if successful
bool jop::RenderTexture::bindDraw ( ) const

Bind this frame buffer for drawing.

Returns
True if successful
bool jop::RenderTexture::bindRead ( ) const

Bind this frame buffer for reading.

Returns
True if successful
void jop::RenderTexture::destroy ( const bool  framebuffer,
const bool  attachments 
)

Destroy this frame buffer.

Parameters
framebufferDestroy the frame buffer object?
attachmentsDestroy the attachments?
static unsigned int jop::RenderTexture::getMaximumRenderbufferSize ( )
static

Get the maximum render buffer size.

Returns
The maximum render buffer size
glm::uvec2 jop::RenderTexture::getSize ( ) const
overridevirtual

Get the frame buffer texture size.

Returns
The size in pixels

Implements jop::RenderTarget.

Texture* jop::RenderTexture::getTextureAttachment ( const Slot  slot)

Get a texture attachment.

Parameters
slotThe attachment slot
Returns
Pointer to the texture. nullptr if none exists in the slot
const Texture* jop::RenderTexture::getTextureAttachment ( const Slot  slot) const

Get a texture attachment.

Parameters
slotThe attachment slot
Returns
Pointer to the texture. nullptr if none exists in the slot
bool jop::RenderTexture::isValid ( ) const

Check if this frame buffer is valid.

Returns
True if valid
void jop::RenderTexture::setSize ( const glm::uvec2 &  size)

Set the size for attachments.

Must be called before attempting to add attachments. Has no effect when already called once before destroy().

Parameters
sizeThe size to set
static void jop::RenderTexture::unbind ( )
static

Unbind the currently bound draw frame buffer.

Rebinds the window as the frame buffer


The documentation for this class was generated from the following file: