LightsprintSDK 2021.08.08
rr_gl::FBO Class Reference

#include <FBO.h>

Public Member Functions

void restore ()
 
 FBO ()
 

Static Public Member Functions

static void setRenderTarget (GLenum attachment, GLenum target, const Texture *texture, const FBO &oldState)
 
static void setRenderTargetGL (GLenum attachment, GLenum target, GLuint texture, const FBO &oldState)
 
static void setRenderBuffers (GLenum draw_buffer)
 
static bool isOk ()
 
static const FBOgetState ()
 

Detailed Description

Lets you set, save and restore render target.

Constructor & Destructor Documentation

◆ FBO()

rr_gl::FBO::FBO ( )

Initializes new instance of default framebuffer, without modifying OpenGL state. Calling restore() would restore default framebuffer.

Member Function Documentation

◆ setRenderTarget()

static void rr_gl::FBO::setRenderTarget ( GLenum  attachment,
GLenum  target,
const Texture texture,
const FBO oldState 
)
static

Sets render target.

Default (provided by windowing system) and non-default (texture) targets are never mixed, so by setting texture, any previous default render target is automatically unset. To render to custom color and depth textures, call setRenderTarget twice, once for each texture. To return back to default render target, call restore() on previously backed up state, or on newly constructed FBO.

Parameters
attachmentGL_DEPTH_ATTACHMENT or GL_COLOR_ATTACHMENT0.
targetGL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP_POSITIVE_X or _NEGATIVE_X or _POSITIVE_Y or _NEGATIVE_Y or _POSITIVE_Z or _NEGATIVE_Z.
textureTexture to be set as render target. May be nullptr. If you set both color and depth, sizes must match.
oldStateWhen setting nullptr color texture, setRenderBuffers(oldState.buffers) restores old buffers.

◆ setRenderTargetGL()

static void rr_gl::FBO::setRenderTargetGL ( GLenum  attachment,
GLenum  target,
GLuint  texture,
const FBO oldState 
)
static

Similar to setRenderTarget(), but with raw OpenGL texture id instead of Lightsprint Texture.

◆ setRenderBuffers()

static void rr_gl::FBO::setRenderBuffers ( GLenum  draw_buffer)
static

Wrapper for glDrawBuffer() and glReadBuffer().

It is used internally by setRenderTarget(), it is rarely needed outside. We only use it for setting left&right in quad buffered stereo. Possible parameters: GL_NONE, GL_COLOR_ATTACHMENT0, GL_BACK_LEFT, GL_BACK_RIGHT..

◆ isOk()

static bool rr_gl::FBO::isOk ( )
static

Check whether render target is set correctly (all textures the same size etc).

◆ getState()

static const FBO & rr_gl::FBO::getState ( )
static

Return current state, what textures are set as render target.

◆ restore()

void rr_gl::FBO::restore ( )

Restore saved state.