Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members  

WP_GLState.h

Go to the documentation of this file.
00001 /* Copyright (C) 2001 W.P. van Paassen - peter@paassen.tmfweb.nl
00002 
00003    This program is free software; you can redistribute it and/or modify it under
00004    the terms of the GNU General Public License as published by the Free
00005    Software Foundation; either version 2 of the License, or (at your
00006    option) any later version.
00007 
00008    This program is distributed in the hope that it will be useful, but WITHOUT
00009    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00010    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00011    for more details.
00012 
00013    You should have received a copy of the GNU General Public License
00014    along with this program; see the file COPYING.  If not, write to the Free
00015    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
00016 
00017 #ifndef WP_GLSTATE_H
00018 #define WP_GLSTATE_H
00019 
00020 #include "GL/gl.h"
00021 #include "WP_Def.h"
00022 
00023 namespace WPCG
00024 {
00025 
00044 class WP_GLState
00045 {
00046 public:
00047         ~WP_GLState(){};
00048 
00053         static WP_GLState* getInstance()
00054         {       if (!_instance)
00055                         _instance = new WP_GLState();
00056                 return _instance;
00057         }
00058 
00062         void enableFog()
00063           {
00064             if (!fog)
00065               {
00066                 glEnable(GL_FOG);
00067                 fog = true;
00068               }
00069           }
00070 
00074         void disableFog()
00075           {
00076             if (fog)
00077               {
00078                 glDisable(GL_FOG);
00079                 fog = false;
00080               }
00081           }
00082 
00086         void enableLighting()
00087         {
00088                 if (!lighting)
00089                 {
00090                         glEnable(GL_LIGHTING);
00091                         lighting = true;
00092                 }
00093 
00094         }
00095 
00099         void disableLighting()
00100         {
00101                 if (lighting)
00102                 {
00103                         glDisable(GL_LIGHTING);
00104                         lighting = false;
00105                 }
00106         }
00107 
00111         void enableDepthTest()
00112         {
00113                 if (!depthTest)
00114                 {
00115                         glEnable(GL_DEPTH_TEST);
00116                         depthTest = true;
00117                 }
00118         }
00119 
00123         void disableDepthTest()
00124         {
00125                 if (depthTest)
00126                 {
00127                         glDisable(GL_DEPTH_TEST);
00128                         depthTest = false;
00129                 }
00130         }
00131 
00135         void enableCulling()
00136         {
00137                 if (!culling)
00138                 {
00139                         glEnable(GL_CULL_FACE);
00140                         culling = true;
00141                 }
00142         }
00143 
00147         void disableCulling()
00148         {
00149                 if (culling)
00150                 {
00151                         glDisable(GL_CULL_FACE);
00152                         culling = false;
00153                 }
00154         }
00155 
00159         void enableNormalize()
00160         {
00161                 if (!normalize)
00162                 {
00163                         glEnable(GL_NORMALIZE);
00164                         normalize = true;
00165                 }
00166         }
00167 
00171         void disableNormalize()
00172         {
00173                 if (normalize)
00174                 {
00175                         glDisable(GL_NORMALIZE);
00176                         normalize = false;
00177                 }
00178         }
00179 
00183         void enableLight0()
00184         {
00185                 if (!light0)
00186                 {
00187                         glEnable(GL_LIGHT0);
00188                         light0 = true;
00189                 }
00190         }
00191 
00195         void disableLight0()
00196         {
00197                 if (light0)
00198                 {
00199                         glDisable(GL_LIGHT0);
00200                         light0 = false;
00201                 }
00202         }
00203 
00207         void enableLight1()
00208         {
00209                 if (!light1)
00210                 {
00211                         glEnable(GL_LIGHT1);
00212                         light1 = true;
00213                 }
00214         }
00215 
00219         void disableLight1()
00220         {
00221                 if (light1)
00222                 {
00223                         glDisable(GL_LIGHT1);
00224                         light1 = false;
00225                 }
00226         }
00227 
00231         void enableLight2()
00232         {
00233                 if (!light2)
00234                 {
00235                         glEnable(GL_LIGHT2);
00236                         light2 = true;
00237                 }
00238         }
00239 
00243         void disableLight2()
00244         {
00245                 if (light2)
00246                 {
00247                         glDisable(GL_LIGHT2);
00248                         light2 = false;
00249                 }
00250         }
00251 
00255         void enableLight3()
00256         {
00257                 if (!light3)
00258                 {
00259                         glEnable(GL_LIGHT3);
00260                         light3 = true;
00261                 }
00262         }
00263 
00267         void disableLight3()
00268         {
00269                 if (light3)
00270                 {
00271                         glDisable(GL_LIGHT3);
00272                         light3 = false;
00273                 }
00274         }
00275 
00279         void enableLight4()
00280         {
00281                 if (!light4)
00282                 {
00283                         glEnable(GL_LIGHT4);
00284                         light4 = true;
00285                 }
00286         }
00287 
00291         void disableLight4()
00292         {
00293                 if (light4)
00294                 {
00295                         glDisable(GL_LIGHT4);
00296                         light4 = false;
00297                 }
00298         }
00299 
00303         void enableLight5()
00304         {
00305                 if (!light5)
00306                 {
00307                         glEnable(GL_LIGHT5);
00308                         light5 = true;
00309                 }
00310         }
00311 
00315         void disableLight5()
00316         {
00317                 if (light5)
00318                 {
00319                         glDisable(GL_LIGHT5);
00320                         light5 = false;
00321                 }
00322         }
00323 
00327         void enableLight6()
00328         {
00329                 if (!light6)
00330                 {
00331                         glEnable(GL_LIGHT6);
00332                         light6 = true;
00333                 }
00334         }
00335 
00339         void disableLight6()
00340         {
00341                 if (light6)
00342                 {
00343                         glDisable(GL_LIGHT6);
00344                         light6 = false;
00345                 }
00346         }
00347 
00351         void enableLight7()
00352         {
00353                 if (!light7)
00354                 {
00355                         glEnable(GL_LIGHT7);
00356                         light7 = true;
00357                 }
00358         }
00359 
00363         void disableLight7()
00364         {
00365                 if (light7)
00366                 {
00367                         glDisable(GL_LIGHT7);
00368                         light7 = false;
00369                 }
00370         }
00371 
00375         void enableTexture2D()
00376         {
00377                 if (!texture2D)
00378                 {
00379                         glEnable(GL_TEXTURE_2D);
00380                         texture2D = true;
00381                 }
00382         }
00383 
00387         void disableTexture2D()
00388         {
00389                 if (texture2D)
00390                 {
00391                         glDisable(GL_TEXTURE_2D);
00392                         texture2D = false;
00393                 }
00394         }
00395 
00399         void enableBlending()
00400         {
00401                 if (!blending)
00402                 {
00403                         glEnable(GL_BLEND);
00404                         blending = true;
00405                 }
00406         }
00407 
00411         void disableBlending()
00412         {
00413                 if (blending)
00414                 {
00415                         glDisable(GL_BLEND);
00416                         blending = false;
00417                 }
00418         }
00419 
00423         void enablePolygonSmooth()
00424         {
00425                 if (!polygonSmooth)
00426                 {
00427                         glEnable(GL_POLYGON_SMOOTH);
00428                         polygonSmooth = true;
00429                 }
00430         }
00431 
00435         void disablePolygonSmooth()
00436         {
00437                 if (polygonSmooth)
00438                 {
00439                         glDisable(GL_POLYGON_SMOOTH);
00440                         polygonSmooth = false;
00441                 }
00442         }
00443 
00447         void modelview()
00448           {
00449             if (!_modelview)
00450               {
00451                 glMatrixMode(GL_MODELVIEW);
00452                 _modelview = true;
00453                 _projection = false;
00454               }
00455           }
00456 
00460         void projection()
00461           {
00462             if (!_projection)
00463               {
00464                 glMatrixMode(GL_PROJECTION);
00465                 _projection = true;
00466                 _modelview = false;
00467               }
00468           }
00469 
00473         void selection_mode()
00474           {
00475             if (!_selection)
00476               {
00477                 _selection = true;
00478                 glRenderMode(GL_SELECT);
00479               }
00480           }
00481         
00486         int render_mode()
00487           {
00488             if (_selection)
00489               {
00490                 _selection = false;
00491                 return glRenderMode(GL_RENDER);
00492               }
00493             return 0;
00494           }
00495 
00500         void enableLighti(GLuint number);
00501 
00506         void disableLighti(GLuint number);
00507 
00511         static WP_GLState* _instance;
00512 
00516         bool lighting;
00517 
00521         bool culling;
00522 
00526         bool texture2D;
00527 
00531         bool blending;
00532 
00536         bool depthTest;
00537 
00541         bool normalize;
00542 
00546         bool light0;
00547         
00551         bool light1;
00552 
00556         bool light2;
00557         
00561         bool light3;
00562         
00566         bool light4;
00567         
00571         bool light5;
00572 
00576         bool light6;
00577         
00581         bool light7;
00582 
00586         bool polygonSmooth;
00587 
00591         bool fog;
00592 
00596         bool _modelview;
00597         
00601         bool _projection;
00602 
00606         bool _selection;
00607 
00608  private:
00609         WP_GLState();
00610 };
00611 }
00612 #endif
00613 
00614 
00615 

Generated on Tue Jan 28 20:26:33 2003 by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002