You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
187 lines
4.6 KiB
187 lines
4.6 KiB
7 years ago
|
/*
|
||
|
gl_rmisc.c - renderer misceallaneous
|
||
|
Copyright (C) 2010 Uncle Mike
|
||
|
|
||
|
This program is free software: you can redistribute it and/or modify
|
||
|
it under the terms of the GNU General Public License as published by
|
||
|
the Free Software Foundation, either version 3 of the License, or
|
||
|
(at your option) any later version.
|
||
|
|
||
|
This program is distributed in the hope that it will be useful,
|
||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
GNU General Public License for more details.
|
||
|
*/
|
||
|
|
||
|
#include "gl_local.h"
|
||
|
#include "shake.h"
|
||
6 years ago
|
#include "screenfade.h"
|
||
|
#include "cdll_int.h"
|
||
7 years ago
|
|
||
6 years ago
|
static void R_ParseDetailTextures( const char *filename )
|
||
7 years ago
|
{
|
||
5 years ago
|
byte *afile;
|
||
|
char *pfile;
|
||
7 years ago
|
string token, texname;
|
||
|
string detail_texname;
|
||
|
string detail_path;
|
||
|
float xScale, yScale;
|
||
|
texture_t *tex;
|
||
|
int i;
|
||
|
|
||
2 years ago
|
afile = gEngfuncs.fsapi->LoadFile( filename, NULL, false );
|
||
7 years ago
|
if( !afile ) return;
|
||
|
|
||
5 years ago
|
pfile = (char *)afile;
|
||
7 years ago
|
|
||
|
// format: 'texturename' 'detailtexture' 'xScale' 'yScale'
|
||
3 years ago
|
while(( pfile = COM_ParseFile( pfile, token, sizeof( token ))) != NULL )
|
||
7 years ago
|
{
|
||
|
texname[0] = '\0';
|
||
|
detail_texname[0] = '\0';
|
||
|
|
||
|
// read texname
|
||
|
if( token[0] == '{' )
|
||
|
{
|
||
|
// NOTE: COM_ParseFile handled some symbols seperately
|
||
|
// this code will be fix it
|
||
3 years ago
|
pfile = COM_ParseFile( pfile, token, sizeof( token ));
|
||
7 years ago
|
Q_strncat( texname, "{", sizeof( texname ));
|
||
|
Q_strncat( texname, token, sizeof( texname ));
|
||
|
}
|
||
|
else Q_strncpy( texname, token, sizeof( texname ));
|
||
|
|
||
|
// read detailtexture name
|
||
3 years ago
|
pfile = COM_ParseFile( pfile, token, sizeof( token ));
|
||
7 years ago
|
Q_strncat( detail_texname, token, sizeof( detail_texname ));
|
||
|
|
||
|
// trying the scales or '{'
|
||
3 years ago
|
pfile = COM_ParseFile( pfile, token, sizeof( token ));
|
||
7 years ago
|
|
||
|
// read second part of detailtexture name
|
||
|
if( token[0] == '{' )
|
||
|
{
|
||
|
Q_strncat( detail_texname, token, sizeof( detail_texname ));
|
||
3 years ago
|
pfile = COM_ParseFile( pfile, token, sizeof( token )); // read scales
|
||
7 years ago
|
Q_strncat( detail_texname, token, sizeof( detail_texname ));
|
||
3 years ago
|
pfile = COM_ParseFile( pfile, token, sizeof( token )); // parse scales
|
||
7 years ago
|
}
|
||
|
|
||
|
Q_snprintf( detail_path, sizeof( detail_path ), "gfx/%s", detail_texname );
|
||
|
|
||
|
// read scales
|
||
4 years ago
|
xScale = Q_atof( token );
|
||
7 years ago
|
|
||
3 years ago
|
pfile = COM_ParseFile( pfile, token, sizeof( token ));
|
||
7 years ago
|
yScale = Q_atof( token );
|
||
|
|
||
|
if( xScale <= 0.0f || yScale <= 0.0f )
|
||
|
continue;
|
||
|
|
||
|
// search for existing texture and uploading detail texture
|
||
6 years ago
|
for( i = 0; i < WORLDMODEL->numtextures; i++ )
|
||
7 years ago
|
{
|
||
6 years ago
|
tex = WORLDMODEL->textures[i];
|
||
7 years ago
|
|
||
|
if( Q_stricmp( tex->name, texname ))
|
||
|
continue;
|
||
|
|
||
6 years ago
|
tex->dt_texturenum = GL_LoadTexture( detail_path, NULL, 0, TF_FORCE_COLOR );
|
||
7 years ago
|
|
||
|
// texture is loaded
|
||
|
if( tex->dt_texturenum )
|
||
|
{
|
||
6 years ago
|
gl_texture_t *glt;
|
||
7 years ago
|
|
||
|
glt = R_GetTexture( tex->gl_texturenum );
|
||
|
glt->xscale = xScale;
|
||
|
glt->yscale = yScale;
|
||
|
}
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
Mem_Free( afile );
|
||
|
}
|
||
|
|
||
|
void R_NewMap( void )
|
||
|
{
|
||
|
texture_t *tx;
|
||
|
int i;
|
||
|
|
||
|
R_ClearDecals(); // clear all level decals
|
||
|
|
||
6 years ago
|
R_StudioResetPlayerModels();
|
||
|
|
||
7 years ago
|
// upload detailtextures
|
||
6 years ago
|
if( CVAR_TO_BOOL( r_detailtextures ))
|
||
7 years ago
|
{
|
||
|
string mapname, filepath;
|
||
|
|
||
6 years ago
|
Q_strncpy( mapname, WORLDMODEL->name, sizeof( mapname ));
|
||
7 years ago
|
COM_StripExtension( mapname );
|
||
|
Q_sprintf( filepath, "%s_detail.txt", mapname );
|
||
|
|
||
|
R_ParseDetailTextures( filepath );
|
||
|
}
|
||
|
|
||
6 years ago
|
if( gEngfuncs.pfnGetCvarFloat( "v_dark" ))
|
||
7 years ago
|
{
|
||
6 years ago
|
screenfade_t *sf = gEngfuncs.GetScreenFade();
|
||
7 years ago
|
float fadetime = 5.0f;
|
||
7 years ago
|
client_textmessage_t *title;
|
||
|
|
||
6 years ago
|
title = gEngfuncs.pfnTextMessageGet( "GAMETITLE" );
|
||
6 years ago
|
if( ENGINE_GET_PARM( PARM_QUAKE_COMPATIBLE ))
|
||
7 years ago
|
fadetime = 1.0f;
|
||
7 years ago
|
|
||
|
if( title )
|
||
|
{
|
||
|
// get settings from titles.txt
|
||
|
sf->fadeEnd = title->holdtime + title->fadeout;
|
||
|
sf->fadeReset = title->fadeout;
|
||
|
}
|
||
7 years ago
|
else sf->fadeEnd = sf->fadeReset = fadetime;
|
||
4 years ago
|
|
||
7 years ago
|
sf->fadeFlags = FFADE_IN;
|
||
|
sf->fader = sf->fadeg = sf->fadeb = 0;
|
||
|
sf->fadealpha = 255;
|
||
|
sf->fadeSpeed = (float)sf->fadealpha / sf->fadeReset;
|
||
6 years ago
|
sf->fadeReset += gpGlobals->time;
|
||
7 years ago
|
sf->fadeEnd += sf->fadeReset;
|
||
|
|
||
6 years ago
|
gEngfuncs.Cvar_SetValue( "v_dark", 0.0f );
|
||
7 years ago
|
}
|
||
|
|
||
|
// clear out efrags in case the level hasn't been reloaded
|
||
6 years ago
|
for( i = 0; i < WORLDMODEL->numleafs; i++ )
|
||
|
WORLDMODEL->leafs[i+1].efrags = NULL;
|
||
7 years ago
|
|
||
6 years ago
|
glState.isFogEnabled = false;
|
||
7 years ago
|
tr.skytexturenum = -1;
|
||
|
pglDisable( GL_FOG );
|
||
|
|
||
|
// clearing texture chains
|
||
6 years ago
|
for( i = 0; i < WORLDMODEL->numtextures; i++ )
|
||
7 years ago
|
{
|
||
6 years ago
|
if( !WORLDMODEL->textures[i] )
|
||
7 years ago
|
continue;
|
||
|
|
||
6 years ago
|
tx = WORLDMODEL->textures[i];
|
||
7 years ago
|
|
||
6 years ago
|
if( !Q_strncmp( tx->name, "sky", 3 ) && tx->width == ( tx->height * 2 ))
|
||
7 years ago
|
tr.skytexturenum = i;
|
||
|
|
||
|
tx->texturechain = NULL;
|
||
|
}
|
||
|
|
||
6 years ago
|
R_SetupSky( MOVEVARS->skyName );
|
||
7 years ago
|
|
||
|
GL_BuildLightmaps ();
|
||
6 years ago
|
R_GenerateVBO();
|
||
6 years ago
|
|
||
|
if( gEngfuncs.drawFuncs->R_NewMap != NULL )
|
||
|
gEngfuncs.drawFuncs->R_NewMap();
|
||
|
|
||
6 years ago
|
}
|