UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
r_state.cpp File Reference
#include "r_local.h"
#include "r_program.h"
#include "r_error.h"

Go to the source code of this file.

Macros

#define FOG_START   300.0
 
#define FOG_END   2500.0
 

Functions

bool R_SelectTexture (gltexunit_t *texunit)
 Returns false if the texunit is not supported. More...
 
static void R_BindTexture_ (int texnum)
 
void R_BindTextureDebug (int texnum, const char *file, int line, const char *function)
 
void R_BindTextureForTexUnit (GLuint texnum, gltexunit_t *texunit)
 
void R_BindLightmapTexture (GLuint texnum)
 
void R_BindDeluxemapTexture (GLuint texnum)
 
void R_BindNormalmapTexture (GLuint texnum)
 
void R_UseMaterial (const material_t *material)
 
void R_BindArray (GLenum target, GLenum type, const void *array)
 
void R_BindDefaultArray (GLenum target)
 Binds the appropriate shared vertex array to the specified target. More...
 
void R_BindBuffer (GLenum target, GLenum type, GLuint id)
 
void R_BlendFunc (GLenum src, GLenum dest)
 
void R_EnableMultisample (bool enable)
 
void R_EnableBlend (bool enable)
 
void R_EnableAlphaTest (bool enable)
 
void R_EnableStencilTest (bool enable)
 
void R_EnableTexture (gltexunit_t *texunit, bool enable)
 
void R_EnableColorArray (bool enable)
 
bool R_EnableLighting (r_program_t *program, bool enable)
 Enables hardware-accelerated lighting with the specified program. This should be called after any texture units which will be active for lighting have been enabled. More...
 
void R_SetupSpotLight (int index, const light_t *light)
 
void R_DisableSpotLight (int index)
 
void R_EnableAnimation (const mAliasMesh_t *mesh, float backlerp, bool enable)
 Enables animation using keyframe interpolation on the GPU. More...
 
void R_EnableBumpmap (const image_t *normalmap)
 Enables bumpmapping and binds the given normalmap. More...
 
void R_EnableWarp (r_program_t *program, bool enable)
 
void R_EnableBlur (r_program_t *program, bool enable, r_framebuffer_t *source, r_framebuffer_t *dest, int dir)
 
void R_EnableShell (bool enable)
 
void R_EnableFog (bool enable)
 
static void R_UpdateGlowBufferBinding (void)
 
void R_EnableGlowMap (const image_t *image)
 
void R_EnableDrawAsGlow (bool enable)
 
void R_EnableSpecularMap (const image_t *image, bool enable)
 
void R_EnableRoughnessMap (const image_t *image, bool enable)
 
static void MYgluPerspective (GLfloat zNear, GLfloat zFar)
 
void R_Setup3D (void)
 
void R_Setup2D (void)
 
void R_SetDefaultState (void)
 
void R_TexEnv (GLenum mode)
 
void R_TexOverride (vec4_t rgba)
 Sets special texture environment mode to override texture color; don't forget to call R_TexOverride(nullptr) to reset after drawing; intended for UI only, will conflict with lightmaps. More...
 
void R_Color (const vec4_t rgba)
 Change the color to given value. More...
 
void R_ReallocateStateArrays (int size)
 Reallocate arrays of GL primitives if needed. More...
 
void R_ReallocateTexunitArray (gltexunit_t *texunit, int size)
 Reallocate texcoord array of the specified texunit, if needed. More...
 

Variables

const vec2_t default_texcoords [4]
 
static r_program_tlastProgram = nullptr
 
vec2_t fogRange = {FOG_START, FOG_END}
 
const vec4_t color_white = {1, 1, 1, 1}
 

Macro Definition Documentation

#define FOG_END   2500.0

Definition at line 582 of file r_state.cpp.

Referenced by R_SetDefaultState().

#define FOG_START   300.0

Definition at line 581 of file r_state.cpp.

Referenced by R_SetDefaultState().

Function Documentation

static void MYgluPerspective ( GLfloat  zNear,
GLfloat  zFar 
)
static
void R_BindBuffer ( GLenum  target,
GLenum  type,
GLuint  id 
)

Definition at line 213 of file r_state.cpp.

References cvar_s::integer, R_BindArray(), and r_vertexbuffers.

Referenced by R_ResetArrayState(), and R_SetVertexBufferState().

void R_BindDeluxemapTexture ( GLuint  texnum)

Definition at line 95 of file r_state.cpp.

References R_BindTextureForTexUnit(), and texunit_deluxemap.

Referenced by R_SetSurfaceBumpMappingParameters().

void R_BindLightmapTexture ( GLuint  texnum)
void R_BindNormalmapTexture ( GLuint  texnum)

Definition at line 100 of file r_state.cpp.

References R_BindTextureForTexUnit(), and texunit_normalmap.

Referenced by R_EnableBumpmap().

static void R_BindTexture_ ( int  texnum)
static
void R_BindTextureDebug ( int  texnum,
const char *  file,
int  line,
const char *  function 
)

