Josh's Graphics Library
JGL::RenderTarget Class Reference

#include <RenderTarget.h>

Public Member Functions

void Resize (const Vector2 &new_size)
 Change the size of the renderable area of the Render Target. More...
 
void SetMSAAEnabled (MSAA_SAMPLE_RATE sample_rate)
 
void Blit () const
 If you're using raw OpenGL commands to draw to this outside of J2D or J3D don't forget to do this. More...
 
bool TextureCreatedByRenderTarget () const
 
Vector2 GetDimensions () const
 
MSAA_SAMPLE_RATE GetMSAASampleRate () const
 
bool MSAAEnabled () const
 Returns whether or not MSAA is enabled, If it is and you're not using J2D || J3D Begin / End, You need to run "Blit()" after rendering to your FBO before you show it. More...
 
const TextureGetJGLTexture () const
 
GLuint GetGLTextureHandle () const
 
GLuint GetGLFramebufferObjectHandle () const
 
GLuint GetGLDepthBufferHandle () const
 
Color4 GetClearColor () const
 
std::vector< GLfloat > GetData () const
 Get the data back from the FBO. This is not async friendly. More...
 
 RenderTarget (const RenderTarget &rhs)
 Copy constructor. Will always set "texture_created_by_us" to true and use our own texture to avoid memleaks. More...
 
 RenderTarget (const Texture *texture, const Color4 &clear_color=Colors::Black)
 Create a render target for a texture that already exists. For adding to an existing texture. More...
 
 RenderTarget (const Vector2 &size, const Color4 &clear_color=Colors::Black, bool use_depth=false, MSAA_SAMPLE_RATE sample_rate=MSAA_SAMPLE_RATE::MSAA_NONE)
 Create a Render Target with a brand new texture. Want to render JGL elements onto a texture and display it as a sprite? More...
 
 ~RenderTarget ()
 

Static Public Member Functions

static GLuint GetActiveGLFramebufferHandle ()
 
static void SetActiveGLRenderTarget (const RenderTarget &render_target)
 
static void Blit (const RenderTarget &source, RenderTarget *destination)
 Blit a render target onto another. Will break if they're not the same size. More...
 

Constructor & Destructor Documentation

◆ RenderTarget() [1/3]

JGL::RenderTarget::RenderTarget ( const RenderTarget rhs)

Copy constructor. Will always set "texture_created_by_us" to true and use our own texture to avoid memleaks.

Here is the call graph for this function:

◆ RenderTarget() [2/3]

JGL::RenderTarget::RenderTarget ( const Texture texture,
const Color4 &  clear_color = Colors::Black 
)
explicit

Create a render target for a texture that already exists. For adding to an existing texture.

Idk why you'd ever want to clear it out if you're rendering onto a texture you passed in :shrug:.

Here is the call graph for this function:

◆ RenderTarget() [3/3]

JGL::RenderTarget::RenderTarget ( const Vector2 &  size,
const Color4 &  clear_color = Colors::Black,
bool  use_depth = false,
MSAA_SAMPLE_RATE  sample_rate = MSAA_SAMPLE_RATE::MSAA_NONE 
)
explicit

Create a Render Target with a brand new texture. Want to render JGL elements onto a texture and display it as a sprite?

◆ ~RenderTarget()

JGL::RenderTarget::~RenderTarget ( )

Member Function Documentation

◆ Blit() [1/2]

void JGL::RenderTarget::Blit ( ) const

If you're using raw OpenGL commands to draw to this outside of J2D or J3D don't forget to do this.

Blits the MSAA FBO onto the regular FBO if MSAA is enabled and or If you're rendering to a texture which uses mipmaps, It regenerates them so what you drew doesn't disappear at a distance. Otherwise it does nothing.

Here is the caller graph for this function:

◆ Blit() [2/2]

void JGL::RenderTarget::Blit ( const RenderTarget source,
JGL::RenderTarget destination 
)
static

Blit a render target onto another. Will break if they're not the same size.

◆ GetActiveGLFramebufferHandle()

GLuint JGL::RenderTarget::GetActiveGLFramebufferHandle ( )
static
Here is the caller graph for this function:

◆ GetClearColor()

Color4 JGL::RenderTarget::GetClearColor ( ) const
Here is the caller graph for this function:

◆ GetData()

std::vector< GLfloat > JGL::RenderTarget::GetData ( ) const

Get the data back from the FBO. This is not async friendly.

◆ GetDimensions()

Vector2 JGL::RenderTarget::GetDimensions ( ) const
Here is the caller graph for this function:

◆ GetGLDepthBufferHandle()

GLuint JGL::RenderTarget::GetGLDepthBufferHandle ( ) const

◆ GetGLFramebufferObjectHandle()

GLuint JGL::RenderTarget::GetGLFramebufferObjectHandle ( ) const
Here is the caller graph for this function:

◆ GetGLTextureHandle()

GLuint JGL::RenderTarget::GetGLTextureHandle ( ) const

◆ GetJGLTexture()

const JGL::Texture * JGL::RenderTarget::GetJGLTexture ( ) const
Here is the caller graph for this function:

◆ GetMSAASampleRate()

JGL::MSAA_SAMPLE_RATE JGL::RenderTarget::GetMSAASampleRate ( ) const

◆ MSAAEnabled()

bool JGL::RenderTarget::MSAAEnabled ( ) const

Returns whether or not MSAA is enabled, If it is and you're not using J2D || J3D Begin / End, You need to run "Blit()" after rendering to your FBO before you show it.

Note
Also, If the texture wasn't made by the RenderTarget you don't want this. It would destroy the texture.
Here is the caller graph for this function:

◆ Resize()

void JGL::RenderTarget::Resize ( const Vector2 &  new_size)

Change the size of the renderable area of the Render Target.

Parameters
new_sizenew size in px.

◆ SetActiveGLRenderTarget()

void JGL::RenderTarget::SetActiveGLRenderTarget ( const RenderTarget render_target)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetMSAAEnabled()

void JGL::RenderTarget::SetMSAAEnabled ( JGL::MSAA_SAMPLE_RATE  sample_rate)

◆ TextureCreatedByRenderTarget()

bool JGL::RenderTarget::TextureCreatedByRenderTarget ( ) const
Here is the caller graph for this function:

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