Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r51242 - in sandbox-branches/andreo/guigl: boost/guigl boost/guigl/platform/impl libs/guigl/example
From: andreytorba_at_[hidden]
Date: 2009-02-13 18:14:51


Author: andreo
Date: 2009-02-13 18:14:50 EST (Fri, 13 Feb 2009)
New Revision: 51242
URL: http://svn.boost.org/trac/boost/changeset/51242

Log:
light
Text files modified:
   sandbox-branches/andreo/guigl/boost/guigl/gl.hpp | 81 +++++++++++++++++++++++++++
   sandbox-branches/andreo/guigl/boost/guigl/platform/impl/light.hpp | 116 ++++++++++++++++++++++++++-------------
   sandbox-branches/andreo/guigl/libs/guigl/example/two_spheres.cpp | 45 ++++++++++-----
   3 files changed, 189 insertions(+), 53 deletions(-)

Modified: sandbox-branches/andreo/guigl/boost/guigl/gl.hpp
==============================================================================
--- sandbox-branches/andreo/guigl/boost/guigl/gl.hpp (original)
+++ sandbox-branches/andreo/guigl/boost/guigl/gl.hpp 2009-02-13 18:14:50 EST (Fri, 13 Feb 2009)
@@ -112,6 +112,87 @@
     void translate_z(T z);
 
     //////////////////////////////////////////////////////////////////////////
+ template<class T>
+ inline void light(GLenum i_light, GLenum pname, T param);
+
+ template<class T>
+ inline void light(GLenum i_light, GLenum pname, T const* param);
+
+ template<class T>
+ inline void light_position(GLenum i_light, T x, T y, T z, T w);
+
+ template<class T>
+ void light_constant_attenuation(GLenum i_light, T value);
+
+ template<class T>
+ void light_linear_attenuation(GLenum i_light, T value);
+
+ template<class T>
+ void light_quadratic_attenuation(GLenum i_light, T value);
+
+ template<class T>
+ void light_spot_cutoff(GLenum i_light, T value);
+
+ template<class T>
+ void light_spot_exponent(GLenum i_light, T value);
+
+ template<class T>
+ void light_spot_direction(GLenum i_light, T x, T y, T z);
+
+ template<class T>
+ void light_specular(GLenum i_light, T r, T g, T b, T a);
+
+ template<class T>
+ void light_diffuse(GLenum i_light, T r, T g, T b, T a);
+
+ template<class T>
+ void light_ambient(GLenum i_light, T r, T g, T b, T a);
+
+ //////////////////////////////////////////////////////////////////////////
+ class light_setup : boost::noncopyable
+ {
+ private:
+ GLenum m_light;
+ light_setup(GLenum i_light):m_light(i_light){};
+
+ friend light_setup light(GLenum i_light);
+
+ public:
+ template<class T>
+ light_setup& position(T x, T y, T z, T w);
+
+ template<class T>
+ light_setup& constant_attenuation(T value);
+
+ template<class T>
+ light_setup& linear_attenuation(T value);
+
+ template<class T>
+ light_setup& quadratic_attenuation(T value);
+
+ template<class T>
+ light_setup& spot_cutoff(T value);
+
+ template<class T>
+ light_setup& spot_exponent(T value);
+
+ template<class T>
+ light_setup& spot_direction(T x, T y, T z);
+
+ template<class T>
+ light_setup& specular(T r, T g, T b, T a);
+
+ template<class T>
+ light_setup& diffuse(T r, T g, T b, T a);
+
+ template<class T>
+ light_setup& ambient(T r, T g, T b, T a);
+ };
+
+ light_setup light(GLenum i_light);
+
+
+ //////////////////////////////////////////////////////////////////////////
     void wired_cube(GLdouble size);
     void solid_cube(GLdouble size);
     void wire_sphere(GLdouble radius, GLint slices, GLint stacks);

Modified: sandbox-branches/andreo/guigl/boost/guigl/platform/impl/light.hpp
==============================================================================
--- sandbox-branches/andreo/guigl/boost/guigl/platform/impl/light.hpp (original)
+++ sandbox-branches/andreo/guigl/boost/guigl/platform/impl/light.hpp 2009-02-13 18:14:50 EST (Fri, 13 Feb 2009)
@@ -4,9 +4,6 @@
 namespace boost{ namespace guigl { namespace gl {
 
     //////////////////////////////////////////////////////////////////////////
- template<class T>
- inline void light(GLenum i_light, GLenum pname, T param);
-
     template<>
     inline void light<GLfloat>(GLenum i_light, GLenum pname, GLfloat param)
     {
@@ -20,9 +17,6 @@
     }
 
     //////////////////////////////////////////////////////////////////////////
- template<class T>
- inline void light(GLenum i_light, GLenum pname, T const* param);
-
     template<>
     inline void light<GLfloat>(GLenum i_light, GLenum pname, GLfloat const* params)
     {
@@ -36,9 +30,6 @@
     }
 
     //////////////////////////////////////////////////////////////////////////
- template<class T>
- inline void light_position(GLenum i_light, T x, T y, T z, T w);
-
     template<>
     inline void light_position<GLfloat>(
         GLenum i_light,
@@ -58,25 +49,19 @@
     }
 
     //////////////////////////////////////////////////////////////////////////
- template<class T>
- void light_constant_ambient(GLenum i_light, T value);
-
     template<>
- inline void light_constant_ambient<GLfloat>(GLenum i_light, GLfloat value)
+ inline void light_constant_attenuation<GLfloat>(GLenum i_light, GLfloat value)
     {
         light(i_light, GL_CONSTANT_ATTENUATION, value);
     }
 
     template<>
- inline void light_constant_ambient<GLint>(GLenum i_light, GLint value)
+ inline void light_constant_attenuation<GLint>(GLenum i_light, GLint value)
     {
         light(i_light, GL_CONSTANT_ATTENUATION, value);
     }
 
     //////////////////////////////////////////////////////////////////////////
- template<class T>
- void light_linear_attenuation(GLenum i_light, T value);
-
     template<>
     inline void light_linear_attenuation<GLfloat>(GLenum i_light, GLfloat value)
     {
@@ -90,9 +75,6 @@
     }
 
     //////////////////////////////////////////////////////////////////////////
- template<class T>
- void light_quadratic_attenuation(GLenum i_light, T value);
-
     template<>
     inline void light_quadratic_attenuation<GLfloat>(GLenum i_light, GLfloat value)
     {
@@ -106,9 +88,6 @@
     }
 
     //////////////////////////////////////////////////////////////////////////
- template<class T>
- void light_spot_cutoff(GLenum i_light, T value);
-
     template<>
     inline void light_spot_cutoff<GLfloat>(GLenum i_light, GLfloat value)
     {
@@ -122,9 +101,6 @@
     }
 
     //////////////////////////////////////////////////////////////////////////
- template<class T>
- void light_spot_exponent(GLenum i_light, T value);
-
     template<>
     inline void light_spot_exponent<GLfloat>(GLenum i_light, GLfloat value)
     {
@@ -138,9 +114,6 @@
     }
 
     //////////////////////////////////////////////////////////////////////////
- template<class T>
- void light_spot_direction(GLenum i_light, T x, T y, T z);
-
     template<>
     inline void light_spot_direction<GLfloat>(GLenum i_light, GLfloat x, GLfloat y, GLfloat z)
     {
@@ -156,9 +129,6 @@
     }
 
     //////////////////////////////////////////////////////////////////////////
- template<class T>
- void light_specular(GLenum i_light, T r, T g, T b, T a);
-
     template<>
     inline void light_specular<GLfloat>(GLenum i_light,
         GLfloat r, GLfloat g, GLfloat b, GLfloat a)
@@ -176,9 +146,6 @@
     }
 
     //////////////////////////////////////////////////////////////////////////
- template<class T>
- void light_diffuse(GLenum i_light, T r, T g, T b, T a);
-
     template<>
     inline void light_diffuse<GLfloat>(GLenum i_light,
         GLfloat r, GLfloat g, GLfloat b, GLfloat a)
@@ -196,9 +163,6 @@
     }
 
     //////////////////////////////////////////////////////////////////////////
- template<class T>
- void light_ambient(GLenum i_light, T r, T g, T b, T a);
-
     template<>
     inline void light_ambient<GLfloat>(GLenum i_light,
         GLfloat r, GLfloat g, GLfloat b, GLfloat a)
@@ -215,6 +179,82 @@
         light(i_light, GL_AMBIENT, ambient_color);
     }
 
+ //////////////////////////////////////////////////////////////////////////
+ template<class T>
+ inline light_setup& light_setup::position(T x, T y, T z, T w)
+ {
+ light_position(m_light, x, y, z, w);
+ return *this;
+ }
+
+ template<class T>
+ inline light_setup& light_setup::constant_attenuation(T value)
+ {
+ light_constant_attenuation(m_light, value);
+ return *this;
+ }
+
+ template<class T>
+ inline light_setup& light_setup::linear_attenuation(T value)
+ {
+ light_linear_attenuation(m_light, value);
+ return *this;
+ }
+
+ template<class T>
+ inline light_setup& light_setup::quadratic_attenuation(T value)
+ {
+ light_quadratic_attenuation(m_light, value);
+ return *this;
+ }
+
+ template<class T>
+ inline light_setup& light_setup::spot_cutoff(T value)
+ {
+ light_spot_cutoff(m_light, value);
+ return *this;
+ }
+
+ template<class T>
+ inline light_setup& light_setup::spot_exponent(T value)
+ {
+ light_spot_exponent(m_light, value);
+ return *this;
+ }
+
+ template<class T>
+ inline light_setup& light_setup::spot_direction(T x, T y, T z)
+ {
+ light_spot_direction(m_light, x, y, z);
+ return *this;
+ }
+
+ template<class T>
+ inline light_setup& light_setup::specular(T r, T g, T b, T a)
+ {
+ light_specular(m_light, r, g, b, a);
+ return *this;
+ }
+
+ template<class T>
+ inline light_setup& light_setup::diffuse(T r, T g, T b, T a)
+ {
+ light_diffuse(m_light, r, g, b, a);
+ return *this;
+ }
+
+ template<class T>
+ inline light_setup& light_setup::ambient(T r, T g, T b, T a)
+ {
+ light_ambient(m_light, r, g, b, a);
+ return *this;
+ }
+
+ inline light_setup light(GLenum i_light)
+ {
+ return light_setup(i_light);
+ }
+
 }}}
 
 #endif BOOST__GUIGL__GL__LIGHT_HPP

Modified: sandbox-branches/andreo/guigl/libs/guigl/example/two_spheres.cpp
==============================================================================
--- sandbox-branches/andreo/guigl/libs/guigl/example/two_spheres.cpp (original)
+++ sandbox-branches/andreo/guigl/libs/guigl/example/two_spheres.cpp 2009-02-13 18:14:50 EST (Fri, 13 Feb 2009)
@@ -30,27 +30,42 @@
     //glEnable(GL_COLOR_MATERIAL);
     glEnable(GL_LIGHTING);
     glEnable(GL_LIGHT1);
+ glEnable(GL_LIGHT2);
 
- light_ambient(GL_LIGHT1, 0.6f, 0.6f, 0.6f, 1.0f);
- light_diffuse(GL_LIGHT1, 1.0f, 1.0f, 1.0f, 1.0f);
- light_specular(GL_LIGHT1, 1.0f, 1.0f, 1.0f, 1.0f);
- light_position(GL_LIGHT1, 100, 40, 40, 1);
- light_spot_direction(GL_LIGHT1, -100, -40, -40);
- light_constant_ambient(GL_LIGHT1, 1.5f);
- light_linear_attenuation(GL_LIGHT1, 0.5f);
- light_quadratic_attenuation(GL_LIGHT1, 0.2f);
- light_spot_cutoff(GL_LIGHT1, 180.0f);
- light_spot_exponent(GL_LIGHT1, 2.0f);
+ light(GL_LIGHT1)
+ .ambient(0.3f, 0.3f, 0.3f, 1.0f)
+ .diffuse(1.0f, 1.0f, 1.0f, 1.0f)
+ .specular(1.0f, 1.0f, 1.0f, 1.0f)
+ .spot_direction(100, 100, 100)
+ .position(-100, -100, -100, 0)
+ .constant_attenuation(1.5f)
+ .linear_attenuation(0.5f)
+ .quadratic_attenuation(0.2f)
+ .spot_cutoff(180.0f)
+ .spot_exponent(2.0f);
+
+ light(GL_LIGHT2)
+ .ambient(0.3f, 0.3f, 0.3f, 1.0f)
+ .diffuse(1.0f, 1.0f, 1.0f, 1.0f)
+ .specular(1.0f, 0.0f, 1.0f, 1.0f)
+ .spot_direction(-100, 100, 100)
+ .position(100, -100, -100, 0)
+ .constant_attenuation(1.2f)
+ .linear_attenuation(0.5f)
+ .quadratic_attenuation(0.2f)
+ .spot_cutoff(180.0f)
+ .spot_exponent(2.0f);
 
- solid_sphere(50, 10, 10);
+ solid_sphere(50, 50, 50);
     glLoadIdentity();
- translate(50.f, 50.f, 50.f);
- wire_sphere(20, 20, 20);
+ translate_x(50.f);
+ boost::guigl::gl::color(1.0, 1.0, 0.0, 0.5);
+ solid_sphere(50, 100, 100);
 
     {
         scoped_matrix m;
- translate_x(-70.0f);
- wire_teapot(20);
+ translate_x(-100.0f);
+ solid_teapot(20);
     }
 }
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk