- // allocate textures as needed
- if (r_bloomstate.screentexturewidth != screentexturewidth
- || r_bloomstate.screentextureheight != screentextureheight
- || r_bloomstate.bloomtexturewidth != bloomtexturewidth
- || r_bloomstate.bloomtextureheight != bloomtextureheight
- || r_bloomstate.texturetype != textype
- || r_bloomstate.viewfbo != r_viewfbo.integer)
- {
- if (r_bloomstate.texture_bloom)
- R_FreeTexture(r_bloomstate.texture_bloom);
- r_bloomstate.texture_bloom = NULL;
- if (r_bloomstate.texture_screen)
- R_FreeTexture(r_bloomstate.texture_screen);
- r_bloomstate.texture_screen = NULL;
- if (r_bloomstate.fbo_framebuffer)
- R_Mesh_DestroyFramebufferObject(r_bloomstate.fbo_framebuffer);
- r_bloomstate.fbo_framebuffer = 0;
- if (r_bloomstate.texture_framebuffercolor)
- R_FreeTexture(r_bloomstate.texture_framebuffercolor);
- r_bloomstate.texture_framebuffercolor = NULL;
- if (r_bloomstate.texture_framebufferdepth)
- R_FreeTexture(r_bloomstate.texture_framebufferdepth);
- r_bloomstate.texture_framebufferdepth = NULL;
- r_bloomstate.screentexturewidth = screentexturewidth;
- r_bloomstate.screentextureheight = screentextureheight;
- if (r_bloomstate.screentexturewidth && r_bloomstate.screentextureheight)
- r_bloomstate.texture_screen = R_LoadTexture2D(r_main_texturepool, "screen", r_bloomstate.screentexturewidth, r_bloomstate.screentextureheight, NULL, textype, TEXF_RENDERTARGET | TEXF_FORCELINEAR | TEXF_CLAMP, -1, NULL);
- if (r_viewfbo.integer >= 1 && vid.support.ext_framebuffer_object)
- {
- // FIXME: choose depth bits based on a cvar
- r_bloomstate.texture_framebufferdepth = R_LoadTextureShadowMap2D(r_main_texturepool, "framebufferdepth", r_bloomstate.screentexturewidth, r_bloomstate.screentextureheight, 24, false);
- r_bloomstate.texture_framebuffercolor = R_LoadTexture2D(r_main_texturepool, "framebuffercolor", r_bloomstate.screentexturewidth, r_bloomstate.screentextureheight, NULL, textype, TEXF_RENDERTARGET | TEXF_FORCELINEAR | TEXF_CLAMP, -1, NULL);
- r_bloomstate.fbo_framebuffer = R_Mesh_CreateFramebufferObject(r_bloomstate.texture_framebufferdepth, r_bloomstate.texture_framebuffercolor, NULL, NULL, NULL);
- R_Mesh_SetRenderTargets(r_bloomstate.fbo_framebuffer, r_bloomstate.texture_framebufferdepth, r_bloomstate.texture_framebuffercolor, NULL, NULL, NULL);
-#ifndef USE_GLES2
- // render depth into one texture and normalmap into the other
- if (qglDrawBuffer)
+ if (r_fb.fbo)
+ R_Mesh_DestroyFramebufferObject(r_fb.fbo);
+ r_fb.fbo = 0;
+
+ if (r_fb.colortexture)
+ R_FreeTexture(r_fb.colortexture);
+ r_fb.colortexture = NULL;
+
+ if (r_fb.depthtexture)
+ R_FreeTexture(r_fb.depthtexture);
+ r_fb.depthtexture = NULL;
+
+ if (r_fb.ghosttexture)
+ R_FreeTexture(r_fb.ghosttexture);
+ r_fb.ghosttexture = NULL;
+
+ r_fb.screentexturewidth = screentexturewidth;
+ r_fb.screentextureheight = screentextureheight;
+ r_fb.bloomtexturewidth = bloomtexturewidth;
+ r_fb.bloomtextureheight = bloomtextureheight;
+ r_fb.textype = textype;
+
+ if (r_fb.screentexturewidth && r_fb.screentextureheight)
+ {
+ if (r_motionblur.value > 0 || r_damageblur.value > 0)
+ r_fb.ghosttexture = R_LoadTexture2D(r_main_texturepool, "framebuffermotionblur", r_fb.screentexturewidth, r_fb.screentextureheight, NULL, r_fb.textype, TEXF_RENDERTARGET | TEXF_FORCELINEAR | TEXF_CLAMP, -1, NULL);
+ r_fb.ghosttexture_valid = false;
+ r_fb.colortexture = R_LoadTexture2D(r_main_texturepool, "framebuffercolor", r_fb.screentexturewidth, r_fb.screentextureheight, NULL, r_fb.textype, TEXF_RENDERTARGET | TEXF_FORCELINEAR | TEXF_CLAMP, -1, NULL);
+ if (useviewfbo)