Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r50922 - in sandbox-branches/guigl-openGL-wrappers: boost/guigl libs/guigl/build/vc8ide libs/guigl/example
From: andreytorba_at_[hidden]
Date: 2009-01-31 06:08:51


Author: andreo
Date: 2009-01-31 06:08:50 EST (Sat, 31 Jan 2009)
New Revision: 50922
URL: http://svn.boost.org/trac/boost/changeset/50922

Log:
scoped_matrix, polygon_creator
Added:
   sandbox-branches/guigl-openGL-wrappers/boost/guigl/color.hpp (contents, props changed)
Text files modified:
   sandbox-branches/guigl-openGL-wrappers/boost/guigl/draw.hpp | 143 +++++++++++++++++++++++++++++++--------
   sandbox-branches/guigl-openGL-wrappers/boost/guigl/parameters.hpp | 3
   sandbox-branches/guigl-openGL-wrappers/boost/guigl/types.hpp | 31 --------
   sandbox-branches/guigl-openGL-wrappers/libs/guigl/build/vc8ide/build.vcproj | 6 +
   sandbox-branches/guigl-openGL-wrappers/libs/guigl/build/vc8ide/example.vcproj | 2
   sandbox-branches/guigl-openGL-wrappers/libs/guigl/example/two_buttons.cpp | 40 ++++++++---
   6 files changed, 151 insertions(+), 74 deletions(-)

