UFO: Alien Invasion
Loading...
Searching...
No Matches
r_state.cpp File Reference
#include "r_local.h"
#include "r_program.h"
#include "r_error.h"
Include dependency graph for r_state.cpp:

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.
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.
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.
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.
void R_EnableBumpmap (const image_t *normalmap)
 Enables bumpmapping and binds the given normalmap.
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.
void R_Color (const vec4_t rgba)
 Change the color to given value.
void R_ReallocateStateArrays (int size)
 Reallocate arrays of GL primitives if needed.
void R_ReallocateTexunitArray (gltexunit_t *texunit, int size)
 Reallocate texcoord array of the specified texunit, if needed.

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

◆ FOG_END

#define FOG_END   2500.0

Definition at line 582 of file r_state.cpp.

Referenced by R_SetDefaultState().

◆ FOG_START

#define FOG_START   300.0

Definition at line 581 of file r_state.cpp.

Referenced by R_SetDefaultState().

Function Documentation

◆ MYgluPerspective()

void MYgluPerspective ( GLfloat zNear,
GLfloat zFar )
static
See also
R_Setup3D

Definition at line 743 of file r_state.cpp.

References M_PI, r_isometric, refdef, and viddef.

Referenced by R_Setup3D().

◆ R_BindArray()

◆ R_BindBuffer()

void R_BindBuffer ( GLenum target,
GLenum type,
GLuint id )

Definition at line 213 of file r_state.cpp.

References GLenum, GLuint, R_BindArray(), r_vertexbuffers, and type.

Referenced by R_ResetArrayState(), and R_SetVertexBufferState().

◆ R_BindDefaultArray()

◆ R_BindDeluxemapTexture()

void R_BindDeluxemapTexture ( GLuint texnum)

Definition at line 95 of file r_state.cpp.

References GLuint, R_BindTextureForTexUnit(), and texunit_deluxemap.

Referenced by R_SetSurfaceBumpMappingParameters().

◆ R_BindLightmapTexture()

void R_BindLightmapTexture ( GLuint texnum)

◆ R_BindNormalmapTexture()

void R_BindNormalmapTexture ( GLuint texnum)

Definition at line 100 of file r_state.cpp.

References GLuint, R_BindTextureForTexUnit(), and texunit_normalmap.

Referenced by R_EnableBumpmap().

◆ R_BindTexture_()

void R_BindTexture_ ( int texnum)
static

Definition at line 56 of file r_state.cpp.

References glBindTexture(), R_CheckError, and r_state.

Referenced by R_BindTextureDebug().

◆ R_BindTextureDebug()

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_().

◆ R_BindTextureForTexUnit()

◆ R_BlendFunc()

◆ R_Color()

◆ R_DisableSpotLight()

void R_DisableSpotLight ( int index)

◆ R_EnableAlphaTest()

void R_EnableAlphaTest ( bool enable)

Definition at line 277 of file r_state.cpp.

References r_state.

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

◆ R_EnableAnimation()

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 GL_NEXT_NORMAL_ARRAY, GL_NEXT_TANGENT_ARRAY, GL_NEXT_VERTEX_ARRAY, GL_TANGENT_ARRAY, mAliasMesh_t::next_normals, mAliasMesh_t::next_tangents, mAliasMesh_t::next_verts, mAliasMesh_t::normals, R_BindArray(), R_DisableAttribute(), R_EnableAttribute(), R_ProgramParameter1f(), R_ProgramParameter1i(), r_programs, r_state, mAliasMesh_t::tangents, mAliasMesh_t::texcoords, and mAliasMesh_t::verts.

Referenced by R_DrawAliasFrameLerp().

◆ R_EnableBlend()

◆ R_EnableBlur()

◆ R_EnableBumpmap()

void R_EnableBumpmap ( const image_t * normalmap)

Enables bumpmapping and binds the given normalmap.

Note
Don't forget to bind the deluxe map, too.
See also
R_BindDeluxemapTexture

Definition at line 465 of file r_state.cpp.

References defaultMaterial, R_BindNormalmapTexture(), r_bumpmap, R_ProgramParameter1i(), r_state, R_UseMaterial(), and image_t::texnum.

Referenced by R_DrawAliasModel(), R_DrawMaterialSurfaces(), R_DrawSurfaces(), and R_SetSurfaceBumpMappingParameters().

◆ R_EnableColorArray()

◆ R_EnableDrawAsGlow()

void R_EnableDrawAsGlow ( bool enable)

◆ R_EnableFog()

◆ R_EnableGlowMap()

◆ R_EnableLighting()

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 r_program_t::id, 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().

◆ R_EnableMultisample()

void R_EnableMultisample ( bool enable)

Definition at line 243 of file r_state.cpp.

References R_CheckError, r_multisample, and r_state.

Referenced by R_BeginFrame(), and R_EndFrame().

◆ R_EnableRoughnessMap()

void R_EnableRoughnessMap ( const image_t * image,
bool enable )

◆ R_EnableShell()

void R_EnableShell ( bool enable)

◆ R_EnableSpecularMap()

void R_EnableSpecularMap ( const image_t * image,
bool enable )

◆ R_EnableStencilTest()

void R_EnableStencilTest ( bool enable)

Definition at line 290 of file r_state.cpp.

References r_state.

Referenced by R_DrawMeshShadow().

◆ R_EnableTexture()

◆ R_EnableWarp()

◆ R_ReallocateStateArrays()

◆ R_ReallocateTexunitArray()

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.

References gltexunit_t::array_size, COMPONENTS_TEXCOORD_ARRAY, Mem_SafeReAlloc, R_BindDefaultArray(), r_state, and gltexunit_t::texcoord_array.

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

◆ R_SelectTexture()

◆ R_SetDefaultState()

◆ R_Setup2D()

void R_Setup2D ( void )

◆ R_Setup3D()

◆ R_SetupSpotLight()

void R_SetupSpotLight ( int index,
const light_t * light )

◆ R_TexEnv()

void R_TexEnv ( GLenum mode)

Definition at line 956 of file r_state.cpp.

References GLenum, and r_state.

Referenced by R_DrawParticles(), R_EnableTexture(), R_SetBlendMode(), R_SetDefaultState(), and R_TexOverride().

◆ R_TexOverride()

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(), texunit_diffuse, and texunit_lightmap.

Referenced by UI_DisableFlashing(), and UI_EnableFlashing().

◆ R_UpdateGlowBufferBinding()

void R_UpdateGlowBufferBinding ( void )
static

◆ R_UseMaterial()

Variable Documentation

◆ color_white

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

Definition at line 1004 of file r_state.cpp.

Referenced by R_Color().

◆ default_texcoords

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().

◆ fogRange

◆ lastProgram

r_program_t* lastProgram = nullptr
static

Definition at line 35 of file r_state.cpp.

Referenced by R_EnableDrawAsGlow(), and R_EnableGlowMap().