UFO: Alien Invasion
Loading...
Searching...
No Matches
r_framebuffer.cpp File Reference

Framebuffer Objects support. More...

#include "r_local.h"
#include "r_framebuffer.h"
#include "r_error.h"
Include dependency graph for r_framebuffer.cpp:

Go to the source code of this file.

Functions

static GLuint R_GetFreeFBOTexture (void)
static void R_FreeFBOTexture (int texnum)
void R_InitFBObjects (void)
void R_DeleteFBObject (r_framebuffer_t *buf)
 Delete framebuffer object along with attached render buffer.
void R_ShutdownFBObjects (void)
 Delete all registered framebuffer and render buffer objects, clear memory.
r_framebuffer_tR_CreateFramebuffer (int width, int height, int ntextures, bool depth, bool halfFloat, unsigned int *filters)
 create a new framebuffer object
void R_ResolveMSAA (const r_framebuffer_t *buf)
 Forces multisample antialiasing resolve on given framebuffer, if needed.
void R_UseFramebuffer (const r_framebuffer_t *buf)
 bind specified framebuffer object so we render to it
void R_SetupViewport (r_framebuffer_t *buf, int x, int y, int width, int height)
 Sets the framebuffer dimensions of the viewport.
void R_UseViewport (const r_framebuffer_t *buf)
 Set the viewport to the dimensions of the given framebuffer.
void R_DrawBuffers (unsigned int drawBufferNum)
 Activate draw buffer(s).
void R_BindColorAttachments (unsigned int n, unsigned int *attachments)
 Activate draw buffer(s).
bool R_EnableRenderbuffer (bool enable)
 Enable the render to the framebuffer.
bool R_RenderbufferEnabled (void)

Variables

static int frameBufferObjectCount
static r_framebuffer_t frameBufferObjects [MAX_GL_FRAMEBUFFERS]
static GLuint frameBufferTextures [MAX_GL_FRAMEBUFFERS]
static r_framebuffer_t screenBuffer
static GLenumcolorAttachments

Detailed Description

Framebuffer Objects support.

Definition in file r_framebuffer.cpp.

Function Documentation

◆ R_BindColorAttachments()

void R_BindColorAttachments ( unsigned int n,
unsigned int * attachments )

Activate draw buffer(s).

Parameters
nThe number of buffers to activate
attachmentsThe buffers we are rendering into
Note
The order of the attachments define the gl_FragData order in the shaders

Definition at line 404 of file r_framebuffer.cpp.

References Com_DPrintf(), DEBUG_RENDERER, r_config, r_postprocess, r_programs, and r_state.

Referenced by R_DrawBuffers(), and R_UpdateGlowBufferBinding().

◆ R_CreateFramebuffer()

r_framebuffer_t * R_CreateFramebuffer ( int width,
int height,
int ntextures,
bool depth,
bool halfFloat,
unsigned int * filters )

create a new framebuffer object

Parameters
[in]widthThe width of the framebuffer
[in]heightThe height of the framebuffer
[in]ntexturesThe amount of textures for this framebuffer. See also the filters array.
[in]depthAlso generate a depth buffer
[in]halfFloatUse half float pixel format
[in]filtersFilters for the textures. Must have ntextures entries
Todo
also check if we are running on older (SM2.0) hardware, which doesn't support antialiased MRT

Definition at line 175 of file r_framebuffer.cpp.

References colorAttachments, Com_Printf(), frameBufferObjectCount, frameBufferObjects, GL_CLAMP, GL_DEPTH_ATTACHMENT_EXT, GL_DEPTH_COMPONENT, GL_FRAMEBUFFER_EXT, GL_RENDERBUFFER_EXT, glBindTexture(), glTexImage2D(), i, lengthof, Mem_AllocTypeN, OBJZERO, R_CheckError, r_config, R_GetFreeFBOTexture(), r_multisample, R_SetupViewport(), r_state, and Vector4Clear.

Referenced by R_InitFBObjects().

◆ R_DeleteFBObject()

void R_DeleteFBObject ( r_framebuffer_t * buf)

Delete framebuffer object along with attached render buffer.

Definition at line 126 of file r_framebuffer.cpp.

References i, Mem_Free, and R_FreeFBOTexture().

Referenced by R_ShutdownFBObjects().

◆ R_DrawBuffers()

void R_DrawBuffers ( unsigned int drawBufferNum)

Activate draw buffer(s).

Parameters
[in]drawBufferNumThe number of buffers to activate
Todo
introduce enum or speaking constants for the buffer numbers that are drawn here and elsewhere

Definition at line 393 of file r_framebuffer.cpp.

References colorAttachments, and R_BindColorAttachments().

Referenced by R_Draw3DGlobe(), R_EnableRenderbuffer(), and R_UpdateGlowBufferBinding().

◆ R_EnableRenderbuffer()

bool R_EnableRenderbuffer ( bool enable)