Added: sandbox-branches/guigl-openGL-wrappers/boost/guigl/color.hpp
==============================================================================
--- (empty file)
+++ sandbox-branches/guigl-openGL-wrappers/boost/guigl/color.hpp 2009-01-31 06:08:50 EST (Sat, 31 Jan 2009)
@@ -0,0 +1,58 @@
+/*=================================---------------------------------------------
+Copyright 2008 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__COLOR_HPP
+#define BOOST__GUIGL__COLOR_HPP
+
+#include <boost/guigl/types.hpp>
+
+namespace boost { namespace guigl {
+
+inline color_type make_color(float r, float g, float b, float a)
+{
+ return color_type(r, g, b, a);
+}
+
+inline color_type make_color(float r, float g, float b)
+{
+ return make_color(r, g, b, 1);
+}
+
+inline color_type red(float alpha = 1)
+{
+ return make_color(1, 0, 0, alpha);
+}
+
+inline color_type green(float alpha = 1)
+{
+ return make_color(0, 1, 0, alpha);
+}
+
+inline color_type blue(float alpha = 1)
+{
+ return make_color(0, 0, 1, alpha);
+}
+
+inline color_type yellow(float alpha = 1)
+{
+ return make_color(1, 1, 0, alpha);
+}
+
+inline color_type white(float alpha = 1)
+{
+ return make_color(1, 1, 1, alpha);
+}
+
+inline color_type black(float alpha = 1)
+{
+ return make_color(0, 0, 0, alpha);
+}
+
+}}
+
+#endif BOOST__GUIGL__COLOR_HPP

Modified: sandbox-branches/guigl-openGL-wrappers/boost/guigl/draw.hpp
==============================================================================
--- sandbox-branches/guigl-openGL-wrappers/boost/guigl/draw.hpp (original)
+++ sandbox-branches/guigl-openGL-wrappers/boost/guigl/draw.hpp 2009-01-31 06:08:50 EST (Sat, 31 Jan 2009)
@@ -28,6 +28,16 @@
     glColor4f(color[0], color[1], color[2], color[3]);
   }
 
+ inline void vertex(double x, double y)
+ {
+ glVertex2d(x, y);
+ }
+
+ inline void vertex(const position_type &position)
+ {
+ vertex(position.x, position.y);
+ }
+
   class begin : boost::noncopyable
   {
   public:
@@ -42,18 +52,36 @@
     }
   };
 
- inline void vertex(double x, double y)
- {
- glVertex2d(x, y);
- }
+ class point_creator;
+ class line_loop_creator;
+ class polygon_creator;
 
- inline void vertex(const position_type &position)
+ class vertex_creator : boost::noncopyable
   {
- vertex(position.x, position.y);
- }
+ private:
+ begin m_scoped_begin;
 
- struct vertex_creator : boost::noncopyable
- {
+ vertex_creator(GLenum type)
+ : m_scoped_begin(type)
+ {}
+
+ vertex_creator(GLenum type, double x, double y)
+ : m_scoped_begin(type)
+ {
+ vertex(x, y);
+ }
+
+ vertex_creator(GLenum type, const position_type& position)
+ : m_scoped_begin(type)
+ {
+ vertex(position);
+ }
+
+ friend point_creator;
+ friend line_loop_creator;
+ friend polygon_creator;
+
+ public:
     inline vertex_creator const& operator()(const position_type &position) const
     {
       vertex(position);
@@ -67,18 +95,21 @@
     }
   };
 
- struct point_creator : begin, vertex_creator
+ class point_creator : public vertex_creator
   {
-
+ public:
     point_creator()
- : begin(GL_POINTS), vertex_creator()
+ : vertex_creator(GL_POINTS)
     {}
 
     point_creator(double x, double y)
- : begin(GL_POINTS), vertex_creator()
- {
- vertex(x, y);
- }
+ : vertex_creator(GL_POINTS, x, y)
+ {}
+
+ point_creator(const position_type& position)
+ : vertex_creator(GL_POINTS, position)
+ {}
+
   };
 
   inline void point(double x, double y)
@@ -146,18 +177,20 @@
   // std::for_each(begin_it, end_it, &vertex);
   // }
 
- struct line_loop_creator : begin, vertex_creator
+ class line_loop_creator : public vertex_creator
   {
-
+ public:
     line_loop_creator()
- : begin(GL_LINE_LOOP), vertex_creator()
+ : vertex_creator(GL_LINE_LOOP)
     {}
 
     line_loop_creator(double x, double y)
- : begin(GL_LINE_LOOP), vertex_creator()
- {
- vertex(x, y);
- }
+ : vertex_creator(GL_LINE_LOOP, x, y)
+ {}
+
+ line_loop_creator(const position_type& position)
+ : vertex_creator(GL_LINE_LOOP, position)
+ {}
   };
 
   //template<class ForwardIterator>
@@ -180,6 +213,32 @@
     return line_loop(position.x, position.y);
   }
 
+ class polygon_creator : public vertex_creator
+ {
+ public:
+ polygon_creator()
+ : vertex_creator(GL_POLYGON)
+ {}
+
+ polygon_creator(double x, double y)
+ : vertex_creator(GL_POLYGON, x, y)
+ {}
+
+ polygon_creator(const position_type& position)
+ : vertex_creator(GL_POLYGON, position)
+ {}
+ };
+
+ inline polygon_creator polygon(double x, double y)
+ {
+ return polygon_creator(x, y);
+ }
+
+ inline polygon_creator polygon(const position_type& pos)
+ {
+ return polygon_creator(pos);
+ }
+
   class scoped_matrix : boost::noncopyable
   {
   public:
@@ -194,17 +253,17 @@
     glRotated(angle, x, y, z);
   }
 
- inline void rotateX(double angle)
+ inline void rotate_x(double angle)
   {
     glRotated(angle, 1, 0, 0);
   }
 
- inline void rotateY(double angle)
+ inline void rotate_y(double angle)
   {
     glRotated(angle, 0, 1, 0);
   }
 
- inline void rotateZ(double angle)
+ inline void rotate_z(double angle)
   {
     glRotated(angle, 0, 0, 1);
   }
@@ -214,21 +273,42 @@
     glTranslated(x, y, z);
   }
 
- inline void translateX(double distance)
+ inline void translate_x(double distance)
   {
     translate(distance, 0, 0);
   }
 
- inline void translateY(double distance)
+ inline void translate_y(double distance)
   {
     translate(0, distance, 0);
   }
 
- inline void translateZ(double distance)
+ inline void translate_z(double distance)
   {
     translate(0, 0, distance);
   }
 
+ inline void scale(double x, double y, double z)
+ {
+ glScaled(x, y, z);
+ }
+
+ inline void scale_x(double x)
+ {
+ scale(x, 1, 1);
+ }
+
+ inline void scale_y(double y)
+ {
+ scale(1, y, 1);
+ }
+
+ inline void scale_z(double z)
+ {
+ scale(1, 1, z);
+ }
+
+
   inline void rect(double x1, double y1, double x2, double y2)
   {
     glRectd(x1, y1, x2, y2);
@@ -256,6 +336,11 @@
     rect(zero_position(), pos2);
   }
 
+ inline void line_width(float width)
+ {
+ glLineWidth(width);
+ }
+
 }
 
 }}

Modified: sandbox-branches/guigl-openGL-wrappers/boost/guigl/parameters.hpp
==============================================================================
--- sandbox-branches/guigl-openGL-wrappers/boost/guigl/parameters.hpp (original)
+++ sandbox-branches/guigl-openGL-wrappers/boost/guigl/parameters.hpp 2009-01-31 06:08:50 EST (Sat, 31 Jan 2009)
@@ -1,5 +1,5 @@
 /*=================================---------------------------------------------
- Copyright 2008 Stjepan Rajko
+ Copyright 2008 Stjepan Rajko, Andrey Torba
   
     Distributed under the Boost Software License, Version 1.0.
     (See accompanying file LICENSE_1_0.txt or copy at
@@ -12,6 +12,7 @@
 #include <boost/guigl/event.hpp>
 #include <boost/guigl/types.hpp>
 #include <boost/parameter/typed_name.hpp>
+#include <boost/guigl/color.hpp>
 
 namespace boost { namespace guigl {
 

Modified: sandbox-branches/guigl-openGL-wrappers/boost/guigl/types.hpp
==============================================================================
--- sandbox-branches/guigl-openGL-wrappers/boost/guigl/types.hpp (original)
+++ sandbox-branches/guigl-openGL-wrappers/boost/guigl/types.hpp 2009-01-31 06:08:50 EST (Sat, 31 Jan 2009)
@@ -19,37 +19,6 @@
 typedef gil::point2<double> position_type;
 typedef gil::rgba32f_pixel_t color_type;
 
-// temporary place for color functions
-inline color_type red(float alpha = 1)
- {
- return color_type(1, 0, 0, alpha);
- }
-
-inline color_type green(float alpha = 1)
- {
- return color_type(0, 1, 0, alpha);
- }
-
-inline color_type blue(float alpha = 1)
- {
- return color_type(0, 0, 1, alpha);
- }
-
-inline color_type yellow(float alpha = 1)
- {
- return color_type(1, 1, 0, alpha);
- }
-
-inline color_type white(float alpha = 1)
- {
- return color_type(1, 1, 1, alpha);
- }
-
-inline color_type black(float alpha = 1)
- {
- return color_type(0, 0, 0, alpha);
- }
-
 }}
 
 #endif // BOOST__GUIGL__TYPES_HPP

Modified: sandbox-branches/guigl-openGL-wrappers/libs/guigl/build/vc8ide/build.vcproj
==============================================================================
--- sandbox-branches/guigl-openGL-wrappers/libs/guigl/build/vc8ide/build.vcproj (original)
+++ sandbox-branches/guigl-openGL-wrappers/libs/guigl/build/vc8ide/build.vcproj 2009-01-31 06:08:50 EST (Sat, 31 Jan 2009)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="Windows-1252"?>
 <VisualStudioProject
         ProjectType="Visual C++"
- Version="8.00"
+ Version="8,00"
         Name="build"
         ProjectGUID="{96DD7085-0763-49FF-9986-0244D7B43704}"
>
@@ -85,6 +85,10 @@
>
                         </File>
                         <File
+ RelativePath="..\..\..\..\boost\guigl\color.hpp"
+ >
+ </File>
+ <File
                                 RelativePath="..\..\..\..\boost\guigl\export_symbols.hpp"
>
                         </File>

Modified: sandbox-branches/guigl-openGL-wrappers/libs/guigl/build/vc8ide/example.vcproj
==============================================================================
--- sandbox-branches/guigl-openGL-wrappers/libs/guigl/build/vc8ide/example.vcproj (original)
+++ sandbox-branches/guigl-openGL-wrappers/libs/guigl/build/vc8ide/example.vcproj 2009-01-31 06:08:50 EST (Sat, 31 Jan 2009)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="Windows-1252"?>
 <VisualStudioProject
         ProjectType="Visual C++"
- Version="8.00"
+ Version="8,00"
         Name="example"
         ProjectGUID="{9E866DB0-47D4-4A21-BFBD-2877DE504697}"
>

Modified: sandbox-branches/guigl-openGL-wrappers/libs/guigl/example/two_buttons.cpp
==============================================================================
--- sandbox-branches/guigl-openGL-wrappers/libs/guigl/example/two_buttons.cpp (original)
+++ sandbox-branches/guigl-openGL-wrappers/libs/guigl/example/two_buttons.cpp 2009-01-31 06:08:50 EST (Sat, 31 Jan 2009)
@@ -1,5 +1,5 @@
 /*=================================---------------------------------------------
- Copyright 2008 Stjepan Rajko
+ Copyright 2008 Stjepan Rajko, Andrey Torba
   
     Distributed under the Boost Software License, Version 1.0.
     (See accompanying file LICENSE_1_0.txt or copy at
@@ -12,7 +12,7 @@
 #include <boost/guigl/view/impl/positioned.hpp>
 #include <boost/guigl/types.hpp>
 #include <boost/guigl/draw.hpp>
-
+#include <boost/guigl/color.hpp>
 
 void two_buttons::draw()
 {
@@ -21,23 +21,41 @@
     using namespace boost::guigl;
     using namespace boost::guigl::draw;
 
- color(black((float)0.3));
+ color(black(0.3f));
 
     glLineWidth(2.5);
     glEnable(GL_LINE_SMOOTH);
- glHint(GL_LINE_SMOOTH_HINT, GL_DONT_CARE);
- glEnable (GL_BLEND);
- glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glHint (GL_LINE_SMOOTH_HINT, GL_DONT_CARE);
+ glEnable(GL_POLYGON_SMOOTH);
+ glEnable(GL_POINT_SMOOTH);
+ glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
+ glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
+ glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 
     {
       scoped_matrix m;
- rotateZ(20);
- translateX(20);
- translateY(20);
- rect(10);
+
+ rotate_z(20);
+ translate_x(20);
+ translate_y(20);
+ //scale_y(4);
+
+ polygon
+ (0, 0)
+ (0, size().y)
+ (size().x, size().y)
+ (size().x, 0);
+
+ //rect(10);
     }
 
+ color(yellow(0.5f));
+ polygon
+ (0, 0)
+ (size().x, size().y)
+ (size().x, 0);
+
     line_loop
       (0, 0)
       (size().x, 0)


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