r_framebuffer.c File Reference

Framebuffer Objects support. More...

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

Go to the source code of this file.

Defines

#define MAX_FRAMEBUFFER_OBJECTS   64

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, qboolean depth, qboolean halfFloat, unsigned int *filters)
 create a new framebuffer object
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 (int n)
void R_BindColorAttachments (int n, unsigned int *attachments)
qboolean R_EnableRenderbuffer (qboolean enable)
qboolean R_RenderbufferEnabled (void)

Variables

static int frameBufferObjectCount
static r_framebuffer_t frameBufferObjects [MAX_FRAMEBUFFER_OBJECTS]
static GLuint frameBufferTextures [TEXNUM_FRAMEBUFFER_TEXTURES]
static r_framebuffer_t screenBuffer
static GLenum * colorAttachments

Detailed Description

Framebuffer Objects support.

Definition in file r_framebuffer.c.


Define Documentation

#define MAX_FRAMEBUFFER_OBJECTS   64

Definition at line 29 of file r_framebuffer.c.


Function Documentation

void R_BindColorAttachments ( int  n,
unsigned int *  attachments 
)
r_framebuffer_t* R_CreateFramebuffer ( int  width,
int  height,
int  ntextures,
qboolean  depth,
qboolean  halfFloat,
unsigned int *  filters 
)

create a new framebuffer object

Parameters:
[in] width The width of the framebuffer
[in] height The height of the framebuffer
[in] ntextures The amount of textures for this framebuffer. See also the filters array.
[in] depth Also generate a depth buffer
[in] halfFloat Use half float pixel format
[in] filters Filters for the textures. Must have ntextures entries

Definition at line 174 of file r_framebuffer.c.

References rconfig_t::anisotropic, r_framebuffer_t::byteFormat, r_framebuffer_t::clearColor, colorAttachments, Com_Printf(), r_framebuffer_t::depth, r_framebuffer_t::fbo, frameBufferObjectCount, rstate_t::frameBufferObjectsInitialized, r_framebuffer_t::height, i, lengthof, rconfig_t::maxAnisotropic, rconfig_t::maxDrawBuffers, Mem_Alloc, r_framebuffer_t::nTextures, r_framebuffer_t::pixelFormat, qtrue, R_CheckError, r_config, R_GetFreeFBOTexture(), R_SetupViewport(), r_state, r_framebuffer_t::textures, Vector4Clear, and r_framebuffer_t::width.

Referenced by R_InitFBObjects().

void R_DeleteFBObject ( r_framebuffer_t buf  ) 

Delete framebuffer object along with attached render buffer.

Definition at line 122 of file r_framebuffer.c.

References r_framebuffer_t::depth, r_framebuffer_t::fbo, i, Mem_Free, r_framebuffer_t::nTextures, R_FreeFBOTexture(), and r_framebuffer_t::textures.

Referenced by R_ShutdownFBObjects().

void R_DrawBuffers ( int  n  ) 
Todo:
introduce enum or speaking constants for the buffer numbers that are drawn here and elsewhere

Definition at line 327 of file r_framebuffer.c.

References colorAttachments, and R_BindColorAttachments().

Referenced by R_Draw3DGlobe(), R_EnableDrawAsGlow(), R_EnableGlowMap(), and R_EnableRenderbuffer().

qboolean R_EnableRenderbuffer ( qboolean  enable  ) 
static void R_FreeFBOTexture ( int  texnum  )  [static]

Definition at line 52 of file r_framebuffer.c.

References frameBufferTextures, i, and TEXNUM_FRAMEBUFFER_TEXTURES.

Referenced by R_DeleteFBObject().

static GLuint R_GetFreeFBOTexture ( void   )  [static]

Definition at line 38 of file r_framebuffer.c.

References Com_Error(), ERR_FATAL, frameBufferTextures, i, and TEXNUM_FRAMEBUFFER_TEXTURES.

Referenced by R_CreateFramebuffer().

void R_InitFBObjects ( void   ) 
qboolean R_RenderbufferEnabled ( void   ) 

Definition at line 364 of file r_framebuffer.c.

References r_state, and rstate_t::renderbuffer_enabled.

Referenced by R_DrawBloom().

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

Sets the framebuffer dimensions of the viewport.

Parameters:
[out] buf The framebuffer to initialize the viewport for. If NULL the screen buffer will be taken.
See also:
R_UseViewport

Definition at line 300 of file r_framebuffer.c.

References r_viewport_t::height, r_framebuffer_t::viewport, r_viewport_t::width, r_viewport_t::x, and r_viewport_t::y.

Referenced by R_CreateFramebuffer(), and R_InitFBObjects().

void R_ShutdownFBObjects ( void   ) 

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

Definition at line 145 of file r_framebuffer.c.

References colorAttachments, frameBufferObjectCount, rstate_t::frameBufferObjectsInitialized, i, Mem_Free, qfalse, R_DeleteFBObject(), r_state, and R_UseFramebuffer().

Referenced by R_SetMode(), and R_Shutdown().

void R_UseFramebuffer ( const r_framebuffer_t buf  ) 

bind specified framebuffer object so we render to it

Parameters:
[in] buf the framebuffer to use, if NULL the screen buffer will be used.

Todo:
buf != &screenBuffer

Definition at line 263 of file r_framebuffer.c.

References rstate_t::activeFramebuffer, r_framebuffer_t::clearColor, colorAttachments, Com_Printf(), r_framebuffer_t::depth, r_framebuffer_t::fbo, rconfig_t::frameBufferObject, rstate_t::frameBufferObjectsInitialized, cvar_s::integer, r_framebuffer_t::nTextures, R_CheckError, r_config, r_postprocess, r_programs, and r_state.

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

void R_UseViewport ( const r_framebuffer_t buf  ) 

Set the viewport to the dimensions of the given framebuffer.

Parameters:
[out] buf The framebuffer to set the viewport for. If NULL the screen buffer will be taken.
See also:
R_SetupViewport

Definition at line 316 of file r_framebuffer.c.

References rconfig_t::frameBufferObject, rstate_t::frameBufferObjectsInitialized, r_viewport_t::height, cvar_s::integer, r_config, r_postprocess, r_programs, r_state, r_framebuffer_t::viewport, r_viewport_t::width, r_viewport_t::x, and r_viewport_t::y.

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


Variable Documentation

GLenum* colorAttachments [static]
int frameBufferObjectCount [static]

Definition at line 31 of file r_framebuffer.c.

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

r_framebuffer_t frameBufferObjects[MAX_FRAMEBUFFER_OBJECTS] [static]

Definition at line 32 of file r_framebuffer.c.

GLuint frameBufferTextures[TEXNUM_FRAMEBUFFER_TEXTURES] [static]

Definition at line 33 of file r_framebuffer.c.

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

Definition at line 35 of file r_framebuffer.c.


Generated by  doxygen 1.6.2