2010-12-10 08:15:47 +00:00
|
|
|
/*
|
|
|
|
Copyright (C) 1996-2001 Id Software, Inc.
|
|
|
|
Copyright (C) 2002-2009 John Fitzgibbons and others
|
|
|
|
|
|
|
|
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 2
|
|
|
|
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.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
//gl_fog.c -- global and volumetric fog
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "QF/GL/defines.h"
|
|
|
|
#include "QF/GL/funcs.h"
|
|
|
|
|
|
|
|
#include "compat.h"
|
2012-02-14 08:28:09 +00:00
|
|
|
#include "r_internal.h"
|
2022-03-07 17:10:47 +00:00
|
|
|
#include "vid_gl.h"
|
2010-12-10 08:15:47 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
Fog_SetupFrame
|
|
|
|
|
|
|
|
called at the beginning of each frame
|
|
|
|
*/
|
|
|
|
void
|
2012-02-22 07:32:34 +00:00
|
|
|
gl_Fog_SetupFrame (void)
|
2010-12-10 08:15:47 +00:00
|
|
|
{
|
2020-12-24 07:39:05 +00:00
|
|
|
quat_t fogcolor;
|
|
|
|
|
2022-03-07 17:10:47 +00:00
|
|
|
Fog_GetColor (fogcolor);
|
2020-12-24 07:39:05 +00:00
|
|
|
qfglFogfv (GL_FOG_COLOR, fogcolor);
|
2022-03-07 17:10:47 +00:00
|
|
|
qfglFogf (GL_FOG_DENSITY, Fog_GetDensity () / 64.0);
|
|
|
|
qfglFogi (GL_FOG_MODE, GL_EXP2);
|
2010-12-10 08:15:47 +00:00
|
|
|
}
|
|
|
|
|
2022-03-07 17:10:47 +00:00
|
|
|
|
2010-12-10 08:15:47 +00:00
|
|
|
/*
|
|
|
|
Fog_EnableGFog
|
|
|
|
|
|
|
|
called before drawing stuff that should be fogged
|
|
|
|
*/
|
|
|
|
void
|
2012-02-22 07:32:34 +00:00
|
|
|
gl_Fog_EnableGFog (void)
|
2010-12-10 08:15:47 +00:00
|
|
|
{
|
2022-03-07 17:10:47 +00:00
|
|
|
if (Fog_GetDensity () > 0)
|
2010-12-10 08:15:47 +00:00
|
|
|
qfglEnable (GL_FOG);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Fog_DisableGFog
|
|
|
|
|
|
|
|
called after drawing stuff that should be fogged
|
|
|
|
*/
|
|
|
|
void
|
2012-02-22 07:32:34 +00:00
|
|
|
gl_Fog_DisableGFog (void)
|
2010-12-10 08:15:47 +00:00
|
|
|
{
|
2022-03-07 17:10:47 +00:00
|
|
|
if (Fog_GetDensity () > 0)
|
2010-12-10 08:15:47 +00:00
|
|
|
qfglDisable (GL_FOG);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Fog_StartAdditive
|
|
|
|
|
|
|
|
called before drawing stuff that is additive blended -- sets fog color
|
|
|
|
to black
|
|
|
|
*/
|
|
|
|
void
|
2012-02-22 07:32:34 +00:00
|
|
|
gl_Fog_StartAdditive (void)
|
2010-12-10 08:15:47 +00:00
|
|
|
{
|
|
|
|
vec3_t color = {0, 0, 0};
|
|
|
|
|
2022-03-07 17:10:47 +00:00
|
|
|
qfglFogi (GL_FOG_MODE, GL_EXP2);
|
|
|
|
if (Fog_GetDensity () > 0)
|
2010-12-10 08:15:47 +00:00
|
|
|
qfglFogfv (GL_FOG_COLOR, color);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Fog_StopAdditive
|
|
|
|
|
|
|
|
called after drawing stuff that is additive blended -- restores fog color
|
|
|
|
*/
|
2012-02-22 07:32:34 +00:00
|
|
|
void
|
|
|
|
gl_Fog_StopAdditive (void)
|
2010-12-10 08:15:47 +00:00
|
|
|
{
|
2022-03-07 17:10:47 +00:00
|
|
|
if (Fog_GetDensity () > 0) {
|
2020-12-24 07:39:05 +00:00
|
|
|
quat_t fogcolor;
|
2022-03-07 17:10:47 +00:00
|
|
|
Fog_GetColor (fogcolor);
|
2020-12-24 07:39:05 +00:00
|
|
|
qfglFogfv (GL_FOG_COLOR, fogcolor);
|
|
|
|
}
|
2010-12-10 08:15:47 +00:00
|
|
|
}
|