|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r51351 - in sandbox-branches/andreo/guigl: boost/guigl boost/guigl/platform/impl libs/guigl/example
From: andreytorba_at_[hidden]
Date: 2009-02-20 13:39:35
Author: andreo
Date: 2009-02-20 13:39:34 EST (Fri, 20 Feb 2009)
New Revision: 51351
URL: http://svn.boost.org/trac/boost/changeset/51351
Log:
add material
Text files modified:
sandbox-branches/andreo/guigl/boost/guigl/gl.hpp | 66 +++++++-
sandbox-branches/andreo/guigl/boost/guigl/platform/impl/color.hpp | 8 +
sandbox-branches/andreo/guigl/boost/guigl/platform/impl/glut.hpp | 8 +
sandbox-branches/andreo/guigl/boost/guigl/platform/impl/light.hpp | 28 ++-
sandbox-branches/andreo/guigl/boost/guigl/platform/impl/material.hpp | 283 ++++++++++++---------------------------
sandbox-branches/andreo/guigl/boost/guigl/platform/impl/rect.hpp | 8 +
sandbox-branches/andreo/guigl/boost/guigl/platform/impl/transform.hpp | 8 +
sandbox-branches/andreo/guigl/boost/guigl/platform/impl/vertex.hpp | 8 +
sandbox-branches/andreo/guigl/libs/guigl/example/two_spheres.cpp | 77 +++++++++-
sandbox-branches/andreo/guigl/libs/guigl/example/window_example.cpp | 16 ++
10 files changed, 276 insertions(+), 234 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-20 13:39:34 EST (Fri, 20 Feb 2009)
@@ -1,3 +1,11 @@
+/*=================================---------------------------------------------
+Copyright 2009 Stjepan Rajko, Torba Andrey
+
+Distributed under the Boost Software License, Version 1.0.
+(See accompanying file LICENSE_1_0.txt or copy at
+http://www.boost.org/LICENSE_1_0.txt)
+-----------------------------------------------===============================*/
+
#ifndef BOOST__GUIGL__GL_HPP
#define BOOST__GUIGL__GL_HPP
@@ -153,7 +161,7 @@
void light_ambient(GLenum i_light, T r, T g, T b, T a);
//////////////////////////////////////////////////////////////////////////
- class light_setup : boost::noncopyable
+ class light_setup
{
private:
GLenum m_light;
@@ -163,34 +171,34 @@
public:
template<class T>
- light_setup& position(T x, T y, T z, T w);
+ light_setup const& position(T x, T y, T z, T w) const;
template<class T>
- light_setup& constant_attenuation(T value);
+ light_setup const& constant_attenuation(T value) const;
template<class T>
- light_setup& linear_attenuation(T value);
+ light_setup const& linear_attenuation(T value) const;
template<class T>
- light_setup& quadratic_attenuation(T value);
+ light_setup const& quadratic_attenuation(T value) const;
template<class T>
- light_setup& spot_cutoff(T value);
+ light_setup const& spot_cutoff(T value) const;
template<class T>
- light_setup& spot_exponent(T value);
+ light_setup const& spot_exponent(T value) const;
template<class T>
- light_setup& spot_direction(T x, T y, T z);
+ light_setup const& spot_direction(T x, T y, T z) const;
template<class T>
- light_setup& specular(T r, T g, T b, T a);
+ light_setup const& specular(T r, T g, T b, T a) const;
template<class T>
- light_setup& diffuse(T r, T g, T b, T a);
+ light_setup const& diffuse(T r, T g, T b, T a) const;
template<class T>
- light_setup& ambient(T r, T g, T b, T a);
+ light_setup const& ambient(T r, T g, T b, T a) const;
};
light_setup light(GLenum i_light);
@@ -203,16 +211,46 @@
void material(GLenum face, GLenum pname, T const* param);
template<class T>
- void material_shininess(GLenum face, T value);
+ void material_ambient(GLenum face, T r, T g, T b, T a);
+
+ template<class T>
+ void material_diffuse(GLenum face, T r, T g, T b, T a);
template<class T>
void material_specular(GLenum face, T r, T g, T b, T a);
template<class T>
- void material_diffuse(GLenum face, T r, T g, T b, T a);
+ void material_shininess(GLenum face, T value);
template<class T>
- void material_ambient(GLenum face, T r, T g, T b, T a);
+ void material_emission(GLenum face, T r, T g, T b, T a);
+
+ class material_setup
+ {
+ private:
+ GLenum m_face;
+ material_setup(GLenum face):m_face(face){};
+
+ friend material_setup material(GLenum i_light);
+
+ public:
+ template<class T>
+ material_setup const& ambient(T r, T g, T b, T a) const;
+
+ template<class T>
+ material_setup const& diffuse(T r, T g, T b, T a) const;
+
+ template<class T>
+ material_setup const& specular(T r, T g, T b, T a) const;
+
+ template<class T>
+ material_setup const& shininess(T value) const;
+
+ template<class T>
+ material_setup const& emission(T r, T g, T b, T a) const;
+ };
+
+ material_setup material(GLenum face);
//////////////////////////////////////////////////////////////////////////
void wired_cube(GLdouble size);
Modified: sandbox-branches/andreo/guigl/boost/guigl/platform/impl/color.hpp
==============================================================================
--- sandbox-branches/andreo/guigl/boost/guigl/platform/impl/color.hpp (original)
+++ sandbox-branches/andreo/guigl/boost/guigl/platform/impl/color.hpp 2009-02-20 13:39:34 EST (Fri, 20 Feb 2009)
@@ -1,3 +1,11 @@
+/*=================================---------------------------------------------
+Copyright 2009 Stjepan Rajko, Torba Andrey
+
+Distributed under the Boost Software License, Version 1.0.
+(See accompanying file LICENSE_1_0.txt or copy at
+http://www.boost.org/LICENSE_1_0.txt)
+-----------------------------------------------===============================*/
+
#ifndef BOOST__GUIGL__GL__COLOR_HPP
#define BOOST__GUIGL__GL__COLOR_HPP
Modified: sandbox-branches/andreo/guigl/boost/guigl/platform/impl/glut.hpp
==============================================================================
--- sandbox-branches/andreo/guigl/boost/guigl/platform/impl/glut.hpp (original)
+++ sandbox-branches/andreo/guigl/boost/guigl/platform/impl/glut.hpp 2009-02-20 13:39:34 EST (Fri, 20 Feb 2009)
@@ -1,3 +1,11 @@
+/*=================================---------------------------------------------
+Copyright 2009 Stjepan Rajko, Torba Andrey
+
+Distributed under the Boost Software License, Version 1.0.
+(See accompanying file LICENSE_1_0.txt or copy at
+http://www.boost.org/LICENSE_1_0.txt)
+-----------------------------------------------===============================*/
+
#ifndef BOOST__GUIGL__GL__GLUT_HPP
#define BOOST__GUIGL__GL__GLUT_HPP
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-20 13:39:34 EST (Fri, 20 Feb 2009)
@@ -1,3 +1,11 @@
+/*=================================---------------------------------------------
+Copyright 2009 Stjepan Rajko, Torba Andrey
+
+Distributed under the Boost Software License, Version 1.0.
+(See accompanying file LICENSE_1_0.txt or copy at
+http://www.boost.org/LICENSE_1_0.txt)
+-----------------------------------------------===============================*/
+
#ifndef BOOST__GUIGL__GL__LIGHT_HPP
#define BOOST__GUIGL__GL__LIGHT_HPP
@@ -185,70 +193,70 @@
//////////////////////////////////////////////////////////////////////////
template<class T>
- inline light_setup& light_setup::position(T x, T y, T z, T w)
+ inline light_setup const& light_setup::position(T x, T y, T z, T w) const
{
light_position(m_light, x, y, z, w);
return *this;
}
template<class T>
- inline light_setup& light_setup::constant_attenuation(T value)
+ inline light_setup const& light_setup::constant_attenuation(T value) const
{
light_constant_attenuation(m_light, value);
return *this;
}
template<class T>
- inline light_setup& light_setup::linear_attenuation(T value)
+ inline light_setup const& light_setup::linear_attenuation(T value) const
{
light_linear_attenuation(m_light, value);
return *this;
}
template<class T>
- inline light_setup& light_setup::quadratic_attenuation(T value)
+ inline light_setup const& light_setup::quadratic_attenuation(T value) const
{
light_quadratic_attenuation(m_light, value);
return *this;
}
template<class T>
- inline light_setup& light_setup::spot_cutoff(T value)
+ inline light_setup const& light_setup::spot_cutoff(T value) const
{
light_spot_cutoff(m_light, value);
return *this;
}
template<class T>
- inline light_setup& light_setup::spot_exponent(T value)
+ inline light_setup const& light_setup::spot_exponent(T value) const
{
light_spot_exponent(m_light, value);
return *this;
}
template<class T>
- inline light_setup& light_setup::spot_direction(T x, T y, T z)
+ inline light_setup const& light_setup::spot_direction(T x, T y, T z) const
{
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)
+ inline light_setup const& light_setup::specular(T r, T g, T b, T a) const
{
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)
+ inline light_setup const& light_setup::diffuse(T r, T g, T b, T a) const
{
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)
+ inline light_setup const& light_setup::ambient(T r, T g, T b, T a) const
{
light_ambient(m_light, r, g, b, a);
return *this;
Modified: sandbox-branches/andreo/guigl/boost/guigl/platform/impl/material.hpp
==============================================================================
--- sandbox-branches/andreo/guigl/boost/guigl/platform/impl/material.hpp (original)
+++ sandbox-branches/andreo/guigl/boost/guigl/platform/impl/material.hpp 2009-02-20 13:39:34 EST (Fri, 20 Feb 2009)
@@ -1,3 +1,11 @@
+/*=================================---------------------------------------------
+Copyright 2009 Stjepan Rajko, Torba Andrey
+
+Distributed under the Boost Software License, Version 1.0.
+(See accompanying file LICENSE_1_0.txt or copy at
+http://www.boost.org/LICENSE_1_0.txt)
+-----------------------------------------------===============================*/
+
#ifndef BOOST__GUIGL__GL__MATERIAL_HPP
#define BOOST__GUIGL__GL__MATERIAL_HPP
@@ -31,117 +39,37 @@
//////////////////////////////////////////////////////////////////////////
template<>
- inline void material_shininess<GLfloat>(GLenum face, GLfloat value)
+ inline void material_ambient<GLfloat>(GLenum face,
+ GLfloat r, GLfloat g, GLfloat b, GLfloat a)
{
- GLfloat const values[] = {value};
- material(face, GL_SHININESS, values);
+ GLfloat const ambient_color[] = {r, g, b, a};
+ material(face, GL_AMBIENT, ambient_color);
}
template<>
- inline void material_shininess<GLint>(GLenum face, GLint value)
+ inline void material_ambient<GLint>(GLenum face,
+ GLint r, GLint g, GLint b, GLint a)
{
- GLint const values[] = {value};
- material(face, GL_SHININESS, values);
+ GLint const ambient_color[] = {r, g, b, a};
+ material(face, GL_AMBIENT, ambient_color);
}
- ////////////////////////////////////////////////////////////////////////////
- //template<>
- //inline void light_position<GLfloat>(
- // GLenum i_light,
- // GLfloat x, GLfloat y, GLfloat z, GLfloat w)
- //{
- // GLfloat const position[] = {x, y, z, w};
- // light(i_light, GL_POSITION, position);
- //}
-
- //template<>
- //inline void light_position<GLint>(
- // GLenum i_light,
- // GLint x, GLint y, GLint z, GLint w)
- //{
- // GLint const position[] = {x, y, z, w};
- // light(i_light, GL_POSITION, position);
- //}
-
- ////////////////////////////////////////////////////////////////////////////
- //template<>
- //inline void light_constant_attenuation<GLfloat>(GLenum i_light, GLfloat value)
- //{
- // light(i_light, GL_CONSTANT_ATTENUATION, value);
- //}
-
- //template<>
- //inline void light_constant_attenuation<GLint>(GLenum i_light, GLint value)
- //{
- // light(i_light, GL_CONSTANT_ATTENUATION, value);
- //}
-
- ////////////////////////////////////////////////////////////////////////////
- //template<>
- //inline void light_linear_attenuation<GLfloat>(GLenum i_light, GLfloat value)
- //{
- // light(i_light, GL_LINEAR_ATTENUATION, value);
- //}
-
- //template<>
- //inline void light_linear_attenuation<GLint>(GLenum i_light, GLint value)
- //{
- // light(i_light, GL_LINEAR_ATTENUATION, value);
- //}
-
- ////////////////////////////////////////////////////////////////////////////
- //template<>
- //inline void light_quadratic_attenuation<GLfloat>(GLenum i_light, GLfloat value)
- //{
- // light(i_light, GL_QUADRATIC_ATTENUATION, value);
- //}
-
- //template<>
- //inline void light_quadratic_attenuation<GLint>(GLenum i_light, GLint value)
- //{
- // light(i_light, GL_QUADRATIC_ATTENUATION, value);
- //}
-
- ////////////////////////////////////////////////////////////////////////////
- //template<>
- //inline void light_spot_cutoff<GLfloat>(GLenum i_light, GLfloat value)
- //{
- // light(i_light, GL_SPOT_CUTOFF, value);
- //}
-
- //template<>
- //inline void light_spot_cutoff<GLint>(GLenum i_light, GLint value)
- //{
- // light(i_light, GL_SPOT_CUTOFF, value);
- //}
-
- ////////////////////////////////////////////////////////////////////////////
- //template<>
- //inline void light_spot_exponent<GLfloat>(GLenum i_light, GLfloat value)
- //{
- // light(i_light, GL_SPOT_EXPONENT, value);
- //}
-
- //template<>
- //inline void light_spot_exponent<GLint>(GLenum i_light, GLint value)
- //{
- // light(i_light, GL_SPOT_EXPONENT, value);
- //}
-
- ////////////////////////////////////////////////////////////////////////////
- //template<>
- //inline void light_spot_direction<GLfloat>(GLenum i_light, GLfloat x, GLfloat y, GLfloat z)
- //{
- // GLfloat const direction[] = {x, y, z};
- // light(i_light, GL_SPOT_DIRECTION, direction);
- //}
-
- //template<>
- //inline void light_spot_direction<GLint>(GLenum i_light, GLint x, GLint y, GLint z)
- //{
- // GLint const direction[] = {x, y, z};
- // light(i_light, GL_SPOT_DIRECTION, direction);
- //}
+ //////////////////////////////////////////////////////////////////////////
+ template<>
+ inline void material_diffuse<GLfloat>(GLenum face,
+ GLfloat r, GLfloat g, GLfloat b, GLfloat a)
+ {
+ GLfloat const diffuse_color[] = {r, g, b, a};
+ material(face, GL_DIFFUSE, diffuse_color);
+ }
+
+ template<>
+ inline void material_diffuse<GLint>(GLenum face,
+ GLint r, GLint g, GLint b, GLint a)
+ {
+ GLint const diffuse_color[] = {r, g, b, a};
+ material(face, GL_DIFFUSE, diffuse_color);
+ }
//////////////////////////////////////////////////////////////////////////
template<>
@@ -162,115 +90,78 @@
//////////////////////////////////////////////////////////////////////////
template<>
- inline void material_diffuse<GLfloat>(GLenum face,
- GLfloat r, GLfloat g, GLfloat b, GLfloat a)
+ inline void material_shininess<GLfloat>(GLenum face, GLfloat value)
{
- GLfloat const diffuse_color[] = {r, g, b, a};
- material(face, GL_DIFFUSE, diffuse_color);
+ GLfloat const values[] = {value};
+ material(face, GL_SHININESS, values);
}
template<>
- inline void material_diffuse<GLint>(GLenum face,
- GLint r, GLint g, GLint b, GLint a)
+ inline void material_shininess<GLint>(GLenum face, GLint value)
{
- GLint const diffuse_color[] = {r, g, b, a};
- material(face, GL_DIFFUSE, diffuse_color);
+ GLint const values[] = {value};
+ material(face, GL_SHININESS, values);
}
//////////////////////////////////////////////////////////////////////////
template<>
- inline void material_ambient<GLfloat>(GLenum face,
- GLfloat r, GLfloat g, GLfloat b, GLfloat a)
+ inline void material_emission<GLfloat>(GLenum face,
+ GLfloat r, GLfloat g, GLfloat b, GLfloat a)
{
- GLfloat const ambient_color[] = {r, g, b, a};
- material(face, GL_AMBIENT, ambient_color);
+ GLfloat const color[] = {r, g, b, a};
+ material(face, GL_EMISSION, color);
}
template<>
- inline void material_ambient<GLint>(GLenum face,
- GLint r, GLint g, GLint b, GLint a)
+ inline void material_emission<GLint>(GLenum face,
+ GLint r, GLint g, GLint b, GLint a)
{
- GLint const ambient_color[] = {r, g, b, a};
- material(face, GL_AMBIENT, ambient_color);
+ GLint const color[] = {r, g, b, a};
+ material(face, GL_EMISSION, color);
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ //////////////////////////////////////////////////////////////////////////
+ //////////////////////////////////////////////////////////////////////////
+ template<class T>
+ inline material_setup const& material_setup::ambient(T r, T g, T b, T a) const
+ {
+ material_ambient(m_face, r, g, b, a);
+ return *this;
+ }
+
+ template<class T>
+ inline material_setup const& material_setup::diffuse(T r, T g, T b, T a) const
+ {
+ material_diffuse(m_face, r, g, b, a);
+ return *this;
+ }
+
+ template<class T>
+ inline material_setup const& material_setup::specular(T r, T g, T b, T a) const
+ {
+ material_specular(m_face, r, g, b, a);
+ return *this;
}
- ////////////////////////////////////////////////////////////////////////////
- //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)
- //{
- // glEnable(i_light);
- // return light_setup(i_light);
- //}
+ template<class T>
+ inline material_setup const& material_setup::shininess(T value) const
+ {
+ material_shininess(m_face, value);
+ return *this;
+ }
+ template<class T>
+ inline material_setup const& material_setup::emission(T r, T g, T b, T a) const
+ {
+ material_emission(m_face, r, g, b, a);
+ return *this;
+ }
+
+ inline material_setup material(GLenum face)
+ {
+ return material_setup(face);
+ }
}}}
#endif BOOST__GUIGL__GL__MATERIAL_HPP
Modified: sandbox-branches/andreo/guigl/boost/guigl/platform/impl/rect.hpp
==============================================================================
--- sandbox-branches/andreo/guigl/boost/guigl/platform/impl/rect.hpp (original)
+++ sandbox-branches/andreo/guigl/boost/guigl/platform/impl/rect.hpp 2009-02-20 13:39:34 EST (Fri, 20 Feb 2009)
@@ -1,3 +1,11 @@
+/*=================================---------------------------------------------
+Copyright 2009 Stjepan Rajko, Torba Andrey
+
+Distributed under the Boost Software License, Version 1.0.
+(See accompanying file LICENSE_1_0.txt or copy at
+http://www.boost.org/LICENSE_1_0.txt)
+-----------------------------------------------===============================*/
+
#ifndef BOOST__GUIGL__GL__RECT_HPP
#define BOOST__GUIGL__GL__RECT_HPP
Modified: sandbox-branches/andreo/guigl/boost/guigl/platform/impl/transform.hpp
==============================================================================
--- sandbox-branches/andreo/guigl/boost/guigl/platform/impl/transform.hpp (original)
+++ sandbox-branches/andreo/guigl/boost/guigl/platform/impl/transform.hpp 2009-02-20 13:39:34 EST (Fri, 20 Feb 2009)
@@ -1,3 +1,11 @@
+/*=================================---------------------------------------------
+Copyright 2009 Stjepan Rajko, Torba Andrey
+
+Distributed under the Boost Software License, Version 1.0.
+(See accompanying file LICENSE_1_0.txt or copy at
+http://www.boost.org/LICENSE_1_0.txt)
+-----------------------------------------------===============================*/
+
#ifndef BOOST__GUIGL__GL__TRANSFORM_HPP
#define BOOST__GUIGL__GL__TRANSFORM_HPP
Modified: sandbox-branches/andreo/guigl/boost/guigl/platform/impl/vertex.hpp
==============================================================================
--- sandbox-branches/andreo/guigl/boost/guigl/platform/impl/vertex.hpp (original)
+++ sandbox-branches/andreo/guigl/boost/guigl/platform/impl/vertex.hpp 2009-02-20 13:39:34 EST (Fri, 20 Feb 2009)
@@ -1,3 +1,11 @@
+/*=================================---------------------------------------------
+Copyright 2009 Stjepan Rajko, Torba Andrey
+
+Distributed under the Boost Software License, Version 1.0.
+(See accompanying file LICENSE_1_0.txt or copy at
+http://www.boost.org/LICENSE_1_0.txt)
+-----------------------------------------------===============================*/
+
#ifndef BOOST__GUIGL__GL__VERTEX_HPP
#define BOOST__GUIGL__GL__VERTEX_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-20 13:39:34 EST (Fri, 20 Feb 2009)
@@ -17,21 +17,57 @@
#include <boost/guigl/platform/glu.hpp>
#include <boost/guigl/gl.hpp>
+#include <boost/date_time/posix_time/posix_time_types.hpp>
+#include <boost/date_time/local_time/local_time.hpp>
+
#include <iostream>
+class time_value
+{
+private:
+ double m_speed;
+ double m_phase;
+ boost::posix_time::ptime m_start_time;
+
+public:
+ time_value(
+ double speed,
+ double phase = 0.0,
+ boost::posix_time::ptime const& start_time = boost::posix_time::microsec_clock::local_time())
+ :
+ m_speed(speed),
+ m_phase(phase),
+ m_start_time(start_time)
+ {}
+
+ double operator()(boost::posix_time::ptime const& now
+ = boost::posix_time::microsec_clock::local_time()) const
+ {
+ return m_phase + m_speed *
+ (double)(now - m_start_time).total_milliseconds() /
+ boost::posix_time::seconds(1).total_milliseconds();
+ }
+};
+
+time_value angle(45.0);
+time_value teapot_angle(700.0);
+time_value v(45.0);
+
void two_spheres::draw_prologue()
{
+ using namespace boost::posix_time;
using namespace boost::guigl::gl;
base_type::draw_prologue();
+
+ ptime now = microsec_clock::local_time();
+
glMatrixMode(GL_MODELVIEW);
load_identity();
scoped_matrix m;
- //translate_y(-100.0f);
- rotate_y(20.0f);
+ rotate_y(angle(now));
- //glEnable(GL_DEPTH_TEST);
//glEnable(GL_COLOR_MATERIAL);
glShadeModel(GL_SMOOTH);
@@ -69,39 +105,54 @@
.spot_exponent(2.0f);
double offset = 30;
- material_ambient(GL_FRONT, 1.0f, 0.0f, 0.0f, 0.0f);
+ material(GL_FRONT).ambient(1.0f, 0.0f, 0.0f, 0.0f);
{ scoped_matrix m;
translate(offset, offset, 0.0);
solid_sphere(50, 30, 30);
}
+ rect(0.0, 0.0, 200.0, -200.0);
- material_ambient(GL_FRONT, 1.0f, 1.0f, 0.0f, 0.0f);
+ material(GL_FRONT).ambient(1.0f, 1.0f, 0.0f, 0.0f);
{ scoped_matrix m;
translate(-offset, offset, 0.0);
solid_sphere(50, 30, 30);
}
+ material(GL_FRONT).ambient(0.0f, 1.0f, 0.0f, 0.0f);
+ rect(0.0, 0.0, -200.0, 200.0);
- material_ambient(GL_FRONT, 1.0f, 0.0f, 1.0f, 0.0f);
+ material(GL_FRONT).ambient(1.0f, 0.0f, 1.0f, 0.0f);
{ scoped_matrix m;
translate(-offset, -offset, 0.0);
- solid_sphere(50, 100, 100);
+ solid_sphere(50, 30, 30);
}
+ rect(0.0, 0.0, 200.0, 200.0);
- material_ambient(GL_FRONT, 0.0f, 0.0f, 1.0f, 0.0f);
+ material(GL_FRONT).emission(0.3f, 0.0f, 0.3f, 1.0f);
+ material(GL_FRONT).ambient(0.0f, 0.0f, 1.0f, 0.0f);
{ scoped_matrix m;
translate(offset, -offset, 0.0);
solid_sphere(50, 30, 30);
}
+ rect(0.0, 0.0, -200.0, -200.0);
+ material(GL_FRONT).ambient(1.0f, 1.0f, 1.0f, 1.0f);
+ glLineWidth(5.0);
+ glBegin(GL_LINE_LOOP);
+ vertex(200.0, 200.0);
+ vertex(-200.0, 200.0);
+ vertex(-200.0, -200.0);
+ vertex(200.0, -200.0);
+ glEnd();
{
scoped_matrix m;
- material_shininess(GL_FRONT, 20.0f);
- material_specular(GL_FRONT, 0.3f, 0.3f, 0.3f, 0.3f);
- material_ambient(GL_FRONT, 0.0f, 0.0f, 0.0f, 0.0f);
- material_diffuse(GL_FRONT, 0.0f, 1.0f, 0.0f, 0.0f);
+ material(GL_FRONT)
+ .shininess(20.0f)
+ .specular(0.3f, 0.3f, 0.3f, 0.3f)
+ .ambient(0.0f, 0.0f, 0.0f, 0.0f)
+ .diffuse(0.0f, 1.0f, 0.0f, 0.0f);
translate_z(100.0f);
- rotate_y(20.0f);
+ rotate_y(teapot_angle(now));
solid_teapot(20);
}
}
Modified: sandbox-branches/andreo/guigl/libs/guigl/example/window_example.cpp
==============================================================================
--- sandbox-branches/andreo/guigl/libs/guigl/example/window_example.cpp (original)
+++ sandbox-branches/andreo/guigl/libs/guigl/example/window_example.cpp 2009-02-20 13:39:34 EST (Fri, 20 Feb 2009)
@@ -88,7 +88,21 @@
test_window3 << grid_layout.create<widget::button>(( _background=color_type(1.0f/i,1.0f/i,1.0f/i) ));
window test_window_3d(( _depth = true, _label="3D", _color=make_grey(1) ));
- test_window_3d << new two_spheres(_period = 0.01);
+
+ widget::labeled_slider *sl = new widget::labeled_slider((
+ _label="Slider",
+ _size=size_type(100,30),
+ _position=position_type(0,0),
+ _background=color_type(0.5,0.5,0.5),
+ _active_color=color_type(0,1,0),
+ _min=0.1,_max=0.9,_value=0.5,
+ _step=0.01 ));
+ two_spheres *two = new two_spheres(_period = 0.01);
+
+ test_window_3d
+ << two
+ << sl
+ ;
application::on_idle().connect(&idle);
application::timeout(&timer, 5000);
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