diff options
author | James Canete <use.less01@gmail.com> | 2012-10-28 20:22:13 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2013-01-12 21:20:55 +0000 |
commit | 8de7ce8c82617c0ced22227a7853c1f4b8d46157 (patch) | |
tree | 4968611ee5c5d8aa6aae5bdaa726fab7bd6819d6 /src | |
parent | 0029b7619d0710f2fd2a4e817bb037bbb036b706 (diff) |
Fix FBO_*() usage when framebuffers are unavailable or undesired.
Diffstat (limited to 'src')
-rw-r--r-- | src/rend2/tr_backend.c | 32 | ||||
-rw-r--r-- | src/rend2/tr_cmds.c | 15 | ||||
-rw-r--r-- | src/rend2/tr_fbo.c | 2 | ||||
-rw-r--r-- | src/rend2/tr_image.c | 18 | ||||
-rw-r--r-- | src/rend2/tr_init.c | 6 | ||||
-rw-r--r-- | src/rend2/tr_scene.c | 4 | ||||
-rw-r--r-- | src/rend2/tr_shade.c | 2 |
7 files changed, 43 insertions, 36 deletions
diff --git a/src/rend2/tr_backend.c b/src/rend2/tr_backend.c index 8c481e61..720cf1e9 100644 --- a/src/rend2/tr_backend.c +++ b/src/rend2/tr_backend.c @@ -815,7 +815,8 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { } #endif - FBO_Bind(fbo); + if (glRefConfig.framebufferObject) + FBO_Bind(fbo); // go back to the world modelview matrix @@ -1193,12 +1194,12 @@ const void *RB_DrawSurfs( const void *data ) { // 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 @@ const void *RB_DrawSurfs( const void *data ) { 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 @@ const void *RB_DrawSurfs( const void *data ) { RB_RenderFlares(); } - if (glRefConfig.framebufferObject) - FBO_Bind(NULL); + //if (glRefConfig.framebufferObject) + //FBO_Bind(NULL); return (const void *)(cmd + 1); } @@ -1453,6 +1454,9 @@ const void *RB_DrawBuffer( const void *data ) { cmd = (const drawBufferCommand_t *)data; + if (glRefConfig.framebufferObject) + FBO_Bind(NULL); + qglDrawBuffer( cmd->buffer ); // clear screen for debugging @@ -1564,14 +1568,18 @@ const void *RB_ClearDepth(const void *data) if (r_showImages->integer) RB_ShowImages(); - if (backEnd.framePostProcessed && (backEnd.refdef.rdflags & RDF_NOWORLDMODEL)) - { - FBO_Bind(tr.screenScratchFbo); - } - else + if (glRefConfig.framebufferObject) { - FBO_Bind(tr.renderFbo); + if (backEnd.framePostProcessed && (backEnd.refdef.rdflags & RDF_NOWORLDMODEL)) + { + FBO_Bind(tr.screenScratchFbo); + } + else + { + FBO_Bind(tr.renderFbo); + } } + qglClear(GL_DEPTH_BUFFER_BIT); // if we're doing MSAA, clear the depth texture for the resolve buffer diff --git a/src/rend2/tr_cmds.c b/src/rend2/tr_cmds.c index b853f2fe..9945da3f 100644 --- a/src/rend2/tr_cmds.c +++ b/src/rend2/tr_cmds.c @@ -498,12 +498,7 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) { 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 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) { 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; } diff --git a/src/rend2/tr_fbo.c b/src/rend2/tr_fbo.c index 0e4a2380..c3b72e20 100644 --- a/src/rend2/tr_fbo.c +++ b/src/rend2/tr_fbo.c @@ -795,7 +795,7 @@ void FBO_FastBlit(FBO_t *src, vec4i_t srcBox, FBO_t *dst, vec4i_t dstBox, int bu } // get to a neutral state first - FBO_Bind(NULL); + //FBO_Bind(NULL); srcFb = src ? src->frameBuffer : 0; dstFb = dst ? dst->frameBuffer : 0; diff --git a/src/rend2/tr_image.c b/src/rend2/tr_image.c index 6b530c41..eaf133b4 100644 --- a/src/rend2/tr_image.c +++ b/src/rend2/tr_image.c @@ -2919,6 +2919,7 @@ void R_CreateBuiltinImages( void ) { R_CreateDlightImage(); R_CreateFogImage(); + if (glRefConfig.framebufferObject) { int width, height, hdrFormat; @@ -3001,17 +3002,16 @@ void R_CreateBuiltinImages( void ) { 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); + } } } diff --git a/src/rend2/tr_init.c b/src/rend2/tr_init.c index 84b8b56b..1df69358 100644 --- a/src/rend2/tr_init.c +++ b/src/rend2/tr_init.c @@ -1411,7 +1411,8 @@ void R_Init( void ) { R_InitImages(); - FBO_Init(); + if (glRefConfig.framebufferObject) + FBO_Init(); GLSL_InitGPUShaders(); @@ -1463,7 +1464,8 @@ void RE_Shutdown( qboolean destroyWindow ) { R_SyncRenderThread(); R_ShutdownCommandBuffers(); R_ShutDownQueries(); - FBO_Shutdown(); + if (glRefConfig.framebufferObject) + FBO_Shutdown(); R_DeleteTextures(); R_ShutdownVBOs(); GLSL_ShutdownGPUShaders(); diff --git a/src/rend2/tr_scene.c b/src/rend2/tr_scene.c index 20f90547..eb58481e 100644 --- a/src/rend2/tr_scene.c +++ b/src/rend2/tr_scene.c @@ -476,13 +476,13 @@ void RE_RenderScene( const refdef_t *fd ) { } /* 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); diff --git a/src/rend2/tr_shade.c b/src/rend2/tr_shade.c index c74409e4..e0452d0c 100644 --- a/src/rend2/tr_shade.c +++ b/src/rend2/tr_shade.c @@ -1713,7 +1713,7 @@ void RB_StageIteratorGeneric( void ) // // 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(); } |