Definition at line 69 of file r_state.cpp.

References Com_Printf(), and R_BindTexture_().

void R_DisableSpotLight ( int  index)
void R_EnableAlphaTest ( bool  enable)

Definition at line 277 of file r_state.cpp.

References rstate_s::alpha_test_enabled, and r_state.

Referenced by R_DrawGrass(), R_RenderAlphaTestBspRRefs(), and R_SetDefaultState().

void R_EnableAnimation ( const mAliasMesh_t mesh,
float  backlerp,
bool  enable 
)

Enables animation using keyframe interpolation on the GPU.

Parameters
meshThe mesh to animate
backlerpThe temporal proximity to the previous keyframe (in the range 0.0 to 1.0)
enableWhether to turn animation on or off

Definition at line 430 of file r_state.cpp.

References rstate_s::animation_enabled, GL_NEXT_NORMAL_ARRAY, GL_NEXT_TANGENT_ARRAY, GL_NEXT_VERTEX_ARRAY, GL_TANGENT_ARRAY, cvar_s::integer, rstate_s::lighting_enabled, mAliasMesh_s::next_normals, mAliasMesh_s::next_tangents, mAliasMesh_s::next_verts, mAliasMesh_s::normals, R_BindArray(), R_DisableAttribute(), R_EnableAttribute(), R_ProgramParameter1f(), R_ProgramParameter1i(), r_programs, r_state, mAliasMesh_s::tangents, mAliasMesh_s::texcoords, and mAliasMesh_s::verts.

Referenced by R_DrawAliasFrameLerp().

void R_EnableBumpmap ( const image_t normalmap)
bool R_EnableLighting ( r_program_t program,
bool  enable 
)

Enables hardware-accelerated lighting with the specified program. This should be called after any texture units which will be active for lighting have been enabled.

Definition at line 350 of file r_state.cpp.

References rstate_s::active_program, r_program_s::id, cvar_s::integer, rstate_s::lighting_enabled, r_programs, r_state, and R_UseProgram().

Referenced by R_DrawBlendMeshEntities(), R_DrawMaterialSurfaces(), R_DrawMeshShadow(), R_DrawOpaqueMeshEntities(), R_RenderAlphaTestBspRRefs(), R_RenderOpaqueBspRRefs(), R_SphereShadeGLSL(), and R_StageLighting().

void R_EnableMultisample ( bool  enable)

Definition at line 243 of file r_state.cpp.

References cvar_s::integer, rstate_s::multisample_enabled, R_CheckError, r_multisample, and r_state.

Referenced by R_BeginFrame(), and R_EndFrame().

void R_EnableRoughnessMap ( const image_t image,
bool  enable 
)
void R_EnableStencilTest ( bool  enable)

Definition at line 290 of file r_state.cpp.

References r_state, and rstate_s::stencil_test_enabled.

Referenced by R_DrawMeshShadow().

void R_ReallocateStateArrays ( int  size)

Reallocate arrays of GL primitives if needed.

Parameters
sizeThe new array size
Note
Also resets all non-default GL array bindings
See also
R_ReallocateTexunitArray

Definition at line 1029 of file r_state.cpp.

Referenced by R_DrawBspNormals(), R_DrawSurfaceStage(), R_FillArrayData(), R_LoadBspVertexArrays(), and R_SetDefaultState().

void R_ReallocateTexunitArray ( gltexunit_t texunit,
int  size 
)

Reallocate texcoord array of the specified texunit, if needed.

Parameters
texunitPointer to texunit (TODO: remove this comment as obvious and redundant)
sizeThe new array size
Note
Also resets active texunit
See also
R_ReallocateStateArrays

Definition at line 1059 of file r_state.cpp.

Referenced by R_DrawSurfaceStage(), R_FillArrayData(), and R_SetDefaultState().

void R_SetupSpotLight ( int  index,
const light_t light 
)
void R_TexOverride ( vec4_t  rgba)

Sets special texture environment mode to override texture color; don't forget to call R_TexOverride(nullptr) to reset after drawing; intended for UI only, will conflict with lightmaps.

Definition at line 968 of file r_state.cpp.

References GL_SOURCE0_ALPHA, GL_SOURCE0_RGB, GL_SOURCE1_RGB, GL_SOURCE2_RGB, R_BindTexture, r_dummyTexture, R_SelectTexture(), R_TexEnv(), image_s::texnum, texunit_diffuse, and texunit_lightmap.

Referenced by UI_DisableFlashing(), and UI_EnableFlashing().

Variable Documentation

const vec4_t color_white = {1, 1, 1, 1}

Definition at line 1004 of file r_state.cpp.

Referenced by R_Color().

const vec2_t default_texcoords[4]
Initial value:
= {
{0.0, 0.0}, {1.0, 0.0}, {1.0, 1.0}, {0.0, 1.0}
}

Definition at line 30 of file r_state.cpp.

Referenced by R_DrawFlareSurfaces(), and R_DrawTexture().

r_program_t* lastProgram = nullptr
static

Definition at line 35 of file r_state.cpp.