UFO: Alien Invasion
Loading...
Searching...
No Matches
r_state.h File Reference
#include "../../shared/cxx.h"
#include "r_program.h"
#include "r_material.h"
#include "r_framebuffer.h"
#include "r_light.h"
#include "r_image.h"
Include dependency graph for r_state.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  gltexunit_t
 texunits maintain multitexture state More...
struct  rstate_t

Macros

#define SKYBOX_DEPTH   -9999.0f
 Center position of skybox along z-axis. This is used to make sure we see only the inside of Skybox.
#define GL_ARRAY_LENGTH_CHUNK   4096
#define MAX_GL_TEXUNITS   6
#define texunit_0   r_state.texunits[0]
#define texunit_1   r_state.texunits[1]
#define texunit_2   r_state.texunits[2]
#define texunit_3   r_state.texunits[3]
#define texunit_4   r_state.texunits[4]
#define texunit_5   r_state.texunits[5]
#define texunit_diffuse   texunit_0
#define texunit_lightmap   texunit_1
#define texunit_deluxemap   texunit_2
#define texunit_normalmap   texunit_3
#define texunit_glowmap   texunit_4
#define texunit_specularmap   texunit_5
#define texunit_roughnessmap   texunit_2
#define COMPONENTS_VERTEX_ARRAY3D   3
#define COMPONENTS_VERTEX_ARRAY2D   2
#define COMPONENTS_COLOR_ARRAY   4
#define COMPONENTS_INDEX_ARRAY   1
#define COMPONENTS_NORMAL_ARRAY   3
#define COMPONENTS_TANGENT_ARRAY   4
#define COMPONENTS_TEXCOORD_ARRAY   2
#define DOWNSAMPLE_PASSES   5
#define DOWNSAMPLE_SCALE   2
#define fbo_screen   nullptr
#define fbo_render   r_state.renderBuffer
#define fbo_bloom0   r_state.bloomBuffer0
#define fbo_bloom1   r_state.bloomBuffer1
#define default_program   nullptr
#define R_BindTexture(tn)

Functions

