diff --git a/code/renderer/tr_backend.cpp b/code/renderer/tr_backend.cpp index 7e09518..9965f14 100644 --- a/code/renderer/tr_backend.cpp +++ b/code/renderer/tr_backend.cpp @@ -687,4 +687,13 @@ void RB_PopShader() { tess.shader = prevShader; tess.xstages = prevStages; -} \ No newline at end of file +} + + +// used when a player has predicted a teleport, but hasn't arrived yet +float RB_HyperspaceColor() +{ + const float c = 0.25f + 0.5f * sinf(M_PI * (backEnd.refdef.time & 0x01FF) / 0x0200); + + return c; +} diff --git a/code/renderer/tr_backend_d3d11.cpp b/code/renderer/tr_backend_d3d11.cpp index 138ad21..9917dec 100644 --- a/code/renderer/tr_backend_d3d11.cpp +++ b/code/renderer/tr_backend_d3d11.cpp @@ -2307,19 +2307,17 @@ static void GAL_Begin3D() memcpy(d3d.projectionMatrix, backEnd.viewParms.projectionMatrix, sizeof(d3d.projectionMatrix)); ApplyViewportAndScissor(backEnd.viewParms.viewportX, backEnd.viewParms.viewportY, backEnd.viewParms.viewportWidth, backEnd.viewParms.viewportHeight, glConfig.vidHeight); + d3d.context->ClearDepthStencilView(d3d.depthStencilView, D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 1.0f, 0); if(backEnd.refdef.rdflags & RDF_HYPERSPACE) { - const FLOAT c = 0.25 + 0.5 * sin(M_PI * (backEnd.refdef.time & 0x01FF) / 0x0200); + const FLOAT c = RB_HyperspaceColor(); const FLOAT clearColor[4] = { c, c, c, 1.0f }; - d3d.context->ClearRenderTargetView(d3d.backBufferRTView, clearColor); - return; + d3d.context->ClearRenderTargetView(d3d.renderTargetViewMS, clearColor); } - - d3d.context->ClearDepthStencilView(d3d.depthStencilView, D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 1.0f, 0); - if(r_fastsky->integer && !(backEnd.refdef.rdflags & RDF_NOWORLDMODEL)) + else if(r_fastsky->integer && !(backEnd.refdef.rdflags & RDF_NOWORLDMODEL)) { const FLOAT clearColor[4] = { 0.0f, 0.0f, 0.0f, 1.0f }; - d3d.context->ClearRenderTargetView(d3d.backBufferRTView, clearColor); + d3d.context->ClearRenderTargetView(d3d.renderTargetViewMS, clearColor); } if(backEnd.viewParms.isPortal) diff --git a/code/renderer/tr_backend_gl2.cpp b/code/renderer/tr_backend_gl2.cpp index cb80215..d590fe4 100644 --- a/code/renderer/tr_backend_gl2.cpp +++ b/code/renderer/tr_backend_gl2.cpp @@ -1141,16 +1141,6 @@ static void GL_State( unsigned long stateBits ) } -// a player has predicted a teleport, but hasn't arrived yet - -static void RB_Hyperspace() -{ - float c = 0.25 + 0.5 * sin( M_PI * (backEnd.refdef.time & 0x01FF) / 0x0200 ); - glClearColor( c, c, c, 1 ); - glClear( GL_COLOR_BUFFER_BIT ); -} - - static void ApplyViewportAndScissor() { glMatrixMode(GL_PROJECTION); @@ -1191,8 +1181,11 @@ static void GAL_Begin3D() // clear relevant buffers clearBits = GL_DEPTH_BUFFER_BIT; - if ( r_fastsky->integer && !( backEnd.refdef.rdflags & RDF_NOWORLDMODEL ) ) - { + if ( backEnd.refdef.rdflags & RDF_HYPERSPACE ) { + const float c = RB_HyperspaceColor(); + clearBits |= GL_COLOR_BUFFER_BIT; + glClearColor( c, c, c, 1.0f ); + } else if ( r_fastsky->integer && !( backEnd.refdef.rdflags & RDF_NOWORLDMODEL ) ) { clearBits |= GL_COLOR_BUFFER_BIT; // tr.sunLight could have colored fastsky properly for the last 9 years, // ... if the code had actually been right >:( but, it's a bad idea to trust mappers anyway @@ -1200,11 +1193,6 @@ static void GAL_Begin3D() } glClear( clearBits ); - if ( backEnd.refdef.rdflags & RDF_HYPERSPACE ) { - RB_Hyperspace(); - return; - } - glState.faceCulling = -1; // force face culling to set next time // clip to the plane of the portal diff --git a/code/renderer/tr_backend_gl3.cpp b/code/renderer/tr_backend_gl3.cpp index 51e2c46..fe598d1 100644 --- a/code/renderer/tr_backend_gl3.cpp +++ b/code/renderer/tr_backend_gl3.cpp @@ -2283,7 +2283,13 @@ static void GAL_Begin3D() ApplyState(GLS_DEFAULT, CT_TWO_SIDED, qfalse); GLbitfield clearBits = GL_DEPTH_BUFFER_BIT; - if(r_fastsky->integer && (backEnd.refdef.rdflags & RDF_NOWORLDMODEL) != 0) + if(backEnd.refdef.rdflags & RDF_HYPERSPACE) + { + clearBits |= GL_COLOR_BUFFER_BIT; + const float c = RB_HyperspaceColor(); + glClearColor(c, c, c, 1.0f); + } + else if(r_fastsky->integer && (backEnd.refdef.rdflags & RDF_NOWORLDMODEL) != 0) { clearBits |= GL_COLOR_BUFFER_BIT; glClearColor(0.0f, 0.0f, 0.0f, 1.0f); diff --git a/code/renderer/tr_local.h b/code/renderer/tr_local.h index f45630f..5d1570d 100644 --- a/code/renderer/tr_local.h +++ b/code/renderer/tr_local.h @@ -1563,6 +1563,8 @@ void RB_ExecuteRenderCommands( const void *data ); void RB_PushSingleStageShader( int stateBits, cullType_t cullType ); void RB_PopShader(); +float RB_HyperspaceColor(); + void RB_DrawSky(); void R_BuildCloudData();