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

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Sun Oct 28 16:22:13 EDT 2012


Author: smiletheory
Date: 2012-10-28 16:22:13 -0400 (Sun, 28 Oct 2012)
New Revision: 2338

Modified:
   trunk/code/rend2/tr_backend.c
   trunk/code/rend2/tr_cmds.c
   trunk/code/rend2/tr_fbo.c
   trunk/code/rend2/tr_image.c
   trunk/code/rend2/tr_init.c
   trunk/code/rend2/tr_scene.c
   trunk/code/rend2/tr_shade.c
Log:
Fix FBO_*() usage when framebuffers are unavailable or undesired.

Modified: trunk/code/rend2/tr_backend.c
===================================================================
--- trunk/code/rend2/tr_backend.c	2012-10-28 18:00:29 UTC (rev 2337)
+++ trunk/code/rend2/tr_backend.c	2012-10-28 20:22:13 UTC (rev 2338)
@@ -815,7 +815,8 @@
 	}
 #endif
 
-	FBO_Bind(fbo);
+	if (glRefConfig.framebufferObject)
+		FBO_Bind(fbo);
 
 	// go back to the world modelview matrix
 
@@ -1193,12 +1194,12 @@
 	// clear the z buffer, set the modelview, etc
 	RB_BeginDrawingView ();
 
-	if ((backEnd.viewParms.flags & VPF_DEPTHCLAMP) && glRefConfig.depthClamp)
+	if (glRefConfig.framebufferObject && (backEnd.viewParms.flags & VPF_DEPTHCLAMP) && glRefConfig.depthClamp)
 	{
 		qglEnable(GL_DEPTH_CLAMP);
 	}
 
-	if (!(backEnd.refdef.rdflags & RDF_NOWORLDMODEL) && (r_depthPrepass->integer || (backEnd.viewParms.flags & VPF_DEPTHSHADOW)))
+	if (glRefConfig.framebufferObject && !(backEnd.refdef.rdflags & RDF_NOWORLDMODEL) && (r_depthPrepass->integer || (backEnd.viewParms.flags & VPF_DEPTHSHADOW)))
 	{
 		FBO_t *oldFbo = glState.currentFBO;
 
@@ -1416,7 +1417,7 @@
 		SetViewportAndScissor();
 	}
 
-	if ((backEnd.viewParms.flags & VPF_DEPTHCLAMP) && glRefConfig.depthClamp)
+	if (glRefConfig.framebufferObject && (backEnd.viewParms.flags & VPF_DEPTHCLAMP) && glRefConfig.depthClamp)
 	{
 		qglDisable(GL_DEPTH_CLAMP);
 	}
@@ -1435,8 +1436,8 @@
 		RB_RenderFlares();
 	}
 
-	if (glRefConfig.framebufferObject)
-		FBO_Bind(NULL);
+	//if (glRefConfig.framebufferObject)
+		//FBO_Bind(NULL);
 
 	return (const void *)(cmd + 1);
 }
@@ -1453,6 +1454,9 @@
 
 	cmd = (const drawBufferCommand_t *)data;
 
+	if (glRefConfig.framebufferObject)
+		FBO_Bind(NULL);
+
 	qglDrawBuffer( cmd->buffer );
 
 	// clear screen for debugging
@@ -1564,14 +1568,18 @@
 	if (r_showImages->integer)
 		RB_ShowImages();
 
-	if (backEnd.framePostProcessed && (backEnd.refdef.rdflags & RDF_NOWORLDMODEL))
+	if (glRefConfig.framebufferObject)
 	{
-		FBO_Bind(tr.screenScratchFbo);
+		if (backEnd.framePostProcessed && (backEnd.refdef.rdflags & RDF_NOWORLDMODEL))
+		{
+			FBO_Bind(tr.screenScratchFbo);
+		}
+		else
+		{
+			FBO_Bind(tr.renderFbo);
+		}
 	}
-	else
-	{
-		FBO_Bind(tr.renderFbo);
-	}
+
 	qglClear(GL_DEPTH_BUFFER_BIT);
 
 	// if we're doing MSAA, clear the depth texture for the resolve buffer

Modified: trunk/code/rend2/tr_cmds.c
===================================================================
--- trunk/code/rend2/tr_cmds.c	2012-10-28 18:00:29 UTC (rev 2337)
+++ trunk/code/rend2/tr_cmds.c	2012-10-28 20:22:13 UTC (rev 2338)
@@ -498,12 +498,7 @@
 				backEnd.colorMask[2] = GL_FALSE;
 				backEnd.colorMask[3] = GL_FALSE;
 				qglClearColor(0.0f, 0.0f, 0.0f, 1.0f);
-				
-				qglDrawBuffer(GL_FRONT);
-				qglClear(GL_COLOR_BUFFER_BIT);
-				qglDrawBuffer(GL_BACK);
-				qglClear(GL_COLOR_BUFFER_BIT);
-				
+								
 				if (glRefConfig.framebufferObject)
 				{
 					// clear all framebuffers
@@ -530,15 +525,17 @@
 								break;
 						}
 
-						qglDrawBuffer(GL_FRONT);
 						qglClear(GL_COLOR_BUFFER_BIT);
-						qglDrawBuffer(GL_BACK);
-						qglClear(GL_COLOR_BUFFER_BIT);	
 					}
 
 					FBO_Bind(NULL);
 				}
 
+				qglDrawBuffer(GL_FRONT);
+				qglClear(GL_COLOR_BUFFER_BIT);
+				qglDrawBuffer(GL_BACK);
+				qglClear(GL_COLOR_BUFFER_BIT);
+
 				r_anaglyphMode->modified = qfalse;
 			}
 			