Enable the render to the framebuffer.

Parameters
enableIf true we are enabling the rendering to fbo_render, if false we are rendering to fbo that represents the screen
See also
R_DrawBuffers
Returns
true if the fbo was bound, false if not supported or deactivated

Definition at line 425 of file r_framebuffer.cpp.

References fbo_render, fbo_screen, r_config, R_DrawBuffers(), r_postprocess, r_programs, r_state, and R_UseFramebuffer().

Referenced by uiGeoscapeNode::draw(), R_DrawBloom(), R_Setup2D(), and R_Setup3D().

◆ R_FreeFBOTexture()

void R_FreeFBOTexture ( int texnum)
static

Definition at line 50 of file r_framebuffer.cpp.

References frameBufferTextures, i, and MAX_GL_FRAMEBUFFERS.

Referenced by R_DeleteFBObject().

◆ R_GetFreeFBOTexture()

GLuint R_GetFreeFBOTexture ( void )
static

◆ R_InitFBObjects()

◆ R_RenderbufferEnabled()

bool R_RenderbufferEnabled ( void )

Definition at line 443 of file r_framebuffer.cpp.

References r_state.

Referenced by R_DrawBloom().

◆ R_ResolveMSAA()

void R_ResolveMSAA ( const r_framebuffer_t * buf)

Forces multisample antialiasing resolve on given framebuffer, if needed.

Parameters
[in]bufthe framebuffer to use

Definition at line 296 of file r_framebuffer.cpp.

References GL_COLOR_ATTACHMENT0_EXT, GL_DRAW_FRAMEBUFFER_EXT, GL_FRAMEBUFFER_EXT, GL_READ_FRAMEBUFFER_EXT, i, R_CheckError, and screenBuffer.

Referenced by R_DrawBloom().

◆ R_SetupViewport()

void R_SetupViewport ( r_framebuffer_t * buf,
int x,
int y,
int width,
int height )

Sets the framebuffer dimensions of the viewport.

Parameters
[out]bufThe framebuffer to initialize the viewport for. If nullptr the screen buffer will be taken.
[in]x,yThe position
[in]width,heightThe dimensions
See also
R_UseViewport

Definition at line 362 of file r_framebuffer.cpp.

References screenBuffer.

Referenced by R_CreateFramebuffer(), and R_InitFBObjects().

◆ R_ShutdownFBObjects()

void R_ShutdownFBObjects ( void )

Delete all registered framebuffer and render buffer objects, clear memory.

Definition at line 148 of file r_framebuffer.cpp.

References colorAttachments, frameBufferObjectCount, frameBufferObjects, i, Mem_Free, OBJZERO, R_DeleteFBObject(), r_state, R_UseFramebuffer(), and screenBuffer.

Referenced by R_ReinitOpenglContext(), R_SetMode(), and R_Shutdown().

◆ R_UseFramebuffer()

void R_UseFramebuffer ( const r_framebuffer_t * buf)

bind specified framebuffer object so we render to it

Parameters
[in]bufthe framebuffer to use, if nullptr the screen buffer will be used.
Todo
buf != &screenBuffer

Definition at line 323 of file r_framebuffer.cpp.

References colorAttachments, Com_Printf(), GL_FRAMEBUFFER_EXT, R_CheckError, r_config, r_postprocess, r_programs, r_state, and screenBuffer.

Referenced by R_BlurStack(), R_DrawBloom(), R_EnableBlur(), R_EnableRenderbuffer(), and R_ShutdownFBObjects().

◆ R_UseViewport()

void R_UseViewport ( const r_framebuffer_t * buf)

Set the viewport to the dimensions of the given framebuffer.

Parameters
[out]bufThe framebuffer to set the viewport for. If nullptr the screen buffer will be taken.
See also
R_SetupViewport

Definition at line 378 of file r_framebuffer.cpp.

References r_config, r_postprocess, r_programs, r_state, and screenBuffer.

Referenced by R_Blur(), R_BlurStack(), and R_DrawBloom().

Variable Documentation

◆ colorAttachments

GLenum* colorAttachments
static

◆ frameBufferObjectCount

int frameBufferObjectCount
static

Definition at line 29 of file r_framebuffer.cpp.

Referenced by R_CreateFramebuffer(), R_InitFBObjects(), and R_ShutdownFBObjects().

◆ frameBufferObjects

r_framebuffer_t frameBufferObjects[MAX_GL_FRAMEBUFFERS]
static

Definition at line 30 of file r_framebuffer.cpp.

Referenced by R_CreateFramebuffer(), R_InitFBObjects(), and R_ShutdownFBObjects().

◆ frameBufferTextures

GLuint frameBufferTextures[MAX_GL_FRAMEBUFFERS]
static

Definition at line 31 of file r_framebuffer.cpp.

Referenced by R_FreeFBOTexture(), R_GetFreeFBOTexture(), and R_InitFBObjects().

◆ screenBuffer