summaryrefslogtreecommitdiff
path: root/src/renderer/tr_backend.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/renderer/tr_backend.c')
-rw-r--r--src/renderer/tr_backend.c103
1 files changed, 94 insertions, 9 deletions
diff --git a/src/renderer/tr_backend.c b/src/renderer/tr_backend.c
index 9c9b841a..5eed467a 100644
--- a/src/renderer/tr_backend.c
+++ b/src/renderer/tr_backend.c
@@ -522,7 +522,7 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {
int fogNum, oldFogNum;
int entityNum, oldEntityNum;
int dlighted, oldDlighted;
- qboolean depthRange, oldDepthRange;
+ qboolean depthRange, oldDepthRange, isCrosshair, wasCrosshair;
int i;
drawSurf_t *drawSurf;
int oldSort;
@@ -540,6 +540,7 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {
oldShader = NULL;
oldFogNum = -1;
oldDepthRange = qfalse;
+ wasCrosshair = qfalse;
oldDlighted = qfalse;
oldSort = -1;
depthRange = qfalse;
@@ -574,7 +575,7 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {
// change the modelview matrix if needed
//
if ( entityNum != oldEntityNum ) {
- depthRange = qfalse;
+ depthRange = isCrosshair = qfalse;
if ( entityNum != ENTITYNUM_WORLD ) {
backEnd.currentEntity = &backEnd.refdef.entities[entityNum];
@@ -591,9 +592,13 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {
R_TransformDlights( backEnd.refdef.num_dlights, backEnd.refdef.dlights, &backEnd.or );
}
- if ( backEnd.currentEntity->e.renderfx & RF_DEPTHHACK ) {
+ if(backEnd.currentEntity->e.renderfx & RF_DEPTHHACK)
+ {
// hack the depth range to prevent view model from poking into walls
depthRange = qtrue;
+
+ if(backEnd.currentEntity->e.renderfx & RF_CROSSHAIR)
+ isCrosshair = qtrue;
}
} else {
backEnd.currentEntity = &tr.worldEntity;
@@ -608,15 +613,54 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {
qglLoadMatrixf( backEnd.or.modelMatrix );
//
- // change depthrange if needed
+ // change depthrange. Also change projection matrix so first person weapon does not look like coming
+ // out of the screen.
//
- if ( oldDepthRange != depthRange ) {
- if ( depthRange ) {
- qglDepthRange (0, 0.3);
- } else {
+ if (oldDepthRange != depthRange || wasCrosshair != isCrosshair)
+ {
+ if (depthRange)
+ {
+ if(backEnd.viewParms.stereoFrame != STEREO_CENTER)
+ {
+ if(isCrosshair)
+ {
+ if(oldDepthRange)
+ {
+ // was not a crosshair but now is, change back proj matrix
+ qglMatrixMode(GL_PROJECTION);
+ qglLoadMatrixf(backEnd.viewParms.projectionMatrix);
+ qglMatrixMode(GL_MODELVIEW);
+ }
+ }
+ else
+ {
+ viewParms_t temp = backEnd.viewParms;
+
+ R_SetupProjection(&temp, r_znear->value, qfalse);
+
+ qglMatrixMode(GL_PROJECTION);
+ qglLoadMatrixf(temp.projectionMatrix);
+ qglMatrixMode(GL_MODELVIEW);
+ }
+ }
+
+ if(!oldDepthRange)
+ qglDepthRange (0, 0.3);
+ }
+ else
+ {
+ if(!wasCrosshair && backEnd.viewParms.stereoFrame != STEREO_CENTER)
+ {
+ qglMatrixMode(GL_PROJECTION);
+ qglLoadMatrixf(backEnd.viewParms.projectionMatrix);
+ qglMatrixMode(GL_MODELVIEW);
+ }
+
qglDepthRange (0, 1);
}
+
oldDepthRange = depthRange;
+ wasCrosshair = isCrosshair;
}
oldEntityNum = entityNum;
@@ -989,6 +1033,42 @@ void RB_ShowImages( void ) {
}
+/*
+=============
+RB_ColorMask
+
+=============
+*/
+const void *RB_ColorMask(const void *data)
+{
+ const colorMaskCommand_t *cmd = data;
+
+ qglColorMask(cmd->rgba[0], cmd->rgba[1], cmd->rgba[2], cmd->rgba[3]);
+
+ return (const void *)(cmd + 1);
+}
+
+/*
+=============
+RB_ClearDepth
+
+=============
+*/
+const void *RB_ClearDepth(const void *data)
+{
+ const clearDepthCommand_t *cmd = data;
+
+ if(tess.numIndexes)
+ RB_EndSurface();
+
+ // texture swapping test
+ if (r_showImages->integer)
+ RB_ShowImages();
+
+ qglClear(GL_DEPTH_BUFFER_BIT);
+
+ return (const void *)(cmd + 1);
+}
/*
=============
@@ -1085,7 +1165,12 @@ void RB_ExecuteRenderCommands( const void *data ) {
case RC_VIDEOFRAME:
data = RB_TakeVideoFrameCmd( data );
break;
-
+ case RC_COLORMASK:
+ data = RB_ColorMask(data);
+ break;
+ case RC_CLEARDEPTH:
+ data = RB_ClearDepth(data);
+ break;
case RC_END_OF_LIST:
default:
// stop rendering on this thread