Hard an brutal reformatting to make it easier to see my changes

This commit is contained in:
sago007
2016-11-27 11:33:18 +01:00
parent 217a26e3c6
commit f5c2b2d71b
3 changed files with 1920 additions and 1505 deletions

View File

@@ -46,13 +46,15 @@ void sound_deinit(void);
extern int samplingrate; // from snd_dma
void S_XMP_StartSong ( void ){
void S_XMP_StartSong ( void )
{
}
void S_XMP_EndSong ( void ){
void S_XMP_EndSong ( void )
{
@@ -84,8 +86,9 @@ snd_stream_t *S_XMP_CodecOpenStream(const char *filename)
// Open
snd_stream_t *rv = S_CodecUtilOpen(filename, &xmp_codec);
if(!rv)
if(!rv) {
return NULL;
}
// Com_Printf("OPENSTREAM %s\n", filename);
@@ -94,8 +97,7 @@ snd_stream_t *S_XMP_CodecOpenStream(const char *filename)
// Try to open the file
FS_FOpenFileRead(filename, &file, qtrue);
if(!file)
{
if(!file) {
Com_Printf( S_COLOR_RED "ERROR: No.\"%s\"\n",filename);
return NULL;
}
@@ -106,8 +108,7 @@ snd_stream_t *S_XMP_CodecOpenStream(const char *filename)
void *buffer = Hunk_AllocateTempMemory(thelength);
if(!buffer)
{
if(!buffer) {
FS_FCloseFile(file);
Com_Printf( S_COLOR_RED "ERROR: Out of memory reading \"%s\"\n", filename);
return NULL;
@@ -131,7 +132,7 @@ snd_stream_t *S_XMP_CodecOpenStream(const char *filename)
if (itsloaded == 0)
itsloaded = xmp_start_player(xmpsong, xmpspeed, 0); // TODO: do sample rate of the mixer.
if (itsloaded == 0){
if (itsloaded == 0) {
// Com_Printf("XMP loaded our buffer of the file %s which is %i long \n", filename, thelength);
xmp_get_module_info(xmpsong, &mi);
// Com_Printf("Song Name: %s\n", mi.mod->name);
@@ -178,13 +179,11 @@ int S_XMP_CodecReadStream(snd_stream_t *stream, int bytes, void *buffer)
struct xmp_frame_info fi;
// check if input is valid
if(!(stream && buffer))
{
if(!(stream && buffer)) {
return 0;
}
if(bytes <= 0)
{
if(bytes <= 0) {
return 0;
}
@@ -193,18 +192,16 @@ int S_XMP_CodecReadStream(snd_stream_t *stream, int bytes, void *buffer)
char* bufPtr = buffer;
// cycle until we have the requested or all available bytes read
while(-1)
{
while(-1) {
int yeah=xmp_play_buffer(xmpsong, buffer, bytesLeft, 0);
if (yeah == 0){ // if we can play it...
if (yeah == 0) { // if we can play it...
xmp_get_frame_info(xmpsong, &fi);
int c = fi.buffer_size;
// no more bytes are left
if(c <= 0)
{
if(c <= 0) {
break;
}
@@ -214,15 +211,12 @@ int S_XMP_CodecReadStream(snd_stream_t *stream, int bytes, void *buffer)
xmp_get_module_info(xmpsong, &mi);
// we have enough bytes
if(bytesLeft <= 0)
{
if(bytesLeft <= 0) {
break;
}
}
else // if we can't play it JUST STOP OK
{
else { // if we can't play it JUST STOP OK
break;
}
}
@@ -230,8 +224,7 @@ int S_XMP_CodecReadStream(snd_stream_t *stream, int bytes, void *buffer)
}
snd_codec_t xmp_codec =
{
snd_codec_t xmp_codec = {
"umx",
S_XMP_CodecLoad,
S_XMP_CodecOpenStream,
@@ -240,8 +233,7 @@ snd_codec_t xmp_codec =
NULL
};
snd_codec_t xmp_mod_codec =
{
snd_codec_t xmp_mod_codec = {
"mod",
S_XMP_CodecLoad,
S_XMP_CodecOpenStream,
@@ -250,8 +242,7 @@ snd_codec_t xmp_mod_codec =
NULL
};
snd_codec_t xmp_it_codec =
{
snd_codec_t xmp_it_codec = {
"it",
S_XMP_CodecLoad,
S_XMP_CodecOpenStream,
@@ -260,8 +251,7 @@ snd_codec_t xmp_it_codec =
NULL
};
snd_codec_t xmp_s3m_codec =
{
snd_codec_t xmp_s3m_codec = {
"s3m",
S_XMP_CodecLoad,
S_XMP_CodecOpenStream,
@@ -270,8 +260,7 @@ snd_codec_t xmp_s3m_codec =
NULL
};
snd_codec_t xmp_xm_codec =
{
snd_codec_t xmp_xm_codec = {
"xm",
S_XMP_CodecLoad,
S_XMP_CodecOpenStream,

View File

@@ -156,8 +156,7 @@ extern int vresHeight;
==============================================================================
*/
static float Diamond8x[8][8] =
{
static float Diamond8x[8][8] = {
{ 0.0f, 0.0f, 0.0f, 0.1f, 0.1f, 0.0f, 0.0f, 0.0f, },
{ 0.0f, 0.0f, 0.2f, 0.3f, 0.3f, 0.2f, 0.0f, 0.0f, },
{ 0.0f, 0.2f, 0.4f, 0.6f, 0.6f, 0.4f, 0.2f, 0.0f, },
@@ -169,8 +168,7 @@ static float Diamond8x[8][8] =
};
static float Star8x[8][8] =
{
static float Star8x[8][8] = {
{ 0.4f, 0.1f, 0.0f, 0.0f, 0.0f, 0.0f, 0.1f, 0.4f, },
{ 0.1f, 0.6f, 0.2f, 0.0f, 0.0f, 0.2f, 0.6f, 0.1f, },
{ 0.0f, 0.2f, 0.7f, 0.6f, 0.6f, 0.7f, 0.2f, 0.0f, },
@@ -182,8 +180,7 @@ static float Star8x[8][8] =
};
static float Diamond6x[6][6] =
{
static float Diamond6x[6][6] = {
{ 0.0f, 0.0f, 0.1f, 0.1f, 0.0f, 0.0f, },
{ 0.0f, 0.3f, 0.5f, 0.5f, 0.3f, 0.0f, },
{ 0.1f, 0.5f, 0.9f, 0.9f, 0.5f, 0.1f, },
@@ -192,8 +189,7 @@ static float Diamond6x[6][6] =
{ 0.0f, 0.0f, 0.1f, 0.1f, 0.0f, 0.0f }
};
static float Diamond4x[4][4] =
{
static float Diamond4x[4][4] = {
{ 0.3f, 0.4f, 0.4f, 0.3f, },
{ 0.4f, 0.9f, 0.9f, 0.4f, },
{ 0.4f, 0.9f, 0.9f, 0.4f, },
@@ -224,7 +220,8 @@ static struct {
static void ID_INLINE R_Bloom_Quad( int width, int height, float texX, float texY, float texWidth, float texHeight ) {
static void ID_INLINE R_Bloom_Quad( int width, int height, float texX, float texY, float texWidth, float texHeight )
{
int x = 0;
int y = 0;
x = 0;
@@ -254,7 +251,8 @@ static void ID_INLINE R_Bloom_Quad( int width, int height, float texX, float tex
// LEILEI - Bloom Reflection
static void ID_INLINE R_Bloom_Quad_Lens(float offsert, int width, int height, float texX, float texY, float texWidth, float texHeight) {
static void ID_INLINE R_Bloom_Quad_Lens(float offsert, int width, int height, float texX, float texY, float texWidth, float texHeight)
{
int x = 0;
int y = 0;
x = 0;
@@ -293,8 +291,8 @@ static void R_Bloom_InitTextures( void )
byte *data;
// find closer power of 2 to screen size
for (bloom.screen.width = 1;bloom.screen.width< glConfig.vidWidth;bloom.screen.width *= 2);
for (bloom.screen.height = 1;bloom.screen.height < glConfig.vidHeight;bloom.screen.height *= 2);
for (bloom.screen.width = 1; bloom.screen.width< glConfig.vidWidth; bloom.screen.width *= 2);
for (bloom.screen.height = 1; bloom.screen.height < glConfig.vidHeight; bloom.screen.height *= 2);
bloom.screen.readW = glConfig.vidWidth / (float)bloom.screen.width;
bloom.screen.readH = glConfig.vidHeight / (float)bloom.screen.height;
@@ -303,8 +301,8 @@ static void R_Bloom_InitTextures( void )
bloom.work.width = r_bloom_sample_size->integer;
bloom.work.height = bloom.work.width * ( glConfig.vidWidth / glConfig.vidHeight );
for (bloom.effect.width = 1;bloom.effect.width < bloom.work.width;bloom.effect.width *= 2);
for (bloom.effect.height = 1;bloom.effect.height < bloom.work.height;bloom.effect.height *= 2);
for (bloom.effect.width = 1; bloom.effect.width < bloom.work.width; bloom.effect.width *= 2);
for (bloom.effect.height = 1; bloom.effect.height < bloom.work.height; bloom.effect.height *= 2);
bloom.effect.readW = bloom.work.width / (float)bloom.effect.width;
bloom.effect.readH = bloom.work.height / (float)bloom.effect.height;
@@ -369,7 +367,7 @@ static void R_Bloom_DrawEffect( void )
float alpha=r_bloom_alpha->value;
GL_Bind( bloom.effect.texture );
GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE );
if(r_bloom_cascade->integer){
if(r_bloom_cascade->integer) {
alpha=r_bloom_cascade_alpha->value;
}
qglColor4f( alpha,alpha,alpha, 1.0f );
@@ -433,7 +431,8 @@ static void R_Bloom_LensEffect( void )
=================
Tcpp: sorry for my poor English skill.
*/
static void R_Bloom_Cascaded( void ){
static void R_Bloom_Cascaded( void )
{
int scale;
int oldWorkW, oldWorkH;
int newWorkW, newWorkH;
@@ -475,7 +474,7 @@ static void R_Bloom_Cascaded( void ){
bloom.effect2.readW, bloom.effect2.readH );
// go through levels.
while(scale>1){
while(scale>1) {
float oldScaleInv=1.f/(float)scale;
scale>>=1;
oldWorkH=newWorkH;
@@ -488,14 +487,15 @@ static void R_Bloom_Cascaded( void ){
qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, oldWorkW, oldWorkH);
// maginfy the previous level.
if(r_bloom_cascade_blur->value<.01f){
if(r_bloom_cascade_blur->value<.01f) {
// don't blur.
qglColor4f( 1.f, 1.f, 1.f, 1.0 );
GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO );
R_Bloom_Quad( newWorkW, newWorkH,
0, 0,
bloom.effect.readW*oldScaleInv, bloom.effect.readH*oldScaleInv );
}else{
}
else {
// blur.
qglColor4f( .25f, .25f, .25f, 1.0 );
GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO );
@@ -575,10 +575,12 @@ static void R_Bloom_WarsowEffect( void )
if( r_bloom_diamond_size->integer > 7 || r_bloom_diamond_size->integer <= 3 ) {
if( r_bloom_diamond_size->integer != 8 )
ri.Cvar_Set( "r_bloom_diamond_size", "8" );
} else if( r_bloom_diamond_size->integer > 5 ) {
}
else if( r_bloom_diamond_size->integer > 5 ) {
if( r_bloom_diamond_size->integer != 6 )
ri.Cvar_Set( "r_bloom_diamond_size", "6" );
} else if( r_bloom_diamond_size->integer > 3 ) {
}
else if( r_bloom_diamond_size->integer > 3 ) {
if( r_bloom_diamond_size->integer != 4 )
ri.Cvar_Set( "r_bloom_diamond_size", "4" );
}
@@ -630,7 +632,8 @@ R_Bloom_BackupScreen
Backup the full original screen to a texture for downscaling and later restoration
=================
*/
static void R_Bloom_BackupScreen( void ) {
static void R_Bloom_BackupScreen( void )
{
GL_Bind( bloom.screen.texture );
qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, glConfig.vidWidth, glConfig.vidHeight );
}
@@ -641,18 +644,20 @@ R_Bloom_RestoreScreen
Restore the temporary framebuffer section we used with the backup texture
=================
*/
static void R_Bloom_RestoreScreen( void ) {
static void R_Bloom_RestoreScreen( void )
{
float dry=r_bloom_dry->value;
if(r_bloom_cascade->integer)
dry=r_bloom_cascade_dry->value;
GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO );
GL_Bind( bloom.screen.texture );
qglColor4f( dry,dry,dry, 1 );
if(dry<.99f){
if(dry<.99f) {
R_Bloom_Quad( bloom.screen.width, bloom.screen.height, 0, 0,
1.f,
1.f );
}else{
}
else {
R_Bloom_Quad( bloom.work.width, bloom.work.height, 0, 0,
bloom.work.width / (float)bloom.screen.width,
bloom.work.height / (float)bloom.screen.height );
@@ -666,7 +671,8 @@ Restore the temporary framebuffer section we used with the backup texture
*/
extern int mpasses;
static void ID_INLINE R_Bloom_QuadTV( int width, int height, float texX, float texY, float texWidth, float texHeight, int aa ) {
static void ID_INLINE R_Bloom_QuadTV( int width, int height, float texX, float texY, float texWidth, float texHeight, int aa )
{
int x = 0;
int y = 0;
float aspcenter = 0;
@@ -684,11 +690,26 @@ static void ID_INLINE R_Bloom_QuadTV( int width, int height, float texX, float t
if (aa == 0){ xaa = 0; yaa = 0; }
if (aa == 1){ xaa = -xpix; yaa = ypix; }
if (aa == 2){ xaa = -xpix; yaa = -ypix; }
if (aa == 3){ xaa = xpix; yaa = -ypix; }
if (aa == 4){ xaa = xpix; yaa = ypix; }
if (aa == 0) {
xaa = 0;
yaa = 0;
}
if (aa == 1) {
xaa = -xpix;
yaa = ypix;
}
if (aa == 2) {
xaa = -xpix;
yaa = -ypix;
}
if (aa == 3) {
xaa = xpix;
yaa = -ypix;
}
if (aa == 4) {
xaa = xpix;
yaa = ypix;
}
@@ -699,20 +720,18 @@ static void ID_INLINE R_Bloom_QuadTV( int width, int height, float texX, float t
texWidth += texX;
texHeight += texY;
if (tvAspectW != 1.0){
if (tvAspectW != 1.0) {
aspcenter = tvWidth * ((1.0f - tvAspectW) / 2);
// leilei - also do a quad that is 100% black, hiding our actual rendered viewport
// qglViewport (0, 0, tvWidth, tvHeight );
// qglScissor (0, 0, tvWidth, tvHeight );
qglBegin( GL_QUADS );
if (r_tvFilter->integer) // bilinear filter
{
if (r_tvFilter->integer) { // bilinear filter
qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
}
else
{
else {
qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
}
@@ -729,7 +748,7 @@ static void ID_INLINE R_Bloom_QuadTV( int width, int height, float texX, float t
//aspcenter = 0;
aspoff = tvWidth * tvAspectW;
if (!aa){
if (!aa) {
qglViewport(aspcenter, 0, (tvWidth * tvAspectW), tvHeight );
qglScissor(aspcenter, 0, (tvWidth * tvAspectW), tvHeight );
}
@@ -749,24 +768,67 @@ static void ID_INLINE R_Bloom_QuadTV( int width, int height, float texX, float t
}
static void R_Bloom_RestoreScreen_Postprocessed( void ) {
static void R_Bloom_RestoreScreen_Postprocessed( void )
{
#ifdef GLSL_POSTPROCESSING
glslProgram_t *program = NULL;
if (leifxmode) {
if (leifxmode == 1){ if (vertexShaders) R_GLSL_UseProgram(tr.leiFXDitherProgram); program=tr.programs[tr.leiFXDitherProgram];}
if (leifxmode == 2){ if (vertexShaders) R_GLSL_UseProgram(tr.leiFXGammaProgram); program=tr.programs[tr.leiFXGammaProgram];}
if (leifxmode == 3){ if (vertexShaders) R_GLSL_UseProgram(tr.leiFXFilterProgram); program=tr.programs[tr.leiFXFilterProgram];}
if (leifxmode == 888){ if (vertexShaders) R_GLSL_UseProgram(tr.animeProgram); program=tr.programs[tr.animeProgram];}
if (leifxmode == 999){ if (vertexShaders) R_GLSL_UseProgram(tr.animeFilmProgram); program=tr.programs[tr.animeFilmProgram];}
if (leifxmode == 777){ if (vertexShaders) R_GLSL_UseProgram(tr.motionBlurProgram); program=tr.programs[tr.motionBlurProgram];}
if (leifxmode == 778){ if (vertexShaders) R_GLSL_UseProgram(tr.motionBlurProgram); program=tr.programs[tr.motionBlurProgram];}
if (leifxmode == 779){ if (vertexShaders) R_GLSL_UseProgram(tr.motionBlurPostProgram); program=tr.programs[tr.motionBlurPostProgram];}
if (leifxmode == 632){ if (vertexShaders) R_GLSL_UseProgram(tr.NTSCEncodeProgram); program=tr.programs[tr.NTSCEncodeProgram];}
if (leifxmode == 633){ if (vertexShaders) R_GLSL_UseProgram(tr.NTSCDecodeProgram); program=tr.programs[tr.NTSCDecodeProgram];}
if (leifxmode == 634){ if (vertexShaders) R_GLSL_UseProgram(tr.NTSCBleedProgram); program=tr.programs[tr.NTSCBleedProgram];}
if (leifxmode == 666){ if (vertexShaders) R_GLSL_UseProgram(tr.BrightnessProgram); program=tr.programs[tr.BrightnessProgram];}
if (leifxmode == 1236){ if (vertexShaders) R_GLSL_UseProgram(tr.CRTProgram); program=tr.programs[tr.CRTProgram];}
if (leifxmode == 1997){ if (vertexShaders) R_GLSL_UseProgram(tr.paletteProgram); program=tr.programs[tr.paletteProgram];}
if (leifxmode == 1) {
if (vertexShaders) R_GLSL_UseProgram(tr.leiFXDitherProgram);
program=tr.programs[tr.leiFXDitherProgram];
}
if (leifxmode == 2) {
if (vertexShaders) R_GLSL_UseProgram(tr.leiFXGammaProgram);
program=tr.programs[tr.leiFXGammaProgram];
}
if (leifxmode == 3) {
if (vertexShaders) R_GLSL_UseProgram(tr.leiFXFilterProgram);
program=tr.programs[tr.leiFXFilterProgram];
}
if (leifxmode == 888) {
if (vertexShaders) R_GLSL_UseProgram(tr.animeProgram);
program=tr.programs[tr.animeProgram];
}
if (leifxmode == 999) {
if (vertexShaders) R_GLSL_UseProgram(tr.animeFilmProgram);
program=tr.programs[tr.animeFilmProgram];
}
if (leifxmode == 777) {
if (vertexShaders) R_GLSL_UseProgram(tr.motionBlurProgram);
program=tr.programs[tr.motionBlurProgram];
}
if (leifxmode == 778) {
if (vertexShaders) R_GLSL_UseProgram(tr.motionBlurProgram);
program=tr.programs[tr.motionBlurProgram];
}
if (leifxmode == 779) {
if (vertexShaders) R_GLSL_UseProgram(tr.motionBlurPostProgram);
program=tr.programs[tr.motionBlurPostProgram];
}
if (leifxmode == 632) {
if (vertexShaders) R_GLSL_UseProgram(tr.NTSCEncodeProgram);
program=tr.programs[tr.NTSCEncodeProgram];
}
if (leifxmode == 633) {
if (vertexShaders) R_GLSL_UseProgram(tr.NTSCDecodeProgram);
program=tr.programs[tr.NTSCDecodeProgram];
}
if (leifxmode == 634) {
if (vertexShaders) R_GLSL_UseProgram(tr.NTSCBleedProgram);
program=tr.programs[tr.NTSCBleedProgram];
}
if (leifxmode == 666) {
if (vertexShaders) R_GLSL_UseProgram(tr.BrightnessProgram);
program=tr.programs[tr.BrightnessProgram];
}
if (leifxmode == 1236) {
if (vertexShaders) R_GLSL_UseProgram(tr.CRTProgram);
program=tr.programs[tr.CRTProgram];
}
if (leifxmode == 1997) {
if (vertexShaders) R_GLSL_UseProgram(tr.paletteProgram);
program=tr.programs[tr.paletteProgram];
}
}
else {
@@ -803,7 +865,9 @@ static void R_Bloom_RestoreScreen_Postprocessed( void ) {
if (program->u_CC_Contrast > -1) R_GLSL_SetUniform_u_CC_Contrast(program, 1.0);
//
if (leifxmode == 3){ R_GLSL_SetUniform_u_CC_Brightness(program, leifxpass); }
if (leifxmode == 3) {
R_GLSL_SetUniform_u_CC_Brightness(program, leifxpass);
}
if (program->u_zFar > -1) R_GLSL_SetUniform_u_zFar(program, tr.viewParms.zFar);
GL_SelectTexture(0);
@@ -814,7 +878,7 @@ static void R_Bloom_RestoreScreen_Postprocessed( void ) {
GL_Bind( postproc.depth.texture );
// motion blur crap
if( r_motionblur->integer > 2){
if( r_motionblur->integer > 2) {
if (program->u_mpasses > -1) R_GLSL_SetUniform_u_mpasses(program, mpasses);
GL_SelectTexture(2);
GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO );
@@ -848,17 +912,17 @@ static void R_Bloom_RestoreScreen_Postprocessed( void ) {
// if (leifxmode == 778)
// return;
if (leifxmode == 1234){
if (leifxmode == 1234) {
{
R_Bloom_QuadTV( glConfig.vidWidth, glConfig.vidHeight, 0, 0, postproc.screen.readW,postproc.screen.readH, 0 );
}
}
else if (leifxmode == 1236){
else if (leifxmode == 1236) {
{
R_Bloom_QuadTV( glConfig.vidWidth, glConfig.vidHeight, 0, 0, postproc.screen.readW,postproc.screen.readH, 0 );
}
}
else if (leifxmode == 1233){
else if (leifxmode == 1233) {
R_Bloom_QuadTV( glConfig.vidWidth, glConfig.vidHeight, 0, 0, postproc.screen.readW,postproc.screen.readH, 1 );
@@ -870,8 +934,7 @@ static void R_Bloom_RestoreScreen_Postprocessed( void ) {
R_Bloom_QuadTV( glConfig.vidWidth, glConfig.vidHeight, 0, 0, postproc.screen.readW,postproc.screen.readH, 4 );
}
else
{
else {
R_Bloom_Quad( glConfig.vidWidth, glConfig.vidHeight, 0, 0,
postproc.screen.readW,postproc.screen.readH );
}
@@ -1024,7 +1087,8 @@ void R_BloomScreen( void )
void R_BloomInit( void ) {
void R_BloomInit( void )
{
memset( &bloom, 0, sizeof( bloom ));
r_bloom = ri.Cvar_Get( "r_bloom", "0", CVAR_ARCHIVE );
@@ -1070,13 +1134,13 @@ static void R_Postprocess_InitTextures( void )
force32upload = 1;
// find closer power of 2 to screen size
for (postproc.screen.width = 1;postproc.screen.width< glConfig.vidWidth;postproc.screen.width *= 2);
for (postproc.screen.width = 1; postproc.screen.width< glConfig.vidWidth; postproc.screen.width *= 2);
// if (r_tvMode->integer > 1) // interlaced
// for (postproc.screen.height = 1;postproc.screen.height < vidinted;postproc.screen.height *= 2);
//else
for (postproc.screen.height = 1;postproc.screen.height < glConfig.vidHeight;postproc.screen.height *= 2);
for (postproc.screen.height = 1; postproc.screen.height < glConfig.vidHeight; postproc.screen.height *= 2);
// if (r_tvMode->integer > 1)
// intdiv = 2;
@@ -1091,8 +1155,8 @@ static void R_Postprocess_InitTextures( void )
postproc.work.width = r_bloom_sample_size->integer;
postproc.work.height = postproc.work.width * ( glConfig.vidWidth / glConfig.vidHeight );
for (postproc.effect.width = 1;postproc.effect.width < postproc.work.width;postproc.effect.width *= 2);
for (postproc.effect.height = 1;postproc.effect.height < postproc.work.height;postproc.effect.height *= 2);
for (postproc.effect.width = 1; postproc.effect.width < postproc.work.width; postproc.effect.width *= 2);
for (postproc.effect.height = 1; postproc.effect.height < postproc.work.height; postproc.effect.height *= 2);
postproc.effect.readW = postproc.work.width / (float)postproc.effect.width;
postproc.effect.readH = postproc.work.height / (float)postproc.effect.height;
@@ -1119,10 +1183,10 @@ static void R_Postprocess_InitTextures( void )
// leilei - tv output texture
if (r_tvMode->integer > -1){
if (r_tvMode->integer > -1) {
// find closer power of 2 to screen size
for (postproc.tv.width = 1;postproc.tv.width< tvWidth;postproc.tv.width *= 2);
for (postproc.tv.height = 1;postproc.tv.height < tvHeight;postproc.tv.height *= 2);
for (postproc.tv.width = 1; postproc.tv.width< tvWidth; postproc.tv.width *= 2);
for (postproc.tv.height = 1; postproc.tv.height < tvHeight; postproc.tv.height *= 2);
//postproc.tv.height /= intdiv; // interlacey
@@ -1136,12 +1200,12 @@ static void R_Postprocess_InitTextures( void )
// postproc.tvwork.height /= intdiv; // interlacey
for (postproc.tveffect.width = 1;postproc.tveffect.width < postproc.tvwork.width;postproc.tveffect.width *= 2) {}
for (postproc.tveffect.width = 1; postproc.tveffect.width < postproc.tvwork.width; postproc.tveffect.width *= 2) {}
if (intdiv > 1) {
for (postproc.tveffect.height = 1;(postproc.tveffect.height/2) < postproc.tvwork.height;postproc.tveffect.height *= 2) {}
for (postproc.tveffect.height = 1; (postproc.tveffect.height/2) < postproc.tvwork.height; postproc.tveffect.height *= 2) {}
}
else {
for (postproc.tveffect.height = 1;postproc.tveffect.height < postproc.tvwork.height;postproc.tveffect.height *= 2) {}
for (postproc.tveffect.height = 1; postproc.tveffect.height < postproc.tvwork.height; postproc.tveffect.height *= 2) {}
}
postproc.tveffect.readW = postproc.tvwork.width / (float)postproc.tveffect.width;
@@ -1157,7 +1221,7 @@ static void R_Postprocess_InitTextures( void )
// leilei - motion blur textures!
if (r_motionblur->integer > 2){
if (r_motionblur->integer > 2) {
data = ri.Hunk_AllocateTempMemory( postproc.screen.width * postproc.screen.height * 4 );
Com_Memset( data, 0, postproc.screen.width * postproc.screen.height * 4 );
postproc.motion1.texture = R_CreateImage( "***motionblur1 texture***", data, postproc.screen.width, postproc.screen.height, qfalse, qfalse, GL_CLAMP_TO_EDGE );
@@ -1208,7 +1272,8 @@ R_Postprocess_BackupScreen
Backup the full original screen to a texture for downscaling and later restoration
=================
*/
static void R_Postprocess_BackupScreen( void ) {
static void R_Postprocess_BackupScreen( void )
{
#ifdef GLSL_POSTPROCESSING
GL_Bind( postproc.screen.texture );
qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, glConfig.vidWidth, glConfig.vidHeight );
@@ -1257,7 +1322,8 @@ void R_PostprocessScreen( void )
void R_PostprocessingInit(void) {
void R_PostprocessingInit(void)
{
#ifdef GLSL_POSTPROCESSING
memset( &postproc, 0, sizeof( postproc ));
#endif
@@ -1274,7 +1340,8 @@ void R_PostprocessingInit(void) {
static void ID_INLINE R_LeiFX_Pointless_Quad( int width, int height, float texX, float texY, float texWidth, float texHeight ) {
static void ID_INLINE R_LeiFX_Pointless_Quad( int width, int height, float texX, float texY, float texWidth, float texHeight )
{
int x = 0;
int y = 0;
x = 0;
@@ -1341,7 +1408,7 @@ void R_LeiFXPostprocessDitherScreen( void )
R_LeiFX_Stupid_Hack();
if (r_leifx->integer > 1){
if (r_leifx->integer > 1) {
leifxmode = 1; // reduct and dither - 1 pass
R_Postprocess_BackupScreen();
R_Bloom_RestoreScreen_Postprocessed();
@@ -1377,15 +1444,15 @@ void R_LeiFXPostprocessFilterScreen( void )
// postprocess = 1;
/* if (r_leifx->integer == 3){
/* if (r_leifx->integer == 3){
leifxmode = 2; // gamma - 1 pass
// The stupidest hack in america
R_LeiFX_Stupid_Hack();
R_Postprocess_BackupScreen();
R_Bloom_RestoreScreen_Postprocessed();
}
*/ // Gamma disabled because r_alternateBrightness 2 makes it redundant now.
if (r_leifx->integer > 3){
*/ // Gamma disabled because r_alternateBrightness 2 makes it redundant now.
if (r_leifx->integer > 3) {
leifxmode = 3; // filter - 4 pass
// The stupidest hack in america
R_LeiFX_Stupid_Hack();
@@ -1448,12 +1515,34 @@ void R_NTSCScreen( void )
int ntsc_decode = 0;
// TODO: Switch it up
if (r_ntsc->integer == 1) ntsc_bleed = 1;
else if (r_ntsc->integer == 2){ ntsc_bleed = 1; ntsc_encode = 1; ntsc_decode = 1; }
else if (r_ntsc->integer == 3){ ntsc_bleed = 0; ntsc_encode = 1; ntsc_decode = 1; }
else if (r_ntsc->integer == 4){ ntsc_bleed = 1; ntsc_encode = 1; ntsc_decode = 1; }
else if (r_ntsc->integer > 6){ ntsc_bleed = 666; ntsc_encode = 0; ntsc_decode = 0; }
else { ntsc_bleed = 0; ntsc_encode = 1; ntsc_decode = 0; }
if (r_ntsc->integer == 1) {
ntsc_bleed = 1;
}
else if (r_ntsc->integer == 2) {
ntsc_bleed = 1;
ntsc_encode = 1;
ntsc_decode = 1;
}
else if (r_ntsc->integer == 3) {
ntsc_bleed = 0;
ntsc_encode = 1;
ntsc_decode = 1;
}
else if (r_ntsc->integer == 4) {
ntsc_bleed = 1;
ntsc_encode = 1;
ntsc_decode = 1;
}
else if (r_ntsc->integer > 6) {
ntsc_bleed = 666;
ntsc_encode = 0;
ntsc_decode = 0;
}
else {
ntsc_bleed = 0;
ntsc_encode = 1;
ntsc_decode = 0;
}
@@ -1461,20 +1550,20 @@ void R_NTSCScreen( void )
// qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
R_LeiFX_Stupid_Hack();
if (ntsc_encode){
if (ntsc_encode) {
leifxmode = 632; // Encode to composite
R_Postprocess_BackupScreen();
R_Bloom_RestoreScreen_Postprocessed();
}
if (ntsc_decode){
if (ntsc_decode) {
leifxmode = 633; // Decode to RGB
R_Postprocess_BackupScreen();
R_Bloom_RestoreScreen_Postprocessed();
}
if (ntsc_bleed){
if (ntsc_bleed) {
leifxmode = 634; // Encode to YUV and decode to RGB
R_Postprocess_BackupScreen();
R_Bloom_RestoreScreen_Postprocessed();
@@ -1482,12 +1571,11 @@ void R_NTSCScreen( void )
if (ntsc_bleed == 666){
if (ntsc_bleed == 666) {
leifxmode = 634; // Encode to YUV and decode to RGB EXCESSIVELY
int passasses = r_ntsc->integer;
int j;
for (j=0;j<passasses;j++)
{
for (j=0; j<passasses; j++) {
R_Postprocess_BackupScreen();
R_Bloom_RestoreScreen_Postprocessed();
}
@@ -1508,7 +1596,8 @@ void R_NTSCScreen( void )
extern cvar_t *r_alternateBrightness;
// shamelessly ripped off from tr_bloom.c
static void ID_INLINE R_Brighter_Quad( int width, int height, float texX, float texY, float texWidth, float texHeight ) {
static void ID_INLINE R_Brighter_Quad( int width, int height, float texX, float texY, float texWidth, float texHeight )
{
int x = 0;
int y = 0;
x = 0;
@@ -1561,8 +1650,7 @@ void R_BrightScreen( void )
if (r_alternateBrightness->integer == 1)
mode = 1; // force use blend
#ifdef GLSL_POSTPROCESSING
if (r_alternateBrightness->integer == 2)
{
if (r_alternateBrightness->integer == 2) {
// Automatically determine from capabilities
if ( vertexShaders ) {
mode = 2;
@@ -1573,8 +1661,7 @@ void R_BrightScreen( void )
}
// the modern pixel shader way
if (mode == 2)
{
if (mode == 2) {
if ( !vertexShaders )
return; // leilei - cards without support for this should not ever activate this
@@ -1608,8 +1695,12 @@ void R_BrightScreen( void )
if ((r_overBrightBits->integer)) {
ah = r_overBrightBits->integer;
if (ah < 1) { ah = 1; }
if (ah > 2) { ah = 2; } // clamp so it never looks stupid
if (ah < 1) {
ah = 1;
}
if (ah > 2) {
ah = 2; // clamp so it never looks stupid
}
// Blend method
// do a loop for every overbright bit enabled
@@ -1624,7 +1715,8 @@ void R_BrightScreen( void )
}
void R_AltBrightnessInit( void ) {
void R_AltBrightnessInit( void )
{
r_alternateBrightness = ri.Cvar_Get( "r_alternateBrightness", "0", CVAR_ARCHIVE | CVAR_LATCH);
r_film = ri.Cvar_Get( "r_film", "0", CVAR_ARCHIVE );
@@ -1658,8 +1750,8 @@ void R_FilmScreen( void )
tone[1] = 0.9f;
tone[2] = 1.0f;
//VectorCopy( backEnd.currentEntity->ambientLight, tone );
if (backEnd.currentEntity){
if (backEnd.currentEntity->ambientLight[0] > 0.001f && backEnd.currentEntity->ambientLight[1] > 0.001f && backEnd.currentEntity->ambientLight[2] > 0.001f){
if (backEnd.currentEntity) {
if (backEnd.currentEntity->ambientLight[0] > 0.001f && backEnd.currentEntity->ambientLight[1] > 0.001f && backEnd.currentEntity->ambientLight[2] > 0.001f) {
tone[0] = backEnd.currentEntity->ambientLight[0];
tone[1] = backEnd.currentEntity->ambientLight[1];
tone[2] = backEnd.currentEntity->ambientLight[2];
@@ -1690,38 +1782,50 @@ void R_FilmScreen( void )
toneinv[2] = tone[2] * -1 + 1 + tonecont[2];
// darken vignette.
GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO);GL_Bind( tr.dlightImage ); GL_Cull( CT_TWO_SIDED );
GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO);
GL_Bind( tr.dlightImage );
GL_Cull( CT_TWO_SIDED );
qglColor4f( 0.941177, 0.952941, 0.968628, 1.0f );
R_Brighter_Quad( glConfig.vidWidth, glConfig.vidHeight, 0.35f, 0.35f, 0.2f, 0.2f );
// brighten.
GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ONE);GL_Bind( tr.dlightImage ); GL_Cull( CT_TWO_SIDED );
GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ONE);
GL_Bind( tr.dlightImage );
GL_Cull( CT_TWO_SIDED );
//qglColor4f( 0.941177, 0.952941, 0.968628, 1.0f );
qglColor4f( (0.9f + (tone[0] * 0.5)), (0.9f + (tone[1] * 0.5)), (0.9f + (tone[2] * 0.5)), 1.0f );
R_Brighter_Quad( glConfig.vidWidth, glConfig.vidHeight, 0.25f, 0.25f, 0.48f, 0.48f );
// invert.
GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_ONE_MINUS_DST_COLOR | GLS_DSTBLEND_ONE_MINUS_SRC_COLOR);GL_Bind( tr.whiteImage ); GL_Cull( CT_TWO_SIDED );
GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_ONE_MINUS_DST_COLOR | GLS_DSTBLEND_ONE_MINUS_SRC_COLOR);
GL_Bind( tr.whiteImage );
GL_Cull( CT_TWO_SIDED );
// qglColor4f(0.85098, 0.85098, 0.815686, 1.0f );
qglColor4f( (0.8f + (toneinv[0] * 0.5)), (0.8f + (toneinv[1] * 0.5)), (0.8f + (toneinv[2] * 0.5)), 1.0f );
R_Brighter_Quad( glConfig.vidWidth, glConfig.vidHeight, 0, 0, 1, 1 );
// brighten.
GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_SRC_COLOR);GL_Bind( tr.whiteImage ); GL_Cull( CT_TWO_SIDED );
GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_SRC_COLOR);
GL_Bind( tr.whiteImage );
GL_Cull( CT_TWO_SIDED );
qglColor4f( 0.615686, 0.615686, 0.615686, 1.0f );
R_Brighter_Quad( glConfig.vidWidth, glConfig.vidHeight, 0, 0, 1, 1 );
// invoort.
GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_ONE_MINUS_DST_COLOR | GLS_DSTBLEND_ONE_MINUS_SRC_COLOR);GL_Bind( tr.whiteImage ); GL_Cull( CT_TWO_SIDED );
GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_ONE_MINUS_DST_COLOR | GLS_DSTBLEND_ONE_MINUS_SRC_COLOR);
GL_Bind( tr.whiteImage );
GL_Cull( CT_TWO_SIDED );
qglColor4f(1.0f, 1.0f, 1.0f , 1.0f );
R_Brighter_Quad( glConfig.vidWidth, glConfig.vidHeight, 0, 0, 1, 1 );
// brighten.
GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_SRC_COLOR);GL_Bind( tr.whiteImage ); GL_Cull( CT_TWO_SIDED );
GL_State( GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_SRC_COLOR);
GL_Bind( tr.whiteImage );
GL_Cull( CT_TWO_SIDED );
// qglColor4f( 0.866667, 0.847059, 0.776471, 1.0f );
qglColor4f( (0.73f + (toneinv[0] * 0.4)), (0.73f + (toneinv[1] * 0.4)), (0.73f + (toneinv[2] * 0.4)), 1.0f );
R_Brighter_Quad( glConfig.vidWidth, glConfig.vidHeight, 0, 0, 1, 1 );
@@ -1838,20 +1942,51 @@ void R_AnimeScreen( void )
// leilei - motion blur hack
void R_MotionBlur_BackupScreen(int which) {
void R_MotionBlur_BackupScreen(int which)
{
#ifdef GLSL_POSTPROCESSING
if( r_motionblur->integer < 3)
return;
if (which == 1){ GL_Bind( postproc.motion1.texture ); qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, glConfig.vidWidth, glConfig.vidHeight ); } // gather thee samples
if (which == 2){ GL_Bind( postproc.motion2.texture ); qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, glConfig.vidWidth, glConfig.vidHeight ); }
if (which == 3){ GL_Bind( postproc.motion3.texture ); qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, glConfig.vidWidth, glConfig.vidHeight ); }
if (which == 4){ GL_Bind( postproc.motion4.texture ); qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, glConfig.vidWidth, glConfig.vidHeight ); }
if (which == 5){ GL_Bind( postproc.motion5.texture ); qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, glConfig.vidWidth, glConfig.vidHeight ); }
if (which == 11){ GL_Bind( postproc.mpass1.texture ); qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, glConfig.vidWidth, glConfig.vidHeight ); } // to accum
if (which == 12){ GL_Bind( postproc.mpass1.texture ); qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, glConfig.vidWidth, glConfig.vidHeight ); } // to accum
if (which == 13){ GL_Bind( postproc.mpass1.texture ); qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, glConfig.vidWidth, glConfig.vidHeight ); } // to accum
if (which == 14){ GL_Bind( postproc.mpass1.texture ); qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, glConfig.vidWidth, glConfig.vidHeight ); } // to accum
if (which == 18){ GL_Bind( postproc.screen.texture ); qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, glConfig.vidWidth, glConfig.vidHeight ); } // to accum
if (which == 1) {
GL_Bind( postproc.motion1.texture ); // gather thee samples
qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, glConfig.vidWidth, glConfig.vidHeight );
}
if (which == 2) {
GL_Bind( postproc.motion2.texture );
qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, glConfig.vidWidth, glConfig.vidHeight );
}
if (which == 3) {
GL_Bind( postproc.motion3.texture );
qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, glConfig.vidWidth, glConfig.vidHeight );
}
if (which == 4) {
GL_Bind( postproc.motion4.texture );
qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, glConfig.vidWidth, glConfig.vidHeight );
}
if (which == 5) {
GL_Bind( postproc.motion5.texture );
qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, glConfig.vidWidth, glConfig.vidHeight );
}
if (which == 11) {
GL_Bind( postproc.mpass1.texture ); // to accum
qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, glConfig.vidWidth, glConfig.vidHeight );
}
if (which == 12) {
GL_Bind( postproc.mpass1.texture ); // to accum
qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, glConfig.vidWidth, glConfig.vidHeight );
}
if (which == 13) {
GL_Bind( postproc.mpass1.texture ); // to accum
qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, glConfig.vidWidth, glConfig.vidHeight );
}
if (which == 14) {
GL_Bind( postproc.mpass1.texture ); // to accum
qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, glConfig.vidWidth, glConfig.vidHeight );
}
if (which == 18) {
GL_Bind( postproc.screen.texture ); // to accum
qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 0, 0, glConfig.vidWidth, glConfig.vidHeight );
}
#endif
}
@@ -1932,7 +2067,8 @@ void R_MblurScreenPost( void )
// TV MODE
// =================================================================
static void R_Postprocess_BackupScreenTV( void ) {
static void R_Postprocess_BackupScreenTV( void )
{
#ifdef GLSL_POSTPROCESSING
int intdiv;
intdiv = 1;
@@ -1953,7 +2089,8 @@ static void R_Postprocess_BackupScreenTV( void ) {
#endif
}
static void R_Postprocess_ScaleTV( void ) {
static void R_Postprocess_ScaleTV( void )
{
#ifdef GLSL_POSTPROCESSING
GL_TexEnv( GL_MODULATE );
@@ -1996,7 +2133,7 @@ void R_TVScreen( void )
// postprocess = 1;
if (backEnd.refdef.time > tvtime){
if (backEnd.refdef.time > tvtime) {
tvinterlace *= -1;
tvtime = backEnd.refdef.time + (1000.0f / 60); // 60hz
}
@@ -2012,12 +2149,10 @@ void R_TVScreen( void )
// leifxmode = 1236; // run it through a shader
//R_Postprocess_BackupScreen();
if (r_tvMode->integer > 100)
{
if (r_tvMode->integer > 100) {
R_Postprocess_ScaleTV();
}
else
{
else {
R_Postprocess_BackupScreenTV();
R_Bloom_RestoreScreen_Postprocessed();
@@ -2123,12 +2258,14 @@ static void R_WaterWorks( void )
}
static void R_Water_RestoreScreen( void ) {
static void R_Water_RestoreScreen( void )
{
// NO!
}
void R_WaterInit( void ) {
void R_WaterInit( void )
{
// NO!
}

File diff suppressed because it is too large Load Diff