diff options
author | James Canete <use.less01@gmail.com> | 2012-10-30 22:05:07 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2013-01-12 21:23:56 +0000 |
commit | bb9e18b2e399cfbea383c99f135e4d5ad308870d (patch) | |
tree | 60cba81be52c9001ca4ed207c7a2c8d49c9ab17a /src | |
parent | 819fbad8191e8e646aa5b4c8dc4b79803126e5a5 (diff) |
Ensure the correct FBO is bound when drawing. (Fixes bug #5791.)
Diffstat (limited to 'src')
-rw-r--r-- | src/rend2/tr_backend.c | 18 | ||||
-rw-r--r-- | src/rend2/tr_fbo.c | 24 | ||||
-rw-r--r-- | src/rend2/tr_scene.c | 5 |
3 files changed, 33 insertions, 14 deletions
diff --git a/src/rend2/tr_backend.c b/src/rend2/tr_backend.c index 720cf1e9..678f9aa7 100644 --- a/src/rend2/tr_backend.c +++ b/src/rend2/tr_backend.c @@ -482,9 +482,17 @@ void RB_BeginDrawingView (void) { if (glRefConfig.framebufferObject) { // FIXME: HUGE HACK: render to the screen fbo if we've already postprocessed the frame and aren't drawing more world - if (backEnd.viewParms.targetFbo == tr.renderFbo && backEnd.framePostProcessed && (backEnd.refdef.rdflags & RDF_NOWORLDMODEL)) + // drawing more world check is in case of double renders, such as skyportals + if (backEnd.viewParms.targetFbo == NULL) { - FBO_Bind(tr.screenScratchFbo); + if (backEnd.framePostProcessed && (backEnd.refdef.rdflags & RDF_NOWORLDMODEL)) + { + FBO_Bind(tr.screenScratchFbo); + } + else + { + FBO_Bind(tr.renderFbo); + } } else { @@ -949,7 +957,7 @@ void RE_StretchRaw (int x, int y, int w, int h, int cols, int rows, const byte * } // FIXME: HUGE hack - if (glRefConfig.framebufferObject && !glState.currentFBO) + if (glRefConfig.framebufferObject) { if (backEnd.framePostProcessed) { @@ -1092,7 +1100,7 @@ const void *RB_StretchPic ( const void *data ) { cmd = (const stretchPicCommand_t *)data; // FIXME: HUGE hack - if (glRefConfig.framebufferObject && !glState.currentFBO) + if (glRefConfig.framebufferObject) { if (backEnd.framePostProcessed) { @@ -1570,7 +1578,7 @@ const void *RB_ClearDepth(const void *data) if (glRefConfig.framebufferObject) { - if (backEnd.framePostProcessed && (backEnd.refdef.rdflags & RDF_NOWORLDMODEL)) + if (backEnd.framePostProcessed) { FBO_Bind(tr.screenScratchFbo); } diff --git a/src/rend2/tr_fbo.c b/src/rend2/tr_fbo.c index c3b72e20..04f9ff26 100644 --- a/src/rend2/tr_fbo.c +++ b/src/rend2/tr_fbo.c @@ -661,6 +661,8 @@ void FBO_BlitFromTexture(struct image_s *src, vec4i_t inSrcBox, vec2_t inSrcTexS vec2_t texCoords[4]; vec2_t invTexRes; FBO_t *oldFbo = glState.currentFBO; + matrix_t projection; + int width, height; if (!src) return; @@ -726,11 +728,25 @@ void FBO_BlitFromTexture(struct image_s *src, vec4i_t inSrcBox, vec2_t inSrcTexS FBO_Bind(dst); - RB_SetGL2D(); + if (glState.currentFBO) + { + width = glState.currentFBO->width; + height = glState.currentFBO->height; + } + else + { + width = glConfig.vidWidth; + height = glConfig.vidHeight; + } + + qglViewport( 0, 0, width, height ); + qglScissor( 0, 0, width, height ); + + Matrix16Ortho(0, width, height, 0, 0, 1, projection); - GL_SelectTexture(TB_COLORMAP); + qglDisable( GL_CULL_FACE ); - GL_Bind(src); + GL_BindToTMU(src, TB_COLORMAP); VectorSet4(quadVerts[0], dstBox[0], dstBox[1], 0, 1); VectorSet4(quadVerts[1], dstBox[2], dstBox[1], 0, 1); @@ -749,7 +765,7 @@ void FBO_BlitFromTexture(struct image_s *src, vec4i_t inSrcBox, vec2_t inSrcTexS GLSL_BindProgram(shaderProgram); - GLSL_SetUniformMatrix16(shaderProgram, TEXTURECOLOR_UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); + GLSL_SetUniformMatrix16(shaderProgram, TEXTURECOLOR_UNIFORM_MODELVIEWPROJECTIONMATRIX, projection); GLSL_SetUniformVec4(shaderProgram, TEXTURECOLOR_UNIFORM_COLOR, color); GLSL_SetUniformVec2(shaderProgram, TEXTURECOLOR_UNIFORM_INVTEXRES, invTexRes); GLSL_SetUniformVec2(shaderProgram, TEXTURECOLOR_UNIFORM_AUTOEXPOSUREMINMAX, tr.refdef.autoExposureMinMax); diff --git a/src/rend2/tr_scene.c b/src/rend2/tr_scene.c index eb58481e..f134c997 100644 --- a/src/rend2/tr_scene.c +++ b/src/rend2/tr_scene.c @@ -507,11 +507,6 @@ void RE_RenderScene( const refdef_t *fd ) { parms.stereoFrame = tr.refdef.stereoFrame; - if (glRefConfig.framebufferObject) - { - parms.targetFbo = tr.renderFbo; - } - VectorCopy( fd->vieworg, parms.or.origin ); VectorCopy( fd->viewaxis[0], parms.or.axis[0] ); VectorCopy( fd->viewaxis[1], parms.or.axis[1] ); |