Modified: trunk/code/rend2/tr_fbo.c
===================================================================
--- trunk/code/rend2/tr_fbo.c	2012-10-28 18:00:29 UTC (rev 2337)
+++ trunk/code/rend2/tr_fbo.c	2012-10-28 20:22:13 UTC (rev 2338)
@@ -795,7 +795,7 @@
 	}
 
 	// get to a neutral state first
-	FBO_Bind(NULL);
+	//FBO_Bind(NULL);
 
 	srcFb = src ? src->frameBuffer : 0;
 	dstFb = dst ? dst->frameBuffer : 0;

Modified: trunk/code/rend2/tr_image.c
===================================================================
--- trunk/code/rend2/tr_image.c	2012-10-28 18:00:29 UTC (rev 2337)
+++ trunk/code/rend2/tr_image.c	2012-10-28 20:22:13 UTC (rev 2338)
@@ -2919,6 +2919,7 @@
 	R_CreateDlightImage();
 	R_CreateFogImage();
 
+	if (glRefConfig.framebufferObject)
 	{
 		int width, height, hdrFormat;
 
@@ -3001,17 +3002,16 @@
 			tr.screenSsaoImage = R_CreateImage("*screenSsao", NULL, width / 2, height / 2, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_RGBA8);
 			tr.hdrDepthImage = R_CreateImage("*hdrDepth", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_INTENSITY32F_ARB);
 		}
-	}
 
-	for( x = 0; x < MAX_DRAWN_PSHADOWS; x++)
-	{
-		tr.pshadowMaps[x] = R_CreateImage(va("*shadowmap%i", x), NULL, PSHADOW_MAP_SIZE, PSHADOW_MAP_SIZE, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_RGBA8);
-	}
+		for( x = 0; x < MAX_DRAWN_PSHADOWS; x++)
+		{
+			tr.pshadowMaps[x] = R_CreateImage(va("*shadowmap%i", x), NULL, PSHADOW_MAP_SIZE, PSHADOW_MAP_SIZE, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_RGBA8);
+		}
 
-	//tr.sunShadowImage = R_CreateImage("*sunshadowmap", NULL, SUNSHADOW_MAP_SIZE, SUNSHADOW_MAP_SIZE, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_RGBA8);
-	for ( x = 0; x < 3; x++)
-	{
-		tr.sunShadowDepthImage[x] = R_CreateImage(va("*sunshadowdepth%i", x),  NULL, r_shadowMapSize->integer, r_shadowMapSize->integer, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_DEPTH_COMPONENT24_ARB);
+		for ( x = 0; x < 3; x++)
+		{
+			tr.sunShadowDepthImage[x] = R_CreateImage(va("*sunshadowdepth%i", x), NULL, r_shadowMapSize->integer, r_shadowMapSize->integer, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_DEPTH_COMPONENT24_ARB);
+		}
 	}
 }
 

Modified: trunk/code/rend2/tr_init.c
===================================================================
--- trunk/code/rend2/tr_init.c	2012-10-28 18:00:29 UTC (rev 2337)
+++ trunk/code/rend2/tr_init.c	2012-10-28 20:22:13 UTC (rev 2338)
@@ -1411,7 +1411,8 @@
 
 	R_InitImages();
 
-	FBO_Init();
+	if (glRefConfig.framebufferObject)
+		FBO_Init();
 
 	GLSL_InitGPUShaders();
 
@@ -1463,7 +1464,8 @@
 		R_SyncRenderThread();
 		R_ShutdownCommandBuffers();
 		R_ShutDownQueries();
-		FBO_Shutdown();
+		if (glRefConfig.framebufferObject)
+			FBO_Shutdown();
 		R_DeleteTextures();
 		R_ShutdownVBOs();
 		GLSL_ShutdownGPUShaders();

Modified: trunk/code/rend2/tr_scene.c
===================================================================
--- trunk/code/rend2/tr_scene.c	2012-10-28 18:00:29 UTC (rev 2337)
+++ trunk/code/rend2/tr_scene.c	2012-10-28 20:22:13 UTC (rev 2338)
@@ -476,13 +476,13 @@
 	}
 
 	/* playing with more shadows */
-	if(!( fd->rdflags & RDF_NOWORLDMODEL ) && r_shadows->integer == 4)
+	if(glRefConfig.framebufferObject && !( fd->rdflags & RDF_NOWORLDMODEL ) && r_shadows->integer == 4)
 	{
 		R_RenderPshadowMaps(fd);
 	}
 
 	// playing with even more shadows
-	if(!( fd->rdflags & RDF_NOWORLDMODEL ) && (r_forceSun->integer || tr.sunShadows))
+	if(glRefConfig.framebufferObject && !( fd->rdflags & RDF_NOWORLDMODEL ) && (r_forceSun->integer || tr.sunShadows))
 	{
 		R_RenderSunShadowMaps(fd, 0);
 		R_RenderSunShadowMaps(fd, 1);

Modified: trunk/code/rend2/tr_shade.c
===================================================================
--- trunk/code/rend2/tr_shade.c	2012-10-28 18:00:29 UTC (rev 2337)
+++ trunk/code/rend2/tr_shade.c	2012-10-28 20:22:13 UTC (rev 2338)
@@ -1713,7 +1713,7 @@
 	//
 	// pshadows!
 	//
-	if ( tess.pshadowBits && tess.shader->sort <= SS_OPAQUE
+	if (glRefConfig.framebufferObject && tess.pshadowBits && tess.shader->sort <= SS_OPAQUE
 		&& !(tess.shader->surfaceFlags & (SURF_NODLIGHT | SURF_SKY) ) ) {
 		ProjectPshadowVBOGLSL();
 	}



More information about the quake3-commits mailing list