📄 tr_local.h
字号:
// tr_shader.c
//
qhandle_t RE_RegisterShaderLightMap( const char *name, int lightmapIndex );
qhandle_t RE_RegisterShader( const char *name );
qhandle_t RE_RegisterShaderNoMip( const char *name );
qhandle_t RE_RegisterShaderFromImage(const char *name, int lightmapIndex, image_t *image, qboolean mipRawImage);
shader_t *R_FindShader( const char *name, int lightmapIndex, qboolean mipRawImage );
shader_t *R_GetShaderByHandle( qhandle_t hShader );
shader_t *R_GetShaderByState( int index, long *cycleTime );
shader_t *R_FindShaderByName( const char *name );
void R_InitShaders( void );
void R_ShaderList_f( void );
void R_RemapShader(const char *oldShader, const char *newShader, const char *timeOffset);
/*
====================================================================
IMPLEMENTATION SPECIFIC FUNCTIONS
====================================================================
*/
void GLimp_Init( void );
void GLimp_Shutdown( void );
void GLimp_EndFrame( void );
qboolean GLimp_SpawnRenderThread( void (*function)( void ) );
void *GLimp_RendererSleep( void );
void GLimp_FrontEndSleep( void );
void GLimp_WakeRenderer( void *data );
void GLimp_LogComment( char *comment );
// NOTE TTimo linux works with float gamma value, not the gamma table
// the params won't be used, getting the r_gamma cvar directly
void GLimp_SetGamma( unsigned char red[256],
unsigned char green[256],
unsigned char blue[256] );
/*
====================================================================
TESSELATOR/SHADER DECLARATIONS
====================================================================
*/
typedef byte color4ub_t[4];
typedef struct stageVars
{
color4ub_t colors[SHADER_MAX_VERTEXES];
vec2_t texcoords[NUM_TEXTURE_BUNDLES][SHADER_MAX_VERTEXES];
} stageVars_t;
typedef struct shaderCommands_s
{
glIndex_t indexes[SHADER_MAX_INDEXES];
vec4_t xyz[SHADER_MAX_VERTEXES];
vec4_t normal[SHADER_MAX_VERTEXES];
vec2_t texCoords[SHADER_MAX_VERTEXES][2];
color4ub_t vertexColors[SHADER_MAX_VERTEXES];
int vertexDlightBits[SHADER_MAX_VERTEXES];
stageVars_t svars;
color4ub_t constantColor255[SHADER_MAX_VERTEXES];
shader_t *shader;
float shaderTime;
int fogNum;
int dlightBits; // or together of all vertexDlightBits
int numIndexes;
int numVertexes;
// info extracted from current shader
int numPasses;
void (*currentStageIteratorFunc)( void );
shaderStage_t **xstages;
} shaderCommands_t;
extern shaderCommands_t tess;
void RB_BeginSurface(shader_t *shader, int fogNum );
void RB_EndSurface(void);
void RB_CheckOverflow( int verts, int indexes );
#define RB_CHECKOVERFLOW(v,i) if (tess.numVertexes + (v) >= SHADER_MAX_VERTEXES || tess.numIndexes + (i) >= SHADER_MAX_INDEXES ) {RB_CheckOverflow(v,i);}
void RB_StageIteratorGeneric( void );
void RB_StageIteratorSky( void );
void RB_StageIteratorVertexLitTexture( void );
void RB_StageIteratorLightmappedMultitexture( void );
void RB_AddQuadStamp( vec3_t origin, vec3_t left, vec3_t up, byte *color );
void RB_AddQuadStampExt( vec3_t origin, vec3_t left, vec3_t up, byte *color, float s1, float t1, float s2, float t2 );
void RB_ShowImages( void );
/*
============================================================
WORLD MAP
============================================================
*/
void R_AddBrushModelSurfaces( trRefEntity_t *e );
void R_AddWorldSurfaces( void );
qboolean R_inPVS( const vec3_t p1, const vec3_t p2 );
/*
============================================================
FLARES
============================================================
*/
void R_ClearFlares( void );
void RB_AddFlare( void *surface, int fogNum, vec3_t point, vec3_t color, vec3_t normal );
void RB_AddDlightFlares( void );
void RB_RenderFlares (void);
/*
============================================================
LIGHTS
============================================================
*/
void R_DlightBmodel( bmodel_t *bmodel );
void R_SetupEntityLighting( const trRefdef_t *refdef, trRefEntity_t *ent );
void R_TransformDlights( int count, dlight_t *dl, orientationr_t *or );
int R_LightForPoint( vec3_t point, vec3_t ambientLight, vec3_t directedLight, vec3_t lightDir );
/*
============================================================
SHADOWS
============================================================
*/
void RB_ShadowTessEnd( void );
void RB_ShadowFinish( void );
void RB_ProjectionShadowDeform( void );
/*
============================================================
SKIES
============================================================
*/
void R_BuildCloudData( shaderCommands_t *shader );
void R_InitSkyTexCoords( float cloudLayerHeight );
void R_DrawSkyBox( shaderCommands_t *shader );
void RB_DrawSun( void );
void RB_ClipSkyPolygons( shaderCommands_t *shader );
/*
============================================================
CURVE TESSELATION
============================================================
*/
#define PATCH_STITCHING
srfGridMesh_t *R_SubdividePatchToGrid( int width, int height,
drawVert_t points[MAX_PATCH_SIZE*MAX_PATCH_SIZE] );
srfGridMesh_t *R_GridInsertColumn( srfGridMesh_t *grid, int column, int row, vec3_t point, float loderror );
srfGridMesh_t *R_GridInsertRow( srfGridMesh_t *grid, int row, int column, vec3_t point, float loderror );
void R_FreeSurfaceGridMesh( srfGridMesh_t *grid );
/*
============================================================
MARKERS, POLYGON PROJECTION ON WORLD POLYGONS
============================================================
*/
int R_MarkFragments( int numPoints, const vec3_t *points, const vec3_t projection,
int maxPoints, vec3_t pointBuffer, int maxFragments, markFragment_t *fragmentBuffer );
/*
============================================================
SCENE GENERATION
============================================================
*/
void R_ToggleSmpFrame( void );
void RE_ClearScene( void );
void RE_AddRefEntityToScene( const refEntity_t *ent );
void RE_AddPolyToScene( qhandle_t hShader , int numVerts, const polyVert_t *verts, int num );
void RE_AddLightToScene( const vec3_t org, float intensity, float r, float g, float b );
void RE_AddAdditiveLightToScene( const vec3_t org, float intensity, float r, float g, float b );
void RE_RenderScene( const refdef_t *fd );
/*
=============================================================
ANIMATED MODELS
=============================================================
*/
void R_MakeAnimModel( model_t *model );
void R_AddAnimSurfaces( trRefEntity_t *ent );
void RB_SurfaceAnim( md4Surface_t *surfType );
/*
=============================================================
=============================================================
*/
void R_TransformModelToClip( const vec3_t src, const float *modelMatrix, const float *projectionMatrix,
vec4_t eye, vec4_t dst );
void R_TransformClipToWindow( const vec4_t clip, const viewParms_t *view, vec4_t normalized, vec4_t window );
void RB_DeformTessGeometry( void );
void RB_CalcEnvironmentTexCoords( float *dstTexCoords );
void RB_CalcFogTexCoords( float *dstTexCoords );
void RB_CalcScrollTexCoords( const float scroll[2], float *dstTexCoords );
void RB_CalcRotateTexCoords( float rotSpeed, float *dstTexCoords );
void RB_CalcScaleTexCoords( const float scale[2], float *dstTexCoords );
void RB_CalcTurbulentTexCoords( const waveForm_t *wf, float *dstTexCoords );
void RB_CalcTransformTexCoords( const texModInfo_t *tmi, float *dstTexCoords );
void RB_CalcModulateColorsByFog( unsigned char *dstColors );
void RB_CalcModulateAlphasByFog( unsigned char *dstColors );
void RB_CalcModulateRGBAsByFog( unsigned char *dstColors );
void RB_CalcWaveAlpha( const waveForm_t *wf, unsigned char *dstColors );
void RB_CalcWaveColor( const waveForm_t *wf, unsigned char *dstColors );
void RB_CalcAlphaFromEntity( unsigned char *dstColors );
void RB_CalcAlphaFromOneMinusEntity( unsigned char *dstColors );
void RB_CalcStretchTexCoords( const waveForm_t *wf, float *texCoords );
void RB_CalcColorFromEntity( unsigned char *dstColors );
void RB_CalcColorFromOneMinusEntity( unsigned char *dstColors );
void RB_CalcSpecularAlpha( unsigned char *alphas );
void RB_CalcDiffuseColor( unsigned char *colors );
/*
=============================================================
RENDERER BACK END FUNCTIONS
=============================================================
*/
void RB_RenderThread( void );
void RB_ExecuteRenderCommands( const void *data );
/*
=============================================================
RENDERER BACK END COMMAND QUEUE
=============================================================
*/
#define MAX_RENDER_COMMANDS 0x40000
typedef struct {
byte cmds[MAX_RENDER_COMMANDS];
int used;
} renderCommandList_t;
typedef struct {
int commandId;
float color[4];
} setColorCommand_t;
typedef struct {
int commandId;
int buffer;
} drawBufferCommand_t;
typedef struct {
int commandId;
image_t *image;
int width;
int height;
void *data;
} subImageCommand_t;
typedef struct {
int commandId;
} swapBuffersCommand_t;
typedef struct {
int commandId;
int buffer;
} endFrameCommand_t;
typedef struct {
int commandId;
shader_t *shader;
float x, y;
float w, h;
float s1, t1;
float s2, t2;
} stretchPicCommand_t;
typedef struct {
int commandId;
trRefdef_t refdef;
viewParms_t viewParms;
drawSurf_t *drawSurfs;
int numDrawSurfs;
} drawSurfsCommand_t;
typedef struct {
int commandId;
int x;
int y;
int width;
int height;
char *fileName;
qboolean jpeg;
} screenshotCommand_t;
typedef enum {
RC_END_OF_LIST,
RC_SET_COLOR,
RC_STRETCH_PIC,
RC_DRAW_SURFS,
RC_DRAW_BUFFER,
RC_SWAP_BUFFERS,
RC_SCREENSHOT
} renderCommand_t;
// these are sort of arbitrary limits.
// the limits apply to the sum of all scenes in a frame --
// the main view, all the 3D icons, etc
#define MAX_POLYS 600
#define MAX_POLYVERTS 3000
// all of the information needed by the back end must be
// contained in a backEndData_t. This entire structure is
// duplicated so the front and back end can run in parallel
// on an SMP machine
typedef struct {
drawSurf_t drawSurfs[MAX_DRAWSURFS];
dlight_t dlights[MAX_DLIGHTS];
trRefEntity_t entities[MAX_ENTITIES];
srfPoly_t *polys;//[MAX_POLYS];
polyVert_t *polyVerts;//[MAX_POLYVERTS];
renderCommandList_t commands;
} backEndData_t;
extern int max_polys;
extern int max_polyverts;
extern backEndData_t *backEndData[SMP_FRAMES]; // the second one may not be allocated
extern volatile renderCommandList_t *renderCommandList;
extern volatile qboolean renderThreadActive;
void *R_GetCommandBuffer( int bytes );
void RB_ExecuteRenderCommands( const void *data );
void R_InitCommandBuffers( void );
void R_ShutdownCommandBuffers( void );
void R_SyncRenderThread( void );
void R_AddDrawSurfCmd( drawSurf_t *drawSurfs, int numDrawSurfs );
void RE_SetColor( const float *rgba );
void RE_StretchPic ( float x, float y, float w, float h,
float s1, float t1, float s2, float t2, qhandle_t hShader );
void RE_BeginFrame( stereoFrame_t stereoFrame );
void RE_EndFrame( int *frontEndMsec, int *backEndMsec );
void SaveJPG(char * filename, int quality, int image_width, int image_height, unsigned char *image_buffer);
// font stuff
void R_InitFreeType();
void R_DoneFreeType();
void RE_RegisterFont(const char *fontName, int pointSize, fontInfo_t *font);
#endif //TR_LOCAL_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -