From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- .../nel/driver__opengl__light_8cpp-source.html | 235 +++++++++++++++++++++ 1 file changed, 235 insertions(+) create mode 100644 docs/doxygen/nel/driver__opengl__light_8cpp-source.html (limited to 'docs/doxygen/nel/driver__opengl__light_8cpp-source.html') diff --git a/docs/doxygen/nel/driver__opengl__light_8cpp-source.html b/docs/doxygen/nel/driver__opengl__light_8cpp-source.html new file mode 100644 index 00000000..685a43c7 --- /dev/null +++ b/docs/doxygen/nel/driver__opengl__light_8cpp-source.html @@ -0,0 +1,235 @@ + + + + nevrax.org : docs + + + + + + + + + + + + + + +
# Home   # nevrax.com   
+ + + + +
Nevrax
+ + + + + + + + + + +
+ + +
+ Nevrax.org
+ + + + + + + +
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
+
+ + +
+ + +
+Docs + +
+  + + + + + +
Documentation 
+ +
+Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  
+

driver_opengl_light.cpp

Go to the documentation of this file.
00001 
+00007 /* Copyright, 2000 Nevrax Ltd.
+00008  *
+00009  * This file is part of NEVRAX NEL.
+00010  * NEVRAX NEL is free software; you can redistribute it and/or modify
+00011  * it under the terms of the GNU General Public License as published by
+00012  * the Free Software Foundation; either version 2, or (at your option)
+00013  * any later version.
+00014 
+00015  * NEVRAX NEL is distributed in the hope that it will be useful, but
+00016  * WITHOUT ANY WARRANTY; without even the implied warranty of
+00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+00018  * General Public License for more details.
+00019 
+00020  * You should have received a copy of the GNU General Public License
+00021  * along with NEVRAX NEL; see the file COPYING. If not, write to the
+00022  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+00023  * MA 02111-1307, USA.
+00024  */
+00025 
+00026 #include "stdopengl.h"
+00027 
+00028 #include "3d/light.h"
+00029 
+00030 namespace NL3D 
+00031 {
+00032 
+00033 
+00034 // ***************************************************************************
+00035 uint    CDriverGL::getMaxLight () const
+00036 {
+00037         // return min(maxLight supported by openGL, MaxLight=8).
+00038         return _MaxDriverLight;
+00039 }
+00040 
+00041 // ***************************************************************************
+00042 
+00043 void    CDriverGL::setLight (uint8 num, const CLight& light)
+00044 {
+00045         // Check light count is good
+00046 //      nlassert (num<_MaxDriverLight);
+00047         
+00048         // Set the light
+00049         if (num<_MaxDriverLight)
+00050         {
+00051                 // GL light number
+00052                 GLenum lightNum=(GLenum)(GL_LIGHT0+num);
+00053 
+00054                 // Get light mode
+00055                 CLight::TLightMode mode=light.getMode ();
+00056 
+00057                 // Copy the mode
+00058                 _LightMode[num]=mode;
+00059 
+00060                 // Set the ambiant color
+00061                 GLfloat colorGL[4];
+00062                 CRGBA colorNeL=light.getAmbiant ();
+00063                 colorGL[0]=(float)colorNeL.R/255.f;
+00064                 colorGL[1]=(float)colorNeL.G/255.f;
+00065                 colorGL[2]=(float)colorNeL.B/255.f;
+00066                 colorGL[3]=1.f;
+00067                 glLightfv (lightNum, GL_AMBIENT, colorGL);
+00068 
+00069                 // Set the diffuse color
+00070                 colorNeL=light.getDiffuse ();
+00071                 colorGL[0]=(float)colorNeL.R/255.f;
+00072                 colorGL[1]=(float)colorNeL.G/255.f;
+00073                 colorGL[2]=(float)colorNeL.B/255.f;
+00074                 colorGL[3]=1.f;
+00075                 glLightfv (lightNum, GL_DIFFUSE, colorGL);
+00076 
+00077                 // Set the specular color
+00078                 colorNeL=light.getSpecular ();
+00079                 colorGL[0]=(float)colorNeL.R/255.f;
+00080                 colorGL[1]=(float)colorNeL.G/255.f;
+00081                 colorGL[2]=(float)colorNeL.B/255.f;
+00082                 colorGL[3]=1.f;
+00083                 glLightfv (lightNum, GL_SPECULAR, colorGL);
+00084 
+00085                 // Set light attenuation
+00086                 glLightf (lightNum, GL_CONSTANT_ATTENUATION, light.getConstantAttenuation());
+00087                 glLightf (lightNum, GL_LINEAR_ATTENUATION, light.getLinearAttenuation());
+00088                 glLightf (lightNum, GL_QUADRATIC_ATTENUATION, light.getQuadraticAttenuation());
+00089 
+00090                 // Set the position
+00091                 if ((mode==CLight::DirectionalLight)||(mode==CLight::SpotLight))
+00092                 {
+00093                         // Get the direction of the light
+00094                         _WorldLightDirection[num]=light.getDirection ();
+00095                 }
+00096 
+00097                 if (mode!=CLight::DirectionalLight)
+00098                 {
+00099                         // Get the position of the light
+00100                         _WorldLightPos[num]=light.getPosition ();
+00101                 }
+00102 
+00103                 if (mode==CLight::SpotLight)
+00104                 {
+00105                         // Get the exponent of the spot
+00106                         float exponent=light.getExponent ();
+00107 
+00108                         // Set it
+00109                         glLightf (lightNum, GL_SPOT_EXPONENT, exponent);
+00110 
+00111                         // Get the cutoff of the spot
+00112                         float cutoff=180.f*(light.getCutoff ()/(float)NLMISC::Pi);
+00113 
+00114                         // Set it
+00115                         glLightf (lightNum, GL_SPOT_CUTOFF, cutoff);
+00116                 }
+00117                 else
+00118                 {
+00119                         // Disactive spot properties
+00120                         glLighti (lightNum, GL_SPOT_CUTOFF, 180);
+00121                         glLighti (lightNum, GL_SPOT_EXPONENT, 0);
+00122                 }
+00123 
+00124                 _ViewMatrixSetupDirty=true;
+00125         }
+00126 }
+00127 
+00128 // ***************************************************************************
+00129 
+00130 void    CDriverGL::enableLight (uint8 num, bool enable)
+00131 {
+00132         // Check light count is good
+00133 //      nlassert (num<_MaxDriverLight);
+00134 
+00135         // Enable glLight
+00136         if (num<_MaxDriverLight)
+00137         {
+00138                 // Enable the light
+00139                 _LightEnable[num]=enable;
+00140 
+00141                 // Enable GL
+00142                 if (enable)
+00143                         glEnable ((GLenum)(GL_LIGHT0+num));
+00144                 else
+00145                         glDisable ((GLenum)(GL_LIGHT0+num));
+00146         }
+00147 }
+00148 
+00149 // ***************************************************************************
+00150 
+00151 void    CDriverGL::setAmbientColor (CRGBA color)
+00152 {
+00153         // Gl array
+00154         GLfloat array[4];
+00155         array[0]=(float)color.R/255.f;
+00156         array[1]=(float)color.G/255.f;
+00157         array[2]=(float)color.B/255.f;
+00158         array[3]=1.f;
+00159 
+00160         // Set the color
+00161         glLightModelfv (GL_LIGHT_MODEL_AMBIENT, array);
+00162 }
+00163 
+00164 // ***************************************************************************
+00165 
+00166 } // NL3D
+
+ + +
                                                                                                                                                                    +
+ + -- cgit v1.2.1