void R_Bloom_InitTextures( void ) { unsigned char *data; int maxtexsize; size_t size; // Find closer power of 2 to screen size. for (screen_texture_width = 1; screen_texture_width < glwidth; screen_texture_width *= 2); for (screen_texture_height = 1; screen_texture_height < glheight; screen_texture_height *= 2); // Disable blooms if we can't handle a texture of that size. glGetIntegerv (GL_MAX_TEXTURE_SIZE, &maxtexsize); if (screen_texture_width > maxtexsize || screen_texture_height > maxtexsize) { screen_texture_width = screen_texture_height = 0; Cvar_SetValue (&r_bloom, 0); Com_Printf ("WARNING: 'R_InitBloomScreenTexture' too high resolution for Light Bloom. Effect disabled\n"); return; } // Init the screen texture. size = screen_texture_width * screen_texture_height * sizeof (int); data = Q_malloc (size); memset (data, 255, size); //r_bloomscreentexture = GL_LoadTexture ( "***r_screenbackuptexture***", screen_texture_width, screen_texture_height, data, 0, 4); // false, false, 4); if (!r_bloomscreentexture) r_bloomscreentexture = texture_extension_number++; GL_Bind (r_bloomscreentexture); glTexImage2D (GL_TEXTURE_2D, 0, gl_solid_format, screen_texture_width, screen_texture_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data); glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); Q_free (data); // Validate bloom size and init the bloom effect texture. R_Bloom_InitEffectTexture(); // If screensize is more than 2x the bloom effect texture, set up for stepped downsampling. r_bloomdownsamplingtexture = 0; r_screendownsamplingtexture_size = 0; if( glwidth > (BLOOM_SIZE * 2) && !r_bloom_fast_sample.value ) { r_screendownsamplingtexture_size = (int)(BLOOM_SIZE * 2); data = Q_calloc (r_screendownsamplingtexture_size * r_screendownsamplingtexture_size, sizeof (int)); r_bloomdownsamplingtexture = GL_LoadTexture ( "***r_bloomdownsamplingtexture***", r_screendownsamplingtexture_size, r_screendownsamplingtexture_size, data, 0, 4); Q_free (data); } // Init the screen backup texture. if (r_screendownsamplingtexture_size) R_Bloom_InitBackUpTexture (r_screendownsamplingtexture_size, r_screendownsamplingtexture_size); else R_Bloom_InitBackUpTexture (BLOOM_SIZE, BLOOM_SIZE); }
/* * R_Bloom_InitTextures */ static void R_Bloom_InitTextures( void ) { qbyte *data; int size; if( glConfig.ext.texture_non_power_of_two ) { screen_texture_width = glState.width; screen_texture_height = glState.height; } else { // find closer power of 2 to screen size for (screen_texture_width = 1;screen_texture_width < glState.width;screen_texture_width <<= 1); for (screen_texture_height = 1;screen_texture_height < glState.height;screen_texture_height <<= 1); } // disable blooms if we can't handle a texture of that size if( screen_texture_width > glConfig.maxTextureSize || screen_texture_height > glConfig.maxTextureSize ) { screen_texture_width = screen_texture_height = 0; Cvar_ForceSet( "r_bloom", "0" ); Com_Printf( S_COLOR_YELLOW "WARNING: 'R_InitBloomScreenTexture' too high resolution for light bloom, effect disabled\n" ); return; } // init the screen texture size = screen_texture_width * screen_texture_height * 4; data = Mem_TempMalloc( size ); memset( data, 255, size ); r_bloomscreentexture = R_LoadPic( "***r_bloomscreentexture***", &data, screen_texture_width, screen_texture_height, IT_CLAMP|IT_NOMIPMAP|IT_NOCOMPRESS|IT_NOPICMIP, 3 ); Mem_TempFree( data ); // validate bloom size and init the bloom effect texture R_Bloom_InitEffectTexture(); // if screensize is more than 2x the bloom effect texture, set up for stepped downsampling r_bloomdownsamplingtexture = NULL; r_screendownsamplingtexture_size = 0; if( (glState.width > (BLOOM_SIZE * 2) || glState.height > (BLOOM_SIZE * 2)) && !r_bloom_fast_sample->integer ) { r_screendownsamplingtexture_size = (int)( BLOOM_SIZE * 2 ); data = Mem_TempMalloc( r_screendownsamplingtexture_size * r_screendownsamplingtexture_size * 4 ); memset( data, 0, r_screendownsamplingtexture_size * r_screendownsamplingtexture_size * 4 ); r_bloomdownsamplingtexture = R_LoadPic( "***r_bloomdownsamplingtexture***", &data, r_screendownsamplingtexture_size, r_screendownsamplingtexture_size, IT_CLAMP|IT_NOMIPMAP|IT_NOCOMPRESS|IT_NOPICMIP, 3 ); Mem_TempFree( data ); } // init the screen backup texture if( r_screendownsamplingtexture_size ) R_Bloom_InitBackUpTexture( r_screendownsamplingtexture_size, r_screendownsamplingtexture_size ); else R_Bloom_InitBackUpTexture( BLOOM_SIZE, BLOOM_SIZE ); }
/* * ================= * R_Bloom_InitTextures * ================= */ void R_Bloom_InitTextures(void) { byte *data; int size; //find closer power of 2 to screen size for (screen_texture_width = 1; screen_texture_width < vid.width; screen_texture_width *= 2) { } for (screen_texture_height = 1; screen_texture_height < vid.height; screen_texture_height *= 2) { } //disable blooms if we can't handle a texture of that size /* if( screen_texture_width > glConfig.maxTextureSize || * screen_texture_height > glConfig.maxTextureSize ) { * screen_texture_width = screen_texture_height = 0; * Cvar_SetValue ("r_bloom", 0); * Com_Printf( "WARNING: 'R_InitBloomScreenTexture' too high resolution for Light Bloom. Effect disabled\n" ); * return; * }*/ //init the screen texture size = screen_texture_width * screen_texture_height * 4; data = malloc(size); memset(data, 255, size); r_bloomscreentexture = R_LoadPic("***r_bloomscreentexture***", (byte *)data, screen_texture_width, screen_texture_height, it_pic, 3); free(data); //validate bloom size and init the bloom effect texture R_Bloom_InitEffectTexture(); //if screensize is more than 2x the bloom effect texture, set up for stepped downsampling r_bloomdownsamplingtexture = NULL; r_screendownsamplingtexture_size = 0; if ((vid.width > (BLOOM_SIZE * 2)) && !r_bloom_fast_sample->value) { r_screendownsamplingtexture_size = (int)(BLOOM_SIZE * 2); data = malloc(r_screendownsamplingtexture_size * r_screendownsamplingtexture_size * 4); memset(data, 0, r_screendownsamplingtexture_size * r_screendownsamplingtexture_size * 4); r_bloomdownsamplingtexture = R_LoadPic("***r_bloomdownsamplingtexture***", (byte *)data, r_screendownsamplingtexture_size, r_screendownsamplingtexture_size, it_pic, 3); free(data); } //Init the screen backup texture if (r_screendownsamplingtexture_size) { R_Bloom_InitBackUpTexture(r_screendownsamplingtexture_size, r_screendownsamplingtexture_size); } else { R_Bloom_InitBackUpTexture(BLOOM_SIZE, BLOOM_SIZE); } }
/* ================= R_Bloom_InitTextures ================= */ static void R_Bloom_InitTextures( void ) { if( GL_Support( R_ARB_TEXTURE_NPOT_EXT )) { screen_texture_width = glState.width; screen_texture_height = glState.height; } else { // find closer power of 2 to screen size for( screen_texture_width = 1; screen_texture_width < glState.width; screen_texture_width <<= 1 ); for( screen_texture_height = 1; screen_texture_height < glState.height; screen_texture_height <<= 1 ); } // disable blooms if we can't handle a texture of that size if( screen_texture_width > glConfig.max_2d_texture_size || screen_texture_height > glConfig.max_2d_texture_size ) { screen_texture_width = screen_texture_height = 0; CVAR_SET_FLOAT( "r_bloom", 0.0f ); ALERT( at_warning, "'R_InitBloomScreenTexture' too high resolution for light bloom, effect disabled\n" ); return; } r_bloomscreentexture = CREATE_TEXTURE( "*bloomscreentexture", screen_texture_width, screen_texture_height, NULL, TF_IMAGE ); // validate bloom size and init the bloom effect texture R_Bloom_InitEffectTexture(); // if screensize is more than 2x the bloom effect texture, set up for stepped downsampling r_bloomdownsamplingtexture = 0; r_screendownsamplingtexture_size = 0; if(( glState.width > (BLOOM_SIZE * 2) || glState.height > (BLOOM_SIZE * 2)) && !r_bloom_fast_sample->value ) { r_screendownsamplingtexture_size = (int)( BLOOM_SIZE * 2 ); r_bloomdownsamplingtexture = CREATE_TEXTURE( "*bloomdownsampletexture", r_screendownsamplingtexture_size, r_screendownsamplingtexture_size, NULL, TF_IMAGE ); } // init the screen backup texture if( r_screendownsamplingtexture_size ) R_Bloom_InitBackUpTexture( r_screendownsamplingtexture_size, r_screendownsamplingtexture_size ); else R_Bloom_InitBackUpTexture( BLOOM_SIZE, BLOOM_SIZE ); }