Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r51377 - in sandbox-branches/andreo/guigl: boost/guigl boost/guigl/platform/impl libs/guigl/example
From: andreytorba_at_[hidden]
Date: 2009-02-21 16:39:49


Author: andreo
Date: 2009-02-21 16:39:48 EST (Sat, 21 Feb 2009)
New Revision: 51377
URL: http://svn.boost.org/trac/boost/changeset/51377

Log:
playing with materials
Text files modified:
   sandbox-branches/andreo/guigl/boost/guigl/gl.hpp | 3
   sandbox-branches/andreo/guigl/boost/guigl/platform/impl/transform.hpp | 12 ++
   sandbox-branches/andreo/guigl/libs/guigl/example/two_spheres.cpp | 178 +++++++++++++++------------------------
   sandbox-branches/andreo/guigl/libs/guigl/example/window_example.cpp | 9 --
   4 files changed, 82 insertions(+), 120 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-21 16:39:48 EST (Sat, 21 Feb 2009)
@@ -115,6 +115,9 @@
     void translate(T x, T y, T z);
 
     template<class T>
+ void translate(T x, T y);
+
+ template<class T>
     void translate_x(T x);
 
     template<class T>

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-21 16:39:48 EST (Sat, 21 Feb 2009)
@@ -144,6 +144,18 @@
     }
 
     template<>
+ inline void translate<GLdouble>(GLdouble x, GLdouble y)
+ {
+ translate(x, y, 0.0);
+ }
+
+ template<>
+ inline void translate<GLfloat>(GLfloat x, GLfloat y)
+ {
+ translate(x, y, 0.0f);
+ }
+
+ template<>
     inline void translate_x<GLdouble>(GLdouble x)
     {
         translate(x, 0.0, 0.0);

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-21 16:39:48 EST (Sat, 21 Feb 2009)
@@ -16,42 +16,43 @@
 #include <boost/guigl/view/impl/three_dimensional.hpp>
 #include <boost/guigl/platform/glu.hpp>
 #include <boost/guigl/gl.hpp>
+#include <boost/guigl/types.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);
+//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()
 {
@@ -59,102 +60,57 @@
     using namespace boost::guigl::gl;
     base_type::draw_prologue();
 
- ptime now = microsec_clock::local_time();
+ //ptime now = microsec_clock::local_time();
 
     glMatrixMode(GL_MODELVIEW);
     load_identity();
 
- scoped_matrix m;
- rotate_y(angle(now));
-
-
- //glEnable(GL_COLOR_MATERIAL);
 
     glShadeModel(GL_SMOOTH);
     glEnable(GL_LIGHTING);
     glEnable(GL_DEPTH_TEST);
- //glEnable(GL_BLEND);
- //glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- //glShadeModel(GL_SMOOTH);
- //glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
- //glEnable(GL_POLYGON_SMOOTH);
 
     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
     light(GL_LIGHT0)
- .ambient(0.3f, 0.3f, 0.3f, 1.0f)
         .diffuse(0.5f, 0.5f, 0.5f, 1.0f)
- .specular(1.0f, 0.0f, 1.0f, 1.0f)
+ .specular(1.0f, 1.0f, 1.0f, 1.0f)
         .spot_direction(100, -100, 300)
- .position(-100, 100, -300, 0)
- .constant_attenuation(1.5f)
- .linear_attenuation(0.5f)
- .quadratic_attenuation(0.2f)
- .spot_cutoff(180.0f)
- .spot_exponent(2.0f);
+ .position(200, -150, 0, 0)
+ .spot_cutoff(360.0f)
+ ;
 
     light(GL_LIGHT1)
- .ambient(0.3f, 0.3f, 0.3f, 1.0f)
- .diffuse(0.5f, 0.5f, 0.5f, 1.0f)
- .specular(1.0f, 1.0f, 1.0f, 1.0f)
- .spot_direction(-100, 100, -300)
- .position(100, -100, 300, 0)
- .constant_attenuation(1.2f)
- .linear_attenuation(0.5f)
- .quadratic_attenuation(0.2f)
- .spot_cutoff(180.0f)
- .spot_exponent(2.0f);
-
- double offset = 30;
- 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(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(GL_FRONT).ambient(1.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).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(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(teapot_angle(now));
- solid_teapot(20);
- }
+ .diffuse(1.0f, 1.0f, 0.5f, 1.0f)
+ .spot_direction(0.0f, -0.5f, -0.5f)
+ .position(0, 40, 200, 0)
+ .spot_cutoff(90.0f)
+ ;
+
+ for(float x = -1000; x < 1000 ; x += 100)
+ for(float y = -1000; y < 1000; y += 100)
+ {
+ scoped_matrix m;
+ translate(x, y);
+ rotate_z(drag_origin().x);
+ rotate_x(drag_origin().y);
+
+ material(GL_FRONT)
+ .ambient(0.24725f, 0.1995f, 0.0745f, 1.0f)
+ .diffuse(0.75164f, 0.60648f, 0.22648f, 1.0f)
+ .specular(0.628281f, 0.555802f, 0.366065f, 1.0f)
+ .shininess(51.2f)
+ ;
+ //solid_sphere(45.0, 20, 10);
+ solid_cube(90);
+
+ material(GL_FRONT)
+ .diffuse(0.0f, 0.0f, 0.0f, 0.0f)
+ .ambient(0.0f, 0.0f, 0.0f, 0.0f)
+ ;
+ wire_cube(90);
+ }
+
 }
 
 void two_spheres::draw()

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-21 16:39:48 EST (Sat, 21 Feb 2009)
@@ -89,19 +89,10 @@
     
     window test_window_3d(( _depth = true, _label="3D", _color=make_grey(1) ));
 
- 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);


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