Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

fog.h

Go to the documentation of this file.
00001 /* ***********************************************************************************
00002         Writer:         Sebastien Bloc
00003         Copyright:      2003-2004
00004         eMail:          sebastien.bloc@free.fr
00005         URL:            http://mignonsoft.free.fr
00006 
00007         This program is free software; you can redistribute it and/or
00008         modify it under the terms of the GNU General Public License
00009         as published by the Free Software Foundation; either version 2
00010         of the License, or (at your option) any later version.
00011 
00012         This program is distributed in the hope that it will be useful,
00013         but WITHOUT ANY WARRANTY; without even the implied warranty of
00014         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015         GNU General Public License for more details.
00016         http://www.gnu.org/copyleft/gpl.html
00017 *********************************************************************************** */
00018 
00023 #ifndef INCLUDE_3D_FOG_H
00024 #define INCLUDE_3D_FOG_H
00025 
00037 typedef enum 
00038 {
00039         fogLinear = GL_LINEAR,
00040         fogExponential = GL_EXP,
00041         fogExponential2 = GL_EXP2
00042 } FogMode; 
00053 class Fog
00054 {
00055 public:
00056         BOOL  isEnable;
00057         float start;
00058         float end;
00059         float density;
00060         FogMode mode;
00061         Color color;
00062 
00063 public:
00064         Fog()
00065         {
00066                 isEnable=FALSE;
00067                 start=0;
00068                 end=0;
00069                 density=0;
00070                 mode=fogLinear;
00071                 color.Set(0,0,0,1.0);
00072         }
00073 
00074         void Enable(BOOL set=-1)
00075         {
00076                 if (set!=-1) isEnable = set;
00077                 if (isEnable) glEnable(GL_FOG);
00078                 else glDisable(GL_FOG);
00079         }
00080 
00081         void Use()
00082         {
00083                 Enable();
00084                 glFogfv(GL_FOG_COLOR,color);
00085                 glFogf(GL_FOG_START,start);
00086                 glFogf(GL_FOG_END,end); 
00087                 glFogf(GL_FOG_DENSITY,density); 
00088                 glFogi(GL_FOG_MODE,(int)mode);
00089         }
00090 
00091         void GetStringMode (MyString &result)
00092         {
00093                 switch (mode)
00094                 {
00095                 case fogLinear: result="Linear"; break;
00096                 case fogExponential: result="Exponential"; break;
00097                 case fogExponential2: result="Exponential˛"; break;
00098                 default: result="Error";
00099                 }
00100         }
00101 
00102         int GetIndexMode()
00103         {
00104                 switch (mode)
00105                 {
00106                 case fogLinear: return 0;
00107                 case fogExponential: return 1;
00108                 case fogExponential2: return 2;
00109                 default: return -1;
00110                 }
00111         }
00112 
00113         void SetIndexMode(int index)
00114         {
00115                 FogMode listMode[]={fogLinear,fogExponential,fogExponential2};
00116                 mode = listMode[index];
00117         }
00118 };
00119 
00120 #endif

Generated on Fri Aug 20 19:19:44 2004 for 3d Controls by doxygen 1.3.6