void R_SetDefaultState (void)
void R_Setup2D (void)
void R_Setup3D (void)
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.
void R_TexEnv (GLenum value)
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_BlendFunc (GLenum src, GLenum dest)
bool R_SelectTexture (gltexunit_t *texunit)
 Returns false if the texunit is not supported.
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_BindBuffer (GLenum target, GLenum type, GLuint id)
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_EnableStencilTest (bool enable)
void R_EnableTexture (gltexunit_t *texunit, bool enable)
void R_EnableMultisample (bool enable)
void R_EnableBlend (bool enable)
void R_EnableAlphaTest (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_EnableBumpmap (const struct image_s *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)
void R_EnableDrawAsGlow (bool enable)
void R_EnableGlowMap (const struct image_s *image)
void R_EnableSpecularMap (const struct image_s *image, bool enable)
void R_EnableRoughnessMap (const struct image_s *image, bool enable)
void R_SetupSpotLight (int index, const light_t *light)
void R_DisableSpotLight (int index)
void R_EnableAnimation (const struct mAliasMesh_s *mesh, float backlerp, bool enable)
void R_UseMaterial (const material_t *material)

Variables

const vec2_t default_texcoords [4]
rstate_t r_state

Macro Definition Documentation

◆ COMPONENTS_COLOR_ARRAY

#define COMPONENTS_COLOR_ARRAY   4

Definition at line 78 of file r_state.h.

Referenced by R_BindArray(), and R_ReallocateStateArrays().

◆ COMPONENTS_INDEX_ARRAY

#define COMPONENTS_INDEX_ARRAY   1

Definition at line 79 of file r_state.h.

Referenced by R_ReallocateStateArrays().

◆ COMPONENTS_NORMAL_ARRAY

#define COMPONENTS_NORMAL_ARRAY   3

Definition at line 80 of file r_state.h.

Referenced by R_BindArray(), and R_ReallocateStateArrays().

◆ COMPONENTS_TANGENT_ARRAY

#define COMPONENTS_TANGENT_ARRAY   4

Definition at line 81 of file r_state.h.

Referenced by R_BindArray(), and R_ReallocateStateArrays().

◆ COMPONENTS_TEXCOORD_ARRAY

#define COMPONENTS_TEXCOORD_ARRAY   2

Definition at line 82 of file r_state.h.

Referenced by R_BindArray(), and R_ReallocateTexunitArray().

◆ COMPONENTS_VERTEX_ARRAY2D

#define COMPONENTS_VERTEX_ARRAY2D   2

Definition at line 77 of file r_state.h.

Referenced by R_ReallocateStateArrays().

◆ COMPONENTS_VERTEX_ARRAY3D

#define COMPONENTS_VERTEX_ARRAY3D   3

Definition at line 76 of file r_state.h.

Referenced by R_BindArray(), and R_ReallocateStateArrays().

◆ default_program

#define default_program   nullptr

Definition at line 92 of file r_state.h.

Referenced by R_BlurStack(), and R_DrawBloom().

◆ DOWNSAMPLE_PASSES

#define DOWNSAMPLE_PASSES   5

Definition at line 84 of file r_state.h.

Referenced by R_DrawBloom(), and R_InitFBObjects().

◆ DOWNSAMPLE_SCALE

#define DOWNSAMPLE_SCALE   2

Definition at line 85 of file r_state.h.

Referenced by R_InitFBObjects().

◆ fbo_bloom0

#define fbo_bloom0   r_state.bloomBuffer0

Definition at line 89 of file r_state.h.

Referenced by R_DrawBloom(), and R_InitFBObjects().

◆ fbo_bloom1

#define fbo_bloom1   r_state.bloomBuffer1

Definition at line 90 of file r_state.h.

Referenced by R_DrawBloom(), and R_InitFBObjects().

◆ fbo_render

#define fbo_render   r_state.renderBuffer

Definition at line 88 of file r_state.h.

Referenced by R_DrawBloom(), R_DrawQuad(), and R_EnableRenderbuffer().

◆ fbo_screen

#define fbo_screen   nullptr

Definition at line 87 of file r_state.h.

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

◆ GL_ARRAY_LENGTH_CHUNK

#define GL_ARRAY_LENGTH_CHUNK   4096

Definition at line 44 of file r_state.h.

Referenced by R_SetDefaultState().

◆ MAX_GL_TEXUNITS

#define MAX_GL_TEXUNITS   6

Definition at line 58 of file r_state.h.

Referenced by R_SetDefaultState().

◆ R_BindTexture

◆ SKYBOX_DEPTH

#define SKYBOX_DEPTH   -9999.0f

Center position of skybox along z-axis. This is used to make sure we see only the inside of Skybox.

See also
R_DrawStarfield
R_Setup2D

Definition at line 41 of file r_state.h.

Referenced by R_DrawBloom(), R_DrawStarfield(), and R_Setup2D().

◆ texunit_0

#define texunit_0   r_state.texunits[0]

Definition at line 61 of file r_state.h.

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

◆ texunit_1

#define texunit_1   r_state.texunits[1]

Definition at line 62 of file r_state.h.

Referenced by R_BlurStack(), R_DrawBloom(), R_SetDefaultState(), and R_SphereShadeGLSL().

◆ texunit_2

#define texunit_2   r_state.texunits[2]

Definition at line 63 of file r_state.h.

Referenced by R_SetDefaultState(), and R_SphereShadeGLSL().

◆ texunit_3

#define texunit_3   r_state.texunits[3]

Definition at line 64 of file r_state.h.

Referenced by R_SetDefaultState().

◆ texunit_4

#define texunit_4   r_state.texunits[4]

Definition at line 65 of file r_state.h.

Referenced by R_SetDefaultState().

◆ texunit_5

#define texunit_5   r_state.texunits[5]

Definition at line 66 of file r_state.h.

◆ texunit_deluxemap

#define texunit_deluxemap   texunit_2

Definition at line 70 of file r_state.h.

Referenced by R_BindDeluxemapTexture().

◆ texunit_diffuse

◆ texunit_glowmap

#define texunit_glowmap   texunit_4

Definition at line 72 of file r_state.h.

Referenced by R_EnableGlowMap().

◆ texunit_lightmap

◆ texunit_normalmap

#define texunit_normalmap   texunit_3

Definition at line 71 of file r_state.h.

Referenced by R_BindNormalmapTexture().

◆ texunit_roughnessmap

#define texunit_roughnessmap   texunit_2

Definition at line 74 of file r_state.h.

Referenced by R_EnableRoughnessMap().

◆ texunit_specularmap

#define texunit_specularmap   texunit_5

Definition at line 73 of file r_state.h.

Referenced by R_EnableSpecularMap().

Function Documentation

◆ 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_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_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 struct mAliasMesh_s * mesh,
float backlerp,
bool enable )

