mirror of
https://github.com/UberGames/lilium-voyager.git
synced 2024-11-10 14:41:42 +00:00
Fix FBO_*() usage when framebuffers are unavailable or undesired.
This commit is contained in:
parent
c4aa3cf8c0
commit
5cbe7888f8
7 changed files with 43 additions and 36 deletions
|
@ -815,6 +815,7 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (glRefConfig.framebufferObject)
|
||||||
FBO_Bind(fbo);
|
FBO_Bind(fbo);
|
||||||
|
|
||||||
// go back to the world modelview matrix
|
// 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
|
// clear the z buffer, set the modelview, etc
|
||||||
RB_BeginDrawingView ();
|
RB_BeginDrawingView ();
|
||||||
|
|
||||||
if ((backEnd.viewParms.flags & VPF_DEPTHCLAMP) && glRefConfig.depthClamp)
|
if (glRefConfig.framebufferObject && (backEnd.viewParms.flags & VPF_DEPTHCLAMP) && glRefConfig.depthClamp)
|
||||||
{
|
{
|
||||||
qglEnable(GL_DEPTH_CLAMP);
|
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;
|
FBO_t *oldFbo = glState.currentFBO;
|
||||||
|
|
||||||
|
@ -1416,7 +1417,7 @@ const void *RB_DrawSurfs( const void *data ) {
|
||||||
SetViewportAndScissor();
|
SetViewportAndScissor();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((backEnd.viewParms.flags & VPF_DEPTHCLAMP) && glRefConfig.depthClamp)
|
if (glRefConfig.framebufferObject && (backEnd.viewParms.flags & VPF_DEPTHCLAMP) && glRefConfig.depthClamp)
|
||||||
{
|
{
|
||||||
qglDisable(GL_DEPTH_CLAMP);
|
qglDisable(GL_DEPTH_CLAMP);
|
||||||
}
|
}
|
||||||
|
@ -1435,8 +1436,8 @@ const void *RB_DrawSurfs( const void *data ) {
|
||||||
RB_RenderFlares();
|
RB_RenderFlares();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (glRefConfig.framebufferObject)
|
//if (glRefConfig.framebufferObject)
|
||||||
FBO_Bind(NULL);
|
//FBO_Bind(NULL);
|
||||||
|
|
||||||
return (const void *)(cmd + 1);
|
return (const void *)(cmd + 1);
|
||||||
}
|
}
|
||||||
|
@ -1453,6 +1454,9 @@ const void *RB_DrawBuffer( const void *data ) {
|
||||||
|
|
||||||
cmd = (const drawBufferCommand_t *)data;
|
cmd = (const drawBufferCommand_t *)data;
|
||||||
|
|
||||||
|
if (glRefConfig.framebufferObject)
|
||||||
|
FBO_Bind(NULL);
|
||||||
|
|
||||||
qglDrawBuffer( cmd->buffer );
|
qglDrawBuffer( cmd->buffer );
|
||||||
|
|
||||||
// clear screen for debugging
|
// clear screen for debugging
|
||||||
|
@ -1564,6 +1568,8 @@ const void *RB_ClearDepth(const void *data)
|
||||||
if (r_showImages->integer)
|
if (r_showImages->integer)
|
||||||
RB_ShowImages();
|
RB_ShowImages();
|
||||||
|
|
||||||
|
if (glRefConfig.framebufferObject)
|
||||||
|
{
|
||||||
if (backEnd.framePostProcessed && (backEnd.refdef.rdflags & RDF_NOWORLDMODEL))
|
if (backEnd.framePostProcessed && (backEnd.refdef.rdflags & RDF_NOWORLDMODEL))
|
||||||
{
|
{
|
||||||
FBO_Bind(tr.screenScratchFbo);
|
FBO_Bind(tr.screenScratchFbo);
|
||||||
|
@ -1572,6 +1578,8 @@ const void *RB_ClearDepth(const void *data)
|
||||||
{
|
{
|
||||||
FBO_Bind(tr.renderFbo);
|
FBO_Bind(tr.renderFbo);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
qglClear(GL_DEPTH_BUFFER_BIT);
|
qglClear(GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
// if we're doing MSAA, clear the depth texture for the resolve buffer
|
// if we're doing MSAA, clear the depth texture for the resolve buffer
|
||||||
|
|
|
@ -499,11 +499,6 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) {
|
||||||
backEnd.colorMask[3] = GL_FALSE;
|
backEnd.colorMask[3] = GL_FALSE;
|
||||||
qglClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
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)
|
if (glRefConfig.framebufferObject)
|
||||||
{
|
{
|
||||||
// clear all framebuffers
|
// clear all framebuffers
|
||||||
|
@ -530,15 +525,17 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
qglDrawBuffer(GL_FRONT);
|
|
||||||
qglClear(GL_COLOR_BUFFER_BIT);
|
|
||||||
qglDrawBuffer(GL_BACK);
|
|
||||||
qglClear(GL_COLOR_BUFFER_BIT);
|
qglClear(GL_COLOR_BUFFER_BIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
FBO_Bind(NULL);
|
FBO_Bind(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qglDrawBuffer(GL_FRONT);
|
||||||
|
qglClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
qglDrawBuffer(GL_BACK);
|
||||||
|
qglClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
r_anaglyphMode->modified = qfalse;
|
r_anaglyphMode->modified = qfalse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
// get to a neutral state first
|
||||||
FBO_Bind(NULL);
|
//FBO_Bind(NULL);
|
||||||
|
|
||||||
srcFb = src ? src->frameBuffer : 0;
|
srcFb = src ? src->frameBuffer : 0;
|
||||||
dstFb = dst ? dst->frameBuffer : 0;
|
dstFb = dst ? dst->frameBuffer : 0;
|
||||||
|
|
|
@ -2919,6 +2919,7 @@ void R_CreateBuiltinImages( void ) {
|
||||||
R_CreateDlightImage();
|
R_CreateDlightImage();
|
||||||
R_CreateFogImage();
|
R_CreateFogImage();
|
||||||
|
|
||||||
|
if (glRefConfig.framebufferObject)
|
||||||
{
|
{
|
||||||
int width, height, hdrFormat;
|
int width, height, hdrFormat;
|
||||||
|
|
||||||
|
@ -3001,19 +3002,18 @@ void R_CreateBuiltinImages( void ) {
|
||||||
tr.screenSsaoImage = R_CreateImage("*screenSsao", NULL, width / 2, height / 2, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_RGBA8);
|
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);
|
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++)
|
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.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++)
|
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);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -1411,6 +1411,7 @@ void R_Init( void ) {
|
||||||
|
|
||||||
R_InitImages();
|
R_InitImages();
|
||||||
|
|
||||||
|
if (glRefConfig.framebufferObject)
|
||||||
FBO_Init();
|
FBO_Init();
|
||||||
|
|
||||||
GLSL_InitGPUShaders();
|
GLSL_InitGPUShaders();
|
||||||
|
@ -1463,6 +1464,7 @@ void RE_Shutdown( qboolean destroyWindow ) {
|
||||||
R_SyncRenderThread();
|
R_SyncRenderThread();
|
||||||
R_ShutdownCommandBuffers();
|
R_ShutdownCommandBuffers();
|
||||||
R_ShutDownQueries();
|
R_ShutDownQueries();
|
||||||
|
if (glRefConfig.framebufferObject)
|
||||||
FBO_Shutdown();
|
FBO_Shutdown();
|
||||||
R_DeleteTextures();
|
R_DeleteTextures();
|
||||||
R_ShutdownVBOs();
|
R_ShutdownVBOs();
|
||||||
|
|
|
@ -476,13 +476,13 @@ void RE_RenderScene( const refdef_t *fd ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* playing with more shadows */
|
/* 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);
|
R_RenderPshadowMaps(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
// playing with even more shadows
|
// 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, 0);
|
||||||
R_RenderSunShadowMaps(fd, 1);
|
R_RenderSunShadowMaps(fd, 1);
|
||||||
|
|
|
@ -1713,7 +1713,7 @@ void RB_StageIteratorGeneric( void )
|
||||||
//
|
//
|
||||||
// pshadows!
|
// 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) ) ) {
|
&& !(tess.shader->surfaceFlags & (SURF_NODLIGHT | SURF_SKY) ) ) {
|
||||||
ProjectPshadowVBOGLSL();
|
ProjectPshadowVBOGLSL();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue