Shader (GLSL) backend functions. More...
#include "r_local.h"
#include "r_error.h"
#include "../../shared/parse.h"
#include "../../shared/shared.h"
Go to the source code of this file.
Defines | |
#define | SHADER_BUF_SIZE 16384 |
#define | FILTER_SIZE 3 |
width of convolution filter (for blur/bloom effects) | |
Functions | |
void | R_UseProgram (r_program_t *prog) |
static r_progvar_t * | R_ProgramVariable (int type, const char *name) |
void | R_ProgramParameter1i (const char *name, GLint value) |
void | R_ProgramParameter1f (const char *name, GLfloat value) |
void | R_ProgramParameter1fvs (const char *name, GLint size, GLfloat *value) |
void | R_ProgramParameter2fv (const char *name, GLfloat *value) |
void | R_ProgramParameter2fvs (const char *name, GLint size, GLfloat *value) |
void | R_ProgramParameter3fv (const char *name, GLfloat *value) |
void | R_ProgramParameter4fv (const char *name, GLfloat *value) |
void | R_AttributePointer (const char *name, GLuint size, const GLvoid *array) |
void | R_EnableAttribute (const char *name) |
void | R_DisableAttribute (const char *name) |
static void | R_ShutdownShader (r_shader_t *sh) |
static void | R_ShutdownProgram (r_program_t *prog) |
void | R_ShutdownPrograms (void) |
static size_t | R_PreprocessShaderAddToShaderBuf (const char *name, const char *in, char **out, size_t *len) |
static size_t | R_InitializeShader (const char *name, char *out, size_t len) |
static size_t | R_PreprocessShader (const char *name, const char *in, char *out, int len) |
static r_shader_t * | R_LoadShader (GLenum type, const char *name) |
r_program_t * | R_LoadProgram (const char *name, void *init, void *use) |
static void | R_InitWorldProgram (r_program_t *prog) |
static void | R_UseWorldProgram (r_program_t *prog) |
static void | R_InitWarpProgram (r_program_t *prog) |
static void | R_UseWarpProgram (r_program_t *prog) |
static void | R_InitGeoscapeProgram (r_program_t *prog) |
static int | R_PascalTriangle (int row, int col) |
static void | R_InitConvolveProgram (r_program_t *prog) |
static void | R_UseConvolveProgram (r_program_t *prog) |
Use the filter convolution glsl program. | |
static void | R_InitCombine2Program (r_program_t *prog) |
static void | R_InitAtmosphereProgram (r_program_t *prog) |
static void | R_InitSimpleGlowProgram (r_program_t *prog) |
void | R_InitParticleProgram (r_program_t *prog) |
void | R_UseParticleProgram (r_program_t *prog) |
void | R_InitPrograms (void) |
void | R_RestartPrograms_f (void) |
Reloads the glsl shaders. |
Shader (GLSL) backend functions.
Definition in file r_program.c.
#define FILTER_SIZE 3 |
width of convolution filter (for blur/bloom effects)
Definition at line 722 of file r_program.c.
Referenced by R_InitConvolveProgram(), R_InitPrograms(), and R_UseConvolveProgram().
#define SHADER_BUF_SIZE 16384 |
Definition at line 33 of file r_program.c.
Referenced by R_LoadShader(), and R_PreprocessShader().
void R_AttributePointer | ( | const char * | name, | |
GLuint | size, | |||
const GLvoid * | array | |||
) |
pass file-line numbers for debugging
Definition at line 211 of file r_program.c.
References GL_ATTRIBUTE, r_progvar_s::location, and R_ProgramVariable().
Referenced by R_BindArray().
void R_DisableAttribute | ( | const char * | name | ) |
Definition at line 239 of file r_program.c.
References GL_ATTRIBUTE, r_progvar_s::location, and R_ProgramVariable().
Referenced by R_EnableAnimation(), R_EnableBumpmap(), and R_EnableDynamicLights().
void R_EnableAttribute | ( | const char * | name | ) |
Definition at line 225 of file r_program.c.
References GL_ATTRIBUTE, r_progvar_s::location, and R_ProgramVariable().
Referenced by R_EnableAnimation(), R_EnableBumpmap(), and R_EnableDynamicLights().
static void R_InitAtmosphereProgram | ( | r_program_t * | prog | ) | [static] |
Definition at line 775 of file r_program.c.
References R_ProgramParameter1i(), R_ProgramParameter2fv(), and R_ProgramParameter4fv().
Referenced by R_InitPrograms().
static void R_InitCombine2Program | ( | r_program_t * | prog | ) | [static] |
Definition at line 765 of file r_program.c.
References R_ProgramParameter1i(), and R_ProgramParameter4fv().
Referenced by R_InitPrograms().
static void R_InitConvolveProgram | ( | r_program_t * | prog | ) | [static] |
Definition at line 724 of file r_program.c.
References FILTER_SIZE, i, lengthof, R_PascalTriangle(), R_ProgramParameter1fvs(), and R_ProgramParameter1i().
Referenced by R_InitPrograms().
static void R_InitGeoscapeProgram | ( | r_program_t * | prog | ) | [static] |
Definition at line 695 of file r_program.c.
References R_ProgramParameter1i(), R_ProgramParameter2fv(), and R_ProgramParameter4fv().
Referenced by R_InitPrograms().
static size_t R_InitializeShader | ( | const char * | name, | |
char * | out, | |||
size_t | len | |||
) | [static] |
Definition at line 301 of file r_program.c.
References Com_Error(), ERR_FATAL, GLHW_ATI, GLHW_GENERIC, GLHW_INTEL, GLHW_MESA, GLHW_NVIDIA, rconfig_t::hardwareType, viddef_t::height, i, r_config, R_PreprocessShaderAddToShaderBuf(), va(), viddef, and viddef_t::width.
Referenced by R_LoadShader().
void R_InitParticleProgram | ( | r_program_t * | prog | ) |
Definition at line 794 of file r_program.c.
References R_ProgramParameter1i().
Referenced by CL_ParseMapParticle(), and CL_ParticleFunction().
void R_InitPrograms | ( | void | ) |
Definition at line 804 of file r_program.c.
References rstate_t::atmosphere_program, Com_Printf(), rstate_t::combine2_program, rstate_t::convolve_program, Cvar_Set(), DOUBLEQUOTE, FILTER_SIZE, rstate_t::geoscape_program, cvar_s::integer, cvar_s::modified, rstate_t::programs, qfalse, R_InitAtmosphereProgram(), R_InitCombine2Program(), R_InitConvolveProgram(), R_InitGeoscapeProgram(), R_InitSimpleGlowProgram(), R_InitWarpProgram(), R_InitWorldProgram(), R_LoadProgram(), r_programs, r_state, R_UseConvolveProgram(), R_UseWarpProgram(), R_UseWorldProgram(), rstate_t::shaders, rstate_t::simple_glow_program, rstate_t::warp_program, and rstate_t::world_program.
Referenced by R_Init(), and R_RestartPrograms_f().
static void R_InitSimpleGlowProgram | ( | r_program_t * | prog | ) | [static] |
Definition at line 787 of file r_program.c.
References R_ProgramParameter1f(), and R_ProgramParameter1i().
Referenced by R_InitPrograms().
static void R_InitWarpProgram | ( | r_program_t * | prog | ) | [static] |
Definition at line 674 of file r_program.c.
References cvar_s::integer, r_postprocess, R_ProgramParameter1f(), R_ProgramParameter1i(), and R_ProgramParameter4fv().
Referenced by R_InitPrograms().
static void R_InitWorldProgram | ( | r_program_t * | prog | ) | [static] |
Definition at line 647 of file r_program.c.
References cvar_s::integer, r_postprocess, R_ProgramParameter1f(), and R_ProgramParameter1i().
Referenced by R_InitPrograms().
r_program_t* R_LoadProgram | ( | const char * | name, | |
void * | init, | |||
void * | use | |||
) |
Definition at line 579 of file r_program.c.
References Com_Printf(), r_program_s::f, i, r_shader_s::id, r_program_s::id, r_program_s::init, MAX_PROGRAMS, MAX_STRING_CHARS, r_program_s::name, rstate_t::programs, Q_strncpyz(), R_LoadShader(), R_ShutdownProgram(), r_state, R_UseProgram(), r_program_s::use, r_program_s::v, and va().
Referenced by CL_ParseMapParticle(), CL_ParticleFunction(), and R_InitPrograms().
static r_shader_t* R_LoadShader | ( | GLenum | type, | |
const char * | name | |||
) | [static] |
Definition at line 505 of file r_program.c.
References byte, Com_DPrintf(), Com_Printf(), DEBUG_RENDERER, FS_FreeFile(), FS_LoadFile(), i, r_shader_s::id, len, MAX_QPATH, MAX_SHADERS, MAX_STRING_CHARS, Mem_Free, Mem_PoolAlloc, r_shader_s::name, Q_strncpyz(), R_InitializeShader(), R_PreprocessShader(), r_state, SHADER_BUF_SIZE, rstate_t::shaders, r_shader_s::type, and vid_imagePool.
Referenced by R_LoadProgram().
static int R_PascalTriangle | ( | int | row, | |
int | col | |||
) | [static] |
Definition at line 714 of file r_program.c.
Referenced by R_InitConvolveProgram().
static size_t R_PreprocessShader | ( | const char * | name, | |
const char * | in, | |||
char * | out, | |||
int | len | |||
) | [static] |
Definition at line 339 of file r_program.c.
References byte, Com_Error(), Com_Parse(), Com_Printf(), Com_sprintf(), Cvar_GetValue(), ERR_DROP, ERR_FATAL, f, FS_FreeFile(), FS_LoadFile(), i, MAX_QPATH, Mem_Free, Mem_PoolAlloc, qfalse, qtrue, SHADER_BUF_SIZE, and vid_imagePool.
Referenced by R_LoadShader().
static size_t R_PreprocessShaderAddToShaderBuf | ( | const char * | name, | |
const char * | in, | |||
char ** | out, | |||
size_t * | len | |||
) | [static] |
Definition at line 292 of file r_program.c.
Referenced by R_InitializeShader().
void R_ProgramParameter1f | ( | const char * | name, | |
GLfloat | value | |||
) |
Definition at line 127 of file r_program.c.
References GL_UNIFORM, r_progvar_s::location, and R_ProgramVariable().
Referenced by R_EnableAnimation(), R_EnableBumpmap(), R_EnableDynamicLights(), R_EnableGlowMap(), R_EnableShell(), R_InitSimpleGlowProgram(), R_InitWarpProgram(), R_InitWorldProgram(), R_SphereShadeGLSL(), R_StageGlow(), and R_UseMaterial().
void R_ProgramParameter1fvs | ( | const char * | name, | |
GLint | size, | |||
GLfloat * | value | |||
) |
Definition at line 141 of file r_program.c.
References GL_UNIFORM, r_progvar_s::location, and R_ProgramVariable().
Referenced by R_InitConvolveProgram().
void R_ProgramParameter1i | ( | const char * | name, | |
GLint | value | |||
) |
Definition at line 113 of file r_program.c.
References GL_UNIFORM, r_progvar_s::location, and R_ProgramVariable().
Referenced by R_EnableAnimation(), R_EnableBumpmap(), R_EnableDynamicLights(), R_EnableRoughnessMap(), R_EnableSpecularMap(), R_InitAtmosphereProgram(), R_InitCombine2Program(), R_InitConvolveProgram(), R_InitGeoscapeProgram(), R_InitParticleProgram(), R_InitSimpleGlowProgram(), R_InitWarpProgram(), and R_InitWorldProgram().
void R_ProgramParameter2fv | ( | const char * | name, | |
GLfloat * | value | |||
) |
Definition at line 155 of file r_program.c.
References GL_UNIFORM, r_progvar_s::location, and R_ProgramVariable().
Referenced by R_InitAtmosphereProgram(), and R_InitGeoscapeProgram().
void R_ProgramParameter2fvs | ( | const char * | name, | |
GLint | size, | |||
GLfloat * | value | |||
) |
Definition at line 169 of file r_program.c.
References GL_UNIFORM, r_progvar_s::location, and R_ProgramVariable().
Referenced by R_UseConvolveProgram().
void R_ProgramParameter3fv | ( | const char * | name, | |
GLfloat * | value | |||
) |
Definition at line 183 of file r_program.c.
References GL_UNIFORM, r_progvar_s::location, and R_ProgramVariable().
void R_ProgramParameter4fv | ( | const char * | name, | |
GLfloat * | value | |||
) |
Definition at line 197 of file r_program.c.
References GL_UNIFORM, r_progvar_s::location, and R_ProgramVariable().
Referenced by R_InitAtmosphereProgram(), R_InitCombine2Program(), R_InitGeoscapeProgram(), R_InitWarpProgram(), and R_UseWarpProgram().
static r_progvar_t* R_ProgramVariable | ( | int | type, | |
const char * | name | |||
) | [static] |
Definition at line 56 of file r_program.c.
References rstate_t::active_program, Com_DPrintf(), Com_Printf(), DEBUG_RENDERER, GL_UNIFORM, i, r_program_s::id, r_progvar_s::location, MAX_PROGRAM_VARS, r_program_s::name, r_progvar_s::name, Q_strncpyz(), r_state, r_progvar_s::type, and r_program_s::vars.
Referenced by R_AttributePointer(), R_DisableAttribute(), R_EnableAttribute(), R_ProgramParameter1f(), R_ProgramParameter1fvs(), R_ProgramParameter1i(), R_ProgramParameter2fv(), R_ProgramParameter2fvs(), R_ProgramParameter3fv(), and R_ProgramParameter4fv().
void R_RestartPrograms_f | ( | void | ) |
Reloads the glsl shaders.
Definition at line 833 of file r_program.c.
References Com_Printf(), R_InitPrograms(), and R_ShutdownPrograms().
Referenced by R_BeginFrame().
static void R_ShutdownProgram | ( | r_program_t * | prog | ) | [static] |
Definition at line 256 of file r_program.c.
References r_program_s::f, r_shader_s::id, r_program_s::id, R_CheckError, R_ShutdownShader(), and r_program_s::v.
Referenced by R_LoadProgram(), and R_ShutdownPrograms().
void R_ShutdownPrograms | ( | void | ) |
Definition at line 274 of file r_program.c.
References i, r_program_s::id, cvar_s::integer, MAX_PROGRAMS, rstate_t::programs, r_programs, R_ShutdownProgram(), and r_state.
Referenced by R_RestartPrograms_f(), and R_Shutdown().
static void R_ShutdownShader | ( | r_shader_t * | sh | ) | [static] |
Definition at line 250 of file r_program.c.
References r_shader_s::id.
Referenced by R_ShutdownProgram().
static void R_UseConvolveProgram | ( | r_program_t * | prog | ) | [static] |
Use the filter convolution glsl program.
Definition at line 747 of file r_program.c.
References FILTER_SIZE, i, R_ProgramParameter2fvs(), and r_program_s::userdata.
Referenced by R_InitPrograms().
void R_UseParticleProgram | ( | r_program_t * | prog | ) |
Definition at line 799 of file r_program.c.
Referenced by CL_ParseMapParticle(), and CL_ParticleFunction().
void R_UseProgram | ( | r_program_t * | prog | ) |
Definition at line 35 of file r_program.c.
References rstate_t::active_program, r_program_s::id, r_state, and r_program_s::use.
Referenced by R_BlurStack(), R_DrawBloom(), R_DrawParticles(), R_EnableBlur(), R_EnableGlowMap(), R_EnableLighting(), R_EnableWarp(), and R_LoadProgram().
static void R_UseWarpProgram | ( | r_program_t * | prog | ) | [static] |
Definition at line 687 of file r_program.c.
References R_ProgramParameter4fv(), refdef, and rendererData_t::time.
Referenced by R_InitPrograms().
static void R_UseWorldProgram | ( | r_program_t * | prog | ) | [static] |
Definition at line 669 of file r_program.c.
Referenced by R_InitPrograms().