#include "graphics/gropengl.h" #include "graphics/gropenglextension.h" #include "graphics/gropenglpostprocessing.h" #include "graphics/gropenglshader.h" #include "graphics/gropenglstate.h" #include "graphics/gropengldraw.h" #include "io/timer.h" #include "nebula/neb.h" #include "parse/parselo.h" #include "cmdline/cmdline.h" #include "mod_table/mod_table.h" #include "globalincs/def_files.h" #include "ship/ship.h" #include "freespace2/freespace.h" #include "lighting/lighting.h" extern bool PostProcessing_override; extern int opengl_check_framebuffer(); //Needed to track where the FXAA shaders are size_t fxaa_shader_id; //In case we don't find the shaders at all, this override is needed bool fxaa_unavailable = false; int Fxaa_preset_last_frame; bool zbuffer_saved = false; // lightshaft parameters bool ls_on = false; bool ls_force_off = false; float ls_density = 0.5f; float ls_weight = 0.02f; float ls_falloff = 1.0f; float ls_intensity = 0.5f; float ls_cpintensity = 0.5f * 50 * 0.02f; int ls_samplenum = 50; typedef struct post_effect_t { SCP_string name; SCP_string uniform_name; SCP_string define_name; float intensity; float default_intensity; float div; float add; bool always_on; post_effect_t() : intensity(0.0f), default_intensity(0.0f), div(1.0f), add(0.0f), always_on(false) { } } post_effect_t; SCP_vector Post_effects; static int Post_initialized = 0; bool Post_in_frame = false; static int Post_active_shader_index = -1; static GLuint Post_framebuffer_id[2] = { 0 }; static GLuint Post_bloom_texture_id[3] = { 0 }; static GLuint Post_shadow_framebuffer_id = 0; static GLuint Post_shadow_texture_id = 0; static GLuint Post_shadow_depth_texture_id = 0; static int Post_texture_width = 0; static int Post_texture_height = 0; static bool opengl_post_pass_bloom() { if (Cmdline_bloom_intensity <= 0) { return false; } // we need the scissor test disabled GLboolean scissor_test = GL_state.ScissorTest(GL_FALSE); // ------ begin bright pass ------ vglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, Post_framebuffer_id[0]); // width and height are 1/2 for the bright pass int width = Post_texture_width >> 1; int height = Post_texture_height >> 1; glViewport(0, 0, width, height); glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); opengl_shader_set_current( gr_opengl_maybe_create_shader(SDR_TYPE_POST_PROCESS_BRIGHTPASS, 0) ); GL_state.Uniform.setUniformi( "tex", 0 ); GL_state.Texture.SetActiveUnit(0); GL_state.Texture.SetTarget(GL_TEXTURE_2D); GL_state.Texture.Enable(Scene_color_texture); opengl_draw_textured_quad(-1.0f, -1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f); GL_state.Texture.Disable(); // ------ end bright pass ------ // ------ begin blur pass ------ GL_state.Texture.SetActiveUnit(0); GL_state.Texture.SetTarget(GL_TEXTURE_2D); // drop width and height once more for the blur passes width >>= 1; height >>= 1; glViewport(0, 0, width, height); vglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, Post_framebuffer_id[1]); for (int pass = 0; pass < 2; pass++) { vglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, Post_bloom_texture_id[1+pass], 0); glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); if ( pass ) { opengl_shader_set_current( gr_opengl_maybe_create_shader(SDR_TYPE_POST_PROCESS_BLUR, SDR_FLAG_BLUR_VERTICAL) ); } else { opengl_shader_set_current( gr_opengl_maybe_create_shader(SDR_TYPE_POST_PROCESS_BLUR, SDR_FLAG_BLUR_HORIZONTAL) ); } GL_state.Uniform.setUniformi( "tex", 0 ); GL_state.Uniform.setUniformf( "bsize", (pass) ? (float)width : (float)height ); GL_state.Texture.Enable(Post_bloom_texture_id[pass]); opengl_draw_textured_quad(-1.0f, -1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f); } GL_state.Texture.Disable(); // ------ end blur pass -------- // reset viewport, scissor test and exit glViewport(0, 0, gr_screen.max_w, gr_screen.max_h); GL_state.ScissorTest(scissor_test); vglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, opengl_get_rtt_framebuffer()); return true; } void gr_opengl_post_process_begin() { if ( !Post_initialized ) { return; } if (Post_in_frame) { return; } if (PostProcessing_override) { return; } vglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, Post_framebuffer_id[0]); // vglFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, Post_renderbuffer_id); // vglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, Post_screen_texture_id, 0); // Assert( !opengl_check_framebuffer() ); glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT); glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); Post_in_frame = true; } void recompile_fxaa_shader() { mprintf(("Recompiling FXAA shader with preset %d\n", Cmdline_fxaa_preset)); // start recompile by grabbing deleting the current shader we have, assuming it's already created opengl_delete_shader( gr_opengl_maybe_create_shader(SDR_TYPE_POST_PROCESS_FXAA, 0) ); // then recreate it again. shader loading code will be updated with the new FXAA presets gr_opengl_maybe_create_shader(SDR_TYPE_POST_PROCESS_FXAA, 0); Fxaa_preset_last_frame = Cmdline_fxaa_preset; } void opengl_post_pass_fxaa() { //If the preset changed, recompile the shader if (Fxaa_preset_last_frame != Cmdline_fxaa_preset) { recompile_fxaa_shader(); } // We only want to draw to ATTACHMENT0 glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT); // Do a prepass to convert the main shaders' RGBA output into RGBL opengl_shader_set_current( gr_opengl_maybe_create_shader(SDR_TYPE_POST_PROCESS_FXAA_PREPASS, 0) ); // basic/default uniforms GL_state.Uniform.setUniformi( "tex", 0 ); vglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, Scene_luminance_texture, 0); GL_state.Texture.SetActiveUnit(0); GL_state.Texture.SetTarget(GL_TEXTURE_2D); GL_state.Texture.Enable(Scene_color_texture); opengl_draw_textured_quad(-1.0f, -1.0f, 0.0f, 0.0f, 1.0f, 1.0f, Scene_texture_u_scale, Scene_texture_u_scale); GL_state.Texture.Disable(); // set and configure post shader .. opengl_shader_set_current( gr_opengl_maybe_create_shader(SDR_TYPE_POST_PROCESS_FXAA, 0) ); vglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, Scene_color_texture, 0); // basic/default uniforms GL_state.Uniform.setUniformi( "tex0", 0 ); GL_state.Uniform.setUniformf( "rt_w", static_cast(Post_texture_width)); GL_state.Uniform.setUniformf( "rt_h", static_cast(Post_texture_height)); GL_state.Texture.SetActiveUnit(0); GL_state.Texture.SetTarget(GL_TEXTURE_2D); GL_state.Texture.Enable(Scene_luminance_texture); opengl_draw_textured_quad(-1.0f, -1.0f, 0.0f, 0.0f, 1.0f, 1.0f, Scene_texture_u_scale, Scene_texture_u_scale); GL_state.Texture.Disable(); opengl_shader_set_current(); } extern GLuint Shadow_map_depth_texture; extern GLuint Scene_depth_texture; extern GLuint Cockpit_depth_texture; extern GLuint Scene_position_texture; extern GLuint Scene_normal_texture; extern GLuint Scene_specular_texture; extern bool stars_sun_has_glare(int index); extern float Sun_spot; void gr_opengl_post_process_end() { // state switch just the once (for bloom pass and final render-to-screen) GLboolean depth = GL_state.DepthTest(GL_FALSE); GLboolean depth_mask = GL_state.DepthMask(GL_FALSE); GLboolean light = GL_state.Lighting(GL_FALSE); GLboolean blend = GL_state.Blend(GL_FALSE); GLboolean cull = GL_state.CullFace(GL_FALSE); GL_state.Texture.SetShaderMode(GL_TRUE); // Do FXAA if (Cmdline_fxaa && !fxaa_unavailable && !GL_rendering_to_texture) { opengl_post_pass_fxaa(); } opengl_shader_set_current( gr_opengl_maybe_create_shader(SDR_TYPE_POST_PROCESS_LIGHTSHAFTS, 0) ); float x,y; // should we even be here? if (!Game_subspace_effect && ls_on && !ls_force_off) { int n_lights = light_get_global_count(); for(int idx=0; idx 0.7f) { x = asin(vm_vec_dot( &light_dir, &Eye_matrix.vec.rvec ))/PI*1.5f+0.5f; //cant get the coordinates right but this works for the limited glare fov y = asin(vm_vec_dot( &light_dir, &Eye_matrix.vec.uvec ))/PI*1.5f*gr_screen.clip_aspect+0.5f; GL_state.Uniform.setUniform2f( "sun_pos", x, y); GL_state.Uniform.setUniformi( "scene", 0); GL_state.Uniform.setUniformi( "cockpit", 1); GL_state.Uniform.setUniformf( "density", ls_density); GL_state.Uniform.setUniformf( "falloff", ls_falloff); GL_state.Uniform.setUniformf( "weight", ls_weight); GL_state.Uniform.setUniformf( "intensity", Sun_spot * ls_intensity); GL_state.Uniform.setUniformf( "cp_intensity", Sun_spot * ls_cpintensity); GL_state.Texture.SetActiveUnit(0); GL_state.Texture.SetTarget(GL_TEXTURE_2D); GL_state.Texture.Enable(Scene_depth_texture); GL_state.Texture.SetActiveUnit(1); GL_state.Texture.SetTarget(GL_TEXTURE_2D); GL_state.Texture.Enable(Cockpit_depth_texture); GL_state.Color(255, 255, 255, 255); GL_state.Blend(GL_TRUE); GL_state.SetAlphaBlendMode(ALPHA_BLEND_ADDITIVE); opengl_draw_textured_quad(-1.0f, -1.0f, 0.0f, 0.0f, 1.0f, 1.0f, Scene_texture_u_scale, Scene_texture_u_scale); GL_state.Blend(GL_FALSE); break; } } } if(zbuffer_saved) { zbuffer_saved = false; gr_zbuffer_set(GR_ZBUFF_FULL); glClear(GL_DEPTH_BUFFER_BIT); gr_zbuffer_set(GR_ZBUFF_NONE); vglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, Scene_depth_texture, 0); } // Bind the correct framebuffer. opengl_get_rtt_framebuffer returns 0 if not doing RTT vglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, opengl_get_rtt_framebuffer()); // do bloom, hopefully ;) bool bloomed = opengl_post_pass_bloom(); glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); GL_state.Color(255, 255, 255, 255); // set and configure post shader ... int flags = 0; for ( int i = 0; i < (int)Post_effects.size(); i++) { if (Post_effects[i].always_on) { flags |= (1 << i); } } int post_sdr_handle = Post_active_shader_index; if ( post_sdr_handle < 0 ) { // no active shader index? use the always on shader. post_sdr_handle = gr_opengl_maybe_create_shader(SDR_TYPE_POST_PROCESS_MAIN, flags); } opengl_shader_set_current(post_sdr_handle); // basic/default uniforms GL_state.Uniform.setUniformi( "tex", 0 ); GL_state.Uniform.setUniformi( "depth_tex", 2); GL_state.Uniform.setUniformf( "timer", static_cast(timer_get_milliseconds() % 100 + 1) ); for (size_t idx = 0; idx < Post_effects.size(); idx++) { if ( GL_shader[post_sdr_handle].flags & (1< &names) { size_t idx; for (idx = 0; idx < Post_effects.size(); idx++) { names.push_back(Post_effects[idx].name); } } void opengl_post_init_uniforms(int flags) { for (int idx = 0; idx < (int)Post_effects.size(); idx++) { if (flags & (1 << idx)) { opengl_shader_init_uniform(Post_effects[idx].uniform_name.c_str()); } } } void gr_opengl_post_process_set_effect(const char *name, int value) { if ( !Post_initialized ) { return; } if (name == NULL) { return; } size_t idx; int sflags = 0; if(!stricmp("lightshafts",name)) { ls_intensity = value / 100.0f; ls_on = !!value; return; } for (idx = 0; idx < Post_effects.size(); idx++) { const char *eff_name = Post_effects[idx].name.c_str(); if ( !stricmp(eff_name, name) ) { Post_effects[idx].intensity = (value / Post_effects[idx].div) + Post_effects[idx].add; break; } } // figure out new flags for (idx = 0; idx < Post_effects.size(); idx++) { if ( Post_effects[idx].always_on || (Post_effects[idx].intensity != Post_effects[idx].default_intensity) ) { sflags |= (1< GL_max_renderbuffer_size) { Post_texture_width = GL_max_renderbuffer_size; } if (Post_texture_height > GL_max_renderbuffer_size) { Post_texture_height = GL_max_renderbuffer_size; } if (Cmdline_bloom_intensity > 0) { // two more framebuffers, one each for the two different sized bloom textures vglGenFramebuffersEXT(1, &Post_framebuffer_id[0]); vglGenFramebuffersEXT(1, &Post_framebuffer_id[1]); // need to generate textures for bloom too glGenTextures(3, Post_bloom_texture_id); // half size int width = Post_texture_width >> 1; int height = Post_texture_height >> 1; for (int tex = 0; tex < 3; tex++) { GL_state.Texture.SetActiveUnit(0); GL_state.Texture.SetTarget(GL_TEXTURE_2D); GL_state.Texture.Enable(Post_bloom_texture_id[tex]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL); if (tex == 0) { // attach to our bright pass framebuffer and make sure it's ok vglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, Post_framebuffer_id[0]); vglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, Post_bloom_texture_id[tex], 0); // if not then clean up and disable bloom if ( opengl_check_framebuffer() ) { vglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); vglDeleteFramebuffersEXT(1, &Post_framebuffer_id[0]); vglDeleteFramebuffersEXT(1, &Post_framebuffer_id[1]); Post_framebuffer_id[0] = 0; Post_framebuffer_id[1] = 0; glDeleteTextures(3, Post_bloom_texture_id); memset(Post_bloom_texture_id, 0, sizeof(Post_bloom_texture_id)); Cmdline_bloom_intensity = 0; break; } // width and height are 1/2 for the bright pass, 1/4 for the blur, so drop down width >>= 1; height >>= 1; } else { // attach to our blur pass framebuffer and make sure it's ok vglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, Post_framebuffer_id[1]); vglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, Post_bloom_texture_id[tex], 0); // if not then clean up and disable bloom if ( opengl_check_framebuffer() ) { vglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); vglDeleteFramebuffersEXT(1, &Post_framebuffer_id[0]); vglDeleteFramebuffersEXT(1, &Post_framebuffer_id[1]); Post_framebuffer_id[0] = 0; Post_framebuffer_id[1] = 0; glDeleteTextures(3, Post_bloom_texture_id); memset(Post_bloom_texture_id, 0, sizeof(Post_bloom_texture_id)); Cmdline_bloom_intensity = 0; break; } } } } if ( Cmdline_shadow_quality ) { int size = (Cmdline_shadow_quality == 2 ? 1024 : 512); vglGenFramebuffersEXT(1, &Post_shadow_framebuffer_id); vglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, Post_shadow_framebuffer_id); glGenTextures(1, &Post_shadow_texture_id); GL_state.Texture.SetActiveUnit(0); GL_state.Texture.SetTarget(GL_TEXTURE_2D_ARRAY_EXT); // GL_state.Texture.SetTarget(GL_TEXTURE_2D); GL_state.Texture.Enable(Post_shadow_texture_id); glTexParameteri(GL_TEXTURE_2D_ARRAY_EXT, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D_ARRAY_EXT, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D_ARRAY_EXT, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D_ARRAY_EXT, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D_ARRAY_EXT, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); vglTexImage3D(GL_TEXTURE_2D_ARRAY_EXT, 0, GL_RGBA32F_ARB, size, size, 4, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL); // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); // glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F_ARB, size, size, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL); // vglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, Post_shadow_texture_id, 0); vglFramebufferTextureEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, Post_shadow_texture_id, 0); glGenTextures(1, &Post_shadow_depth_texture_id); GL_state.Texture.SetActiveUnit(0); GL_state.Texture.SetTarget(GL_TEXTURE_2D_ARRAY_EXT); // GL_state.Texture.SetTarget(GL_TEXTURE_2D); GL_state.Texture.Enable(Post_shadow_depth_texture_id); glTexParameteri(GL_TEXTURE_2D_ARRAY_EXT, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D_ARRAY_EXT, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D_ARRAY_EXT, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D_ARRAY_EXT, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D_ARRAY_EXT, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); vglTexImage3D(GL_TEXTURE_2D_ARRAY_EXT, 0, GL_DEPTH_COMPONENT32, size, size, 4, 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL); // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); // glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32, size, size, 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL); // vglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, Post_shadow_depth_texture_id, 0); vglFramebufferTextureEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, Post_shadow_depth_texture_id, 0); } vglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); GL_state.Texture.Disable(); rval = true; if ( opengl_check_for_errors("post_init_framebuffer()") ) { rval = false; } return rval; } void opengl_post_process_init() { Post_initialized = 0; //We need to read the tbl first. This is mostly for FRED's benefit, as otherwise the list of post effects for the sexp doesn't get updated. if ( !opengl_post_init_table() ) { mprintf((" Unable to read post-processing table! Disabling post-processing...\n\n")); Cmdline_postprocess = 0; return; } if ( !Cmdline_postprocess ) { return; } if ( !Scene_texture_initialized ) { return; } if ( !Use_GLSL || Cmdline_no_fbo || !Is_Extension_Enabled(OGL_EXT_FRAMEBUFFER_OBJECT) ) { Cmdline_postprocess = 0; return; } // for ease of use we require support for non-power-of-2 textures in one // form or another: // - the NPOT extension // - GL version 2.0+ (which should work for non-reporting ATI cards since we don't use mipmaps) if ( !(Is_Extension_Enabled(OGL_ARB_TEXTURE_NON_POWER_OF_TWO) || (GL_version >= 20)) ) { Cmdline_postprocess = 0; return; } if ( !opengl_post_init_shaders() ) { mprintf((" Unable to initialize post-processing shaders! Disabling post-processing...\n\n")); Cmdline_postprocess = 0; return; } if ( !opengl_post_init_framebuffer() ) { mprintf((" Unable to initialize post-processing framebuffer! Disabling post-processing...\n\n")); Cmdline_postprocess = 0; return; } Post_initialized = 1; } void opengl_post_process_shutdown() { if ( !Post_initialized ) { return; } if (Post_bloom_texture_id[0]) { glDeleteTextures(3, Post_bloom_texture_id); memset(Post_bloom_texture_id, 0, sizeof(Post_bloom_texture_id)); } if (Post_framebuffer_id[0]) { vglDeleteFramebuffersEXT(1, &Post_framebuffer_id[0]); Post_framebuffer_id[0] = 0; if (Post_framebuffer_id[1]) { vglDeleteFramebuffersEXT(1, &Post_framebuffer_id[1]); Post_framebuffer_id[1] = 0; } } Post_effects.clear(); Post_in_frame = false; Post_active_shader_index = 0; Post_initialized = 0; }