00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "ExManagerFog.h"
00025
00026 ExManagerFog::ExManagerFog(void)
00027 {
00028 Guard(ExManagerFog::ExManagerFog(void))
00029 Reset();
00030 UnGuard
00031 }
00032
00033 ExManagerFog::~ExManagerFog(void)
00034 {
00035 Guard(ExManagerFog::~ExManagerFog(void))
00036 UnGuard
00037 }
00038
00039 void ExManagerFog::Reset(void)
00040 {
00041 Guard(ExManagerFog::Reset(void))
00042 SetAlgo(GL_LINEAR);
00043 SetFogColor(0.2f,0.2f,0.2f,1.0f);
00044 SetStartPoint(50.0f);
00045 SetEndPoint(100.0f);
00046 SetDensity(0.30);
00047 m_State=false;
00048 UnGuard
00049 }
00050
00051 void ExManagerFog::EnableFog(void)
00052 {
00053 Guard(ExManagerFog::EnableFog(void))
00054 glEnable(GL_FOG);
00055 glFogi(GL_FOG_MODE,m_FogAlgo);
00056 glFogfv(GL_FOG_COLOR,m_FogColor);
00057 glFogf(GL_FOG_DENSITY,m_Density);
00058 glHint(GL_FOG_HINT,GL_DONT_CARE);
00059 glFogf(GL_FOG_START,m_StartPoint);
00060 glFogf(GL_FOG_END,m_EndPoint);
00061 m_State=true;
00062 UnGuard
00063 }
00064
00065 void ExManagerFog::DisableFog(void)
00066 {
00067 Guard(ExManagerFog::DisableFog(void))
00068 glDisable(GL_FOG);
00069 m_State=false;
00070 UnGuard
00071 }
00072
00073
00074 void ExManagerFog::SetFogColor(float R,float G,float B,float A)
00075 {
00076 Guard(ExManagerFog::SetFogColor(float R,float G,float B,float A))
00077 SetFogColorR(R);
00078 SetFogColorG(G);
00079 SetFogColorB(B);
00080 SetFogColorA(A);
00081 UnGuard
00082 }
00083
00084 void ExManagerFog::SetFogColorR(float R)
00085 {
00086 Guard(ExManagerFog::SetFogColorR(float R))
00087 if(R>1.0f)R=1.0f;
00088 if(R<0.0f)R=0.0f;
00089 m_FogColor[0]=R;
00090 glFogfv(GL_FOG_COLOR,m_FogColor);
00091 UnGuard
00092 }
00093
00094 void ExManagerFog::SetFogColorG(float G)
00095 {
00096 Guard(ExManagerFog::SetFogColorG(float G))
00097 if(G>1.0f)G=1.0f;
00098 if(G<0.0f)G=0.0f;
00099 m_FogColor[1]=G;
00100 glFogfv(GL_FOG_COLOR,m_FogColor);
00101 UnGuard
00102 }
00103
00104 void ExManagerFog::SetFogColorB(float B)
00105 {
00106 Guard(ExManagerFog::SetFogColorB(float B))
00107 if(B>1.0f)B=1.0f;
00108 if(B<0.0f)B=0.0f;
00109 m_FogColor[2]=B;
00110 glFogfv(GL_FOG_COLOR,m_FogColor);
00111 UnGuard
00112 }
00113
00114 void ExManagerFog::SetFogColorA(float A)
00115 {
00116 Guard(ExManagerFog::SetFogColorA(float A))
00117 if(A>1.0f)A=1.0f;
00118 if(A<0.0f)A=0.0f;
00119 m_FogColor[3]=A;
00120 glFogfv(GL_FOG_COLOR,m_FogColor);
00121 UnGuard
00122 }
00123
00124 void ExManagerFog::IncFogColorR(float inc)
00125 {
00126 Guard(ExManagerFog::IncFogColorR(float inc))
00127 SetFogColorR(GetFogColorR()+inc);
00128 UnGuard
00129 }
00130
00131 void ExManagerFog::IncFogColorG(float inc)
00132 {
00133 Guard(ExManagerFog::IncFogColorG(float inc))
00134 SetFogColorG(GetFogColorG()+inc);
00135 UnGuard
00136 }
00137
00138 void ExManagerFog::IncFogColorB(float inc)
00139 {
00140 Guard(ExManagerFog::IncFogColorB(float inc))
00141 SetFogColorB(GetFogColorB()+inc);
00142 UnGuard
00143 }
00144
00145 void ExManagerFog::IncFogColorA(float inc)
00146 {
00147 Guard(ExManagerFog::IncFogColorA(float inc))
00148 SetFogColorA(GetFogColorA()+inc);
00149 UnGuard
00150 }
00151
00152 void ExManagerFog::SetStartPoint(float P)
00153 {
00154 Guard(ExManagerFog::SetStartPoint(float P))
00155 m_StartPoint=P;
00156 glFogf(GL_FOG_START,m_StartPoint);
00157 UnGuard
00158 }
00159
00160 void ExManagerFog::IncStartPoint(float inc)
00161 {
00162 Guard(ExManagerFog::IncStartPoint(float inc))
00163 SetStartPoint(GetStarPoint()+inc);
00164 UnGuard
00165 }
00166
00167 void ExManagerFog::SetEndPoint(float P)
00168 {
00169 Guard(ExManagerFog::SetEndPoint(float P))
00170 m_EndPoint=P;
00171 glFogf(GL_FOG_END,m_EndPoint);
00172 UnGuard
00173 }
00174
00175 void ExManagerFog::IncEndPoint(float inc)
00176 {
00177 Guard(ExManagerFog::IncEndPoint(float inc))
00178 SetEndPoint(GetEndPoint()+inc);
00179 UnGuard
00180 }
00181
00182 void ExManagerFog::SetDensity(float P)
00183 {
00184 Guard(ExManagerFog::SetDensity(float P))
00185 m_Density=P;
00186 glFogf(GL_FOG_DENSITY,m_Density);
00187 UnGuard
00188 }
00189
00190 void ExManagerFog::IncDensity(float inc)
00191 {
00192 Guard(ExManagerFog::IncDensity(float inc))
00193 SetDensity(GetDensity()+inc);
00194 UnGuard
00195 }
00196
00197 void ExManagerFog::SetAlgo(GLenum algo)
00198 {
00199 Guard(ExManagerFog::SetAlgo(GLenum algo))
00200 switch(algo)
00201 {
00202 case GL_LINEAR:
00203 m_FogAlgo=GL_LINEAR;
00204 glFogi(GL_FOG_MODE,GL_LINEAR);
00205 break;
00206 case GL_EXP:
00207 m_FogAlgo=GL_EXP;
00208 glFogi(GL_FOG_MODE,GL_EXP);
00209 break;
00210 case GL_EXP2:
00211 m_FogAlgo=GL_EXP2;
00212 glFogi(GL_FOG_MODE,GL_EXP2);
00213 break;
00214 default :
00215 m_FogAlgo=GL_LINEAR;
00216 glFogi(GL_FOG_MODE,GL_LINEAR);
00217 break;
00218 }
00219 UnGuard
00220 }