[quake3-commits] r2348 - trunk/code/rend2

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Tue Oct 30 18:05:08 EDT 2012


Author: smiletheory
Date: 2012-10-30 18:05:07 -0400 (Tue, 30 Oct 2012)
New Revision: 2348

Modified:
   trunk/code/rend2/tr_backend.c
   trunk/code/rend2/tr_fbo.c
   trunk/code/rend2/tr_scene.c
Log:
Ensure the correct FBO is bound when drawing. (Fixes bug #5791.)

Modified: trunk/code/rend2/tr_backend.c
===================================================================
--- trunk/code/rend2/tr_backend.c	2012-10-30 20:06:48 UTC (rev 2347)
+++ trunk/code/rend2/tr_backend.c	2012-10-30 22:05:07 UTC (rev 2348)
@@ -482,9 +482,17 @@
 	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 @@
 	}
 
 	// FIXME: HUGE hack
-	if (glRefConfig.framebufferObject && !glState.currentFBO)
+	if (glRefConfig.framebufferObject)
 	{
 		if (backEnd.framePostProcessed)
 		{
@@ -1092,7 +1100,7 @@
 	cmd = (const stretchPicCommand_t *)data;
 
 	// FIXME: HUGE hack
-	if (glRefConfig.framebufferObject && !glState.currentFBO)
+	if (glRefConfig.framebufferObject)
 	{
 		if (backEnd.framePostProcessed)
 		{
@@ -1570,7 +1578,7 @@
 
 	if (glRefConfig.framebufferObject)
 	{
-		if (backEnd.framePostProcessed && (backEnd.refdef.rdflags & RDF_NOWORLDMODEL))
+		if (backEnd.framePostProcessed)
 		{
 			FBO_Bind(tr.screenScratchFbo);
 		}

Modified: trunk/code/rend2/tr_fbo.c
===================================================================
--- trunk/code/rend2/tr_fbo.c	2012-10-30 20:06:48 UTC (rev 2347)
+++ trunk/code/rend2/tr_fbo.c	2012-10-30 22:05:07 UTC (rev 2348)
@@ -661,6 +661,8 @@
 	vec2_t texCoords[4];
 	vec2_t invTexRes;
 	FBO_t *oldFbo = glState.currentFBO;
+	matrix_t projection;
+	int width, height;
 
 	if (!src)
 		return;
@@ -726,12 +728,26 @@
 
 	FBO_Bind(dst);
 
-	RB_SetGL2D();
+	if (glState.currentFBO)
+	{
+		width = glState.currentFBO->width;
+		height = glState.currentFBO->height;
+	}
+	else
+	{
+		width = glConfig.vidWidth;
+		height = glConfig.vidHeight;
+	}
 
-	GL_SelectTexture(TB_COLORMAP);
+	qglViewport( 0, 0, width, height );
+	qglScissor( 0, 0, width, height );
 
-	GL_Bind(src);
+	Matrix16Ortho(0, width, height, 0, 0, 1, projection);
 
+	qglDisable( GL_CULL_FACE );
+
+	GL_BindToTMU(src, TB_COLORMAP);
+
 	VectorSet4(quadVerts[0], dstBox[0], dstBox[1], 0, 1);
 	VectorSet4(quadVerts[1], dstBox[2], dstBox[1], 0, 1);
 	VectorSet4(quadVerts[2], dstBox[2], dstBox[3], 0, 1);
@@ -749,7 +765,7 @@
 
 	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);

Modified: trunk/code/rend2/tr_scene.c
===================================================================
--- trunk/code/rend2/tr_scene.c	2012-10-30 20:06:48 UTC (rev 2347)
+++ trunk/code/rend2/tr_scene.c	2012-10-30 22:05:07 UTC (rev 2348)
@@ -507,11 +507,6 @@
 	
 	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] );



More information about the quake3-commits mailing list