◆ R_EnableBlend()

◆ R_EnableBlur()

◆ R_EnableBumpmap()

void R_EnableBumpmap ( const struct image_s * normalmap)

References dest.

◆ R_EnableColorArray()

◆ R_EnableDrawAsGlow()

void R_EnableDrawAsGlow ( bool enable)

◆ R_EnableFog()

◆ R_EnableGlowMap()

void R_EnableGlowMap ( const struct image_s * image)

◆ 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 struct image_s * image,
bool enable )

References index.

◆ R_EnableShell()

void R_EnableShell ( bool enable)

◆ R_EnableSpecularMap()

void R_EnableSpecularMap ( const struct image_s * 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 value)

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

Variable Documentation

◆ default_texcoords

const vec2_t default_texcoords[4]
extern

Definition at line 30 of file r_state.cpp.

Referenced by R_DrawFlareSurfaces(), and R_DrawTexture().

◆ r_state

rstate_t r_state
extern

Definition at line 48 of file r_main.cpp.

Referenced by R_ArraysMask(), R_BindColorAttachments(), R_BindDefaultArray(), R_BindTexture_(), R_BlendFunc(), R_Blur(), R_BlurStack(), R_CreateFramebuffer(), R_Draw2DArray(), R_Draw3DGlobe(), R_DrawAliasModel(), R_DrawAliasStatic(), R_DrawBlendMeshEntities(), R_DrawBloom(), R_DrawBspNormals(), R_DrawCoronas(), R_DrawFlareSurfaces(), R_DrawMaterialSurfaces(), R_DrawMeshShadow(), R_DrawOpaqueMeshEntities(), R_DrawSurfaces(), R_DrawSurfaceStage(), R_EnableAlphaTest(), R_EnableAnimation(), R_EnableBlend(), R_EnableBlur(), R_EnableBumpmap(), R_EnableColorArray(), R_EnableDrawAsGlow(), R_EnableFog(), R_EnableGlowMap(), R_EnableLighting(), R_EnableModelLights(), R_EnableMultisample(), R_EnableRenderbuffer(), R_EnableRoughnessMap(), R_EnableShell(), R_EnableSpecularMap(), R_EnableStencilTest(), R_EnableWarp(), R_FillArrayData(), R_FontDrawTexture(), R_Init(), R_InitFBObjects(), R_InitModelProgram(), R_InitPrograms(), R_InitWarpProgram(), R_InitWorldProgram(), R_LoadProgram(), R_LoadShader(), R_ProgramVariable(), R_ReallocateStateArrays(), R_ReallocateTexunitArray(), R_RenderAlphaTestBspRRefs(), R_RenderBlendBspRRefs(), R_RenderBlendWarpBspRRefs(), R_RenderbufferEnabled(), R_RenderOpaqueBspRRefs(), R_RenderOpaqueWarpBspRRefs(), R_ResetArraysAfterStaticMeshRender(), R_ResetArrayState(), R_SelectTexture(), R_SetDefaultState(), R_SetSurfaceBumpMappingParameters(), R_SetSurfaceStageState(), R_SetSurfaceState(), R_SetVertexArrayState(), R_SetVertexBufferState(), R_ShutdownFBObjects(), R_ShutdownPrograms(), R_StageGlow(), R_StageLighting(), R_TexEnv(), R_UpdateGlowBufferBinding(), R_UseFramebuffer(), R_UseMaterial(), R_UseModelProgram(), R_UseProgram(), R_UseViewport(), R_UseWarpProgram(), R_UseWorldProgram(), CampaignTest::SetUpTestCase(), FootStepTest::SetUpTestCase(), GameTest::SetUpTestCase(), MapDefMassRMATest::SetUpTestCase(), MapDefStatsTest::SetUpTestCase(), MapDefTest::SetUpTestCase(), ParticleTest::SetUpTestCase(), ScriptTest::SetUpTestCase(), and UILevel2Test::SetUpTestCase().