1 /*
2  * Fog.cpp
3  * Copyright (C) 2007 by Bryan Duff <duff0097@gmail.com>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
18  * USA
19  */
20 /**> HEADER FILES <**/
21 #include "Fog.h"
SetFog(float colorR,float colorG,float colorB,float fStart,float fEnd,float Density)22 void Fog::SetFog(float colorR, float colorG, float colorB, float fStart,
23                  float fEnd, float Density)
24 {
25   GLfloat newfogColor[4];
26   newfogColor[0] = colorR;
27   newfogColor[1] = colorG;
28   newfogColor[2] = colorB;
29   newfogColor[3] = 1;
30   fogStart = fStart;
31   fogEnd = fEnd;
32   fogDensity = Density;
33   fogMode = GL_LINEAR;
34 
35   glFogi(GL_FOG_MODE, fogMode);
36   glFogfv(GL_FOG_COLOR, newfogColor);
37   glFogf(GL_FOG_DENSITY, fogDensity);
38   glFogi(GL_FOG_HINT, GL_DONT_CARE);
39   glFogf(GL_FOG_START, fogStart);
40   glFogf(GL_FOG_END, fogEnd);
41 
42   glEnable(GL_FOG);
43 }
44 
SetFog(Color newColor,float fStart,float fEnd,float Density)45 void Fog::SetFog(Color newColor, float fStart, float fEnd, float Density)
46 {
47   GLfloat newfogColor[4];
48   newfogColor[0] = newColor.r;
49   newfogColor[1] = newColor.g;
50   newfogColor[2] = newColor.b;
51   newfogColor[3] = 1;
52   fogStart = fStart;
53   fogEnd = fEnd;
54   fogDensity = Density;
55   fogMode = GL_LINEAR;
56 
57   glFogi(GL_FOG_MODE, fogMode);
58   glFogfv(GL_FOG_COLOR, newfogColor);
59   glFogf(GL_FOG_DENSITY, fogDensity);
60   glFogi(GL_FOG_HINT, GL_DONT_CARE);
61   glFogf(GL_FOG_START, fogStart);
62   glFogf(GL_FOG_END, fogEnd);
63 
64   glEnable(GL_FOG);
65 }
66 
TempFog(float colorR,float colorG,float colorB)67 void Fog::TempFog(float colorR, float colorG, float colorB)
68 {
69   GLfloat tempfogColor[4];
70   tempfogColor[0] = colorR;
71   tempfogColor[1] = colorG;
72   tempfogColor[2] = colorB;
73   tempfogColor[3] = 1;
74 
75   glFogi(GL_FOG_MODE, fogMode);
76   glFogfv(GL_FOG_COLOR, tempfogColor);
77   glFogf(GL_FOG_DENSITY, fogDensity);
78   glFogi(GL_FOG_HINT, GL_DONT_CARE);
79   glFogf(GL_FOG_START, fogStart);
80   glFogf(GL_FOG_END, fogEnd);
81 
82   glEnable(GL_FOG);
83 }
84 
ResetFog()85 void Fog::ResetFog()
86 {
87   glFogi(GL_FOG_MODE, fogMode);
88   glFogfv(GL_FOG_COLOR, fogColor);
89   glFogf(GL_FOG_DENSITY, fogDensity);
90   glFogi(GL_FOG_HINT, GL_DONT_CARE);
91   glFogf(GL_FOG_START, fogStart);
92   glFogf(GL_FOG_END, fogEnd);
93 
94   glEnable(GL_FOG);
95 }
96