r_material.c File Reference

Material related code. More...

#include "r_local.h"
#include "r_error.h"
#include "r_lightmap.h"
#include "../../shared/parse.h"
Include dependency graph for r_material.c:

Go to the source code of this file.

Defines

#define UPDATE_THRESHOLD   0.02

Functions

static void R_UpdateMaterial (material_t *m)
 Materials "think" every few milliseconds to advance animations.
static void R_StageGlow (const materialStage_t *stage)
static void R_StageLighting (const mBspSurface_t *surf, const materialStage_t *stage)
 Manages state for stages supporting static, dynamic, and per-pixel lighting.
static void R_StageVertex (const mBspSurface_t *surf, const materialStage_t *stage, const vec3_t in, vec3_t out)
 Vertex deformation.
static void R_StageTextureMatrix (const mBspSurface_t *surf, const materialStage_t *stage)
 Manages texture matrix manipulations for stages supporting rotations, scrolls, and stretches (rotate, translate, scale).
static void R_StageTexCoord (const materialStage_t *stage, const vec3_t v, const vec2_t in, vec2_t out)
 Generates a single texture coordinate for the specified stage and vertex.
static void R_StageColor (const materialStage_t *stage, const vec3_t v, vec4_t color)
 Generates a single color for the specified stage and vertex.
static void R_SetSurfaceStageState (const mBspSurface_t *surf, const materialStage_t *stage)
 Manages all state for the specified surface and stage.
static void R_DrawSurfaceStage (mBspSurface_t *surf, materialStage_t *stage)
 Render the specified stage for the surface. Resolve vertex attributes via helper functions, outputting to the default vertex arrays.
void R_DrawMaterialSurfaces (mBspSurfaces_t *surfs)
 Iterates the specified surfaces list, updating materials as they are encountered, and rendering all visible stages. State is lazily managed throughout the iteration, so there is a concerted effort to restore the state after all surface stages have been rendered.
static GLenum R_ConstByName (const char *c)
 Translate string into glmode.
static void R_CreateMaterialData_ (model_t *mod)
static void R_CreateMaterialData (void)
static int R_LoadAnimImages (materialStage_t *s)
static int R_ParseStage (materialStage_t *s, const char **buffer)
 Material stage parser.
void R_LoadMaterials (const char *map)
 Load material definitions for each map that has one.

Variables

mBspSurfaces_t r_material_surfaces
static const float dirtmap []
 Array with 'random' alpha values for the dirtmap.

Detailed Description

Material related code.

Definition in file r_material.c.


Define Documentation

#define UPDATE_THRESHOLD   0.02

Definition at line 33 of file r_material.c.

Referenced by R_UpdateMaterial().


Function Documentation

static GLenum R_ConstByName ( const char *  c  )  [static]

Translate string into glmode.

Definition at line 456 of file r_material.c.

References Com_Printf().

Referenced by R_ParseStage().

static void R_CreateMaterialData ( void   )  [static]

Definition at line 490 of file r_material.c.

References i, R_CreateMaterialData_(), r_mapTiles, r_modelsInline, r_numMapTiles, and r_numModelsInline.

Referenced by R_LoadMaterials().

static void R_CreateMaterialData_ ( model_t mod  )  [static]
void R_DrawMaterialSurfaces ( mBspSurfaces_t surfs  ) 

Iterates the specified surfaces list, updating materials as they are encountered, and rendering all visible stages. State is lazily managed throughout the iteration, so there is a concerted effort to restore the state after all surface stages have been rendered.

Todo:
  • integrate BSP lighting with dynamic lighting

Definition at line 372 of file r_material.c.

References rstate_t::blend_enabled, mBspSurfaces_s::count, f, materialStage_s::flags, rlocals_s::frame, mBspSurface_s::frame, i, mBspTexInfo_s::image, cvar_s::integer, m, image_s::material, materialStage_s::next, qfalse, qtrue, R_BlendFunc(), R_Color(), R_DrawSurfaceStage(), R_EnableBumpmap(), R_EnableColorArray(), R_EnableDynamicLights(), R_EnableFog(), R_EnableGlowMap(), R_EnableLighting(), R_EnableTexture(), r_locals, r_materials, R_ResetArrayState(), R_SetSurfaceStageState(), r_state, R_UpdateMaterial(), r_wire, STAGE_RENDER, material_s::stages, mBspSurfaces_s::surfaces, mBspSurface_s::texinfo, texunit_lightmap, and rstate_t::world_program.

Referenced by R_DrawBspModelSurfaces(), and R_RenderFrame().

static void R_DrawSurfaceStage ( mBspSurface_t surf,
materialStage_t stage 
) [static]
static int R_LoadAnimImages ( materialStage_t s  )  [static]
void R_LoadMaterials ( const char *  map  ) 
static int R_ParseStage ( materialStage_t s,
const char **  buffer 
) [static]
static void R_SetSurfaceStageState ( const mBspSurface_t surf,
const materialStage_t stage 
) [static]
static void R_StageColor ( const materialStage_t stage,
const vec3_t  v,
vec4_t  color 
) [static]
static void R_StageGlow ( const materialStage_t stage  )  [static]
static void R_StageLighting ( const mBspSurface_t surf,
const materialStage_t stage 
) [static]
static void R_StageTexCoord ( const materialStage_t stage,
const vec3_t  v,
const vec2_t  in,
vec2_t  out 
) [static]

Generates a single texture coordinate for the specified stage and vertex.

Definition at line 195 of file r_material.c.

References materialStage_s::flags, refdef, STAGE_ENVMAP, Vector2Copy, VectorNormalize(), VectorSubtract, and rendererData_t::viewOrigin.

Referenced by R_DrawSurfaceStage().

static void R_StageTextureMatrix ( const mBspSurface_t surf,
const materialStage_t stage 
) [inline, static]
static void R_StageVertex ( const mBspSurface_t surf,
const materialStage_t stage,
const vec3_t  in,
vec3_t  out 
) [inline, static]

Vertex deformation.

Todo:
implement this

Definition at line 138 of file r_material.c.

References VectorCopy.

Referenced by R_DrawSurfaceStage().

static void R_UpdateMaterial ( material_t m  )  [static]

Variable Documentation

const float dirtmap[] [static]
Initial value:
 {
        0.6, 0.5, 0.3, 0.4, 0.7, 0.3, 0.0, 0.4,
        0.5, 0.2, 0.8, 0.5, 0.3, 0.2, 0.5, 0.3
}

Array with 'random' alpha values for the dirtmap.

Definition at line 209 of file r_material.c.

Referenced by R_StageColor().

Definition at line 31 of file r_material.c.


Generated by  doxygen 1.6.2