Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r52005 - in sandbox-branches/andreo/guigl: boost/guigl boost/guigl/platform/impl libs/guigl/build/vc8ide libs/guigl/example
From: andreytorba_at_[hidden]
Date: 2009-03-26 19:12:23


Author: andreo
Date: 2009-03-26 19:12:22 EDT (Thu, 26 Mar 2009)
New Revision: 52005
URL: http://svn.boost.org/trac/boost/changeset/52005

Log:
tess implementation
Added:
   sandbox-branches/andreo/guigl/boost/guigl/platform/impl/tess.hpp (contents, props changed)
Text files modified:
   sandbox-branches/andreo/guigl/boost/guigl/gl.hpp | 5 +
   sandbox-branches/andreo/guigl/libs/guigl/build/vc8ide/build.vcproj | 4
   sandbox-branches/andreo/guigl/libs/guigl/example/geometry.cpp | 18 ++--
   sandbox-branches/andreo/guigl/libs/guigl/example/ggl.cpp | 172 ++++++---------------------------------
   sandbox-branches/andreo/guigl/libs/guigl/example/sexy_button.cpp | 2
   5 files changed, 48 insertions(+), 153 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-03-26 19:12:22 EDT (Thu, 26 Mar 2009)
@@ -275,6 +275,10 @@
     void wire_teapot(GLdouble size);
     void solid_teapot(GLdouble size);
 
+ //////////////////////////////////////////////////////////////////////////
+ inline void line_width(float width) {glLineWidth(width);}
+ inline void point_size(float width) {glPointSize(width);}
+
 }}}
 
 #include "platform/impl/vertex.hpp"
@@ -284,5 +288,6 @@
 #include "platform/impl/light.hpp"
 #include "platform/impl/material.hpp"
 #include "platform/impl/glut.hpp"
+#include "platform/impl/tess.hpp"
 
 #endif BOOST__GUIGL__GL_HPP

Added: sandbox-branches/andreo/guigl/boost/guigl/platform/impl/tess.hpp
==============================================================================
--- (empty file)
+++ sandbox-branches/andreo/guigl/boost/guigl/platform/impl/tess.hpp 2009-03-26 19:12:22 EDT (Thu, 26 Mar 2009)
@@ -0,0 +1,104 @@
+/*=================================---------------------------------------------
+Copyright 2009 Andrey Torba
+
+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__TESS_HPP
+#define BOOST__GUIGL__GL__TESS_HPP
+
+#include <boost/guigl/types.hpp>
+
+namespace boost{ namespace guigl { namespace gl {
+
+ class tess : boost::noncopyable {
+ private:
+ GLUtesselator *m_tess;
+ friend class polygon;
+
+ static void CALLBACK begin_cb(GLenum which)
+ {
+ glBegin(which);
+ }
+
+ static void CALLBACK end_cb() {
+ glEnd();
+ }
+ static void CALLBACK vertex_cb(const GLvoid *data)
+ {
+ boost::guigl::position_type* pos =
+ (boost::guigl::position_type*)data;
+ glVertex2d(pos->x, pos->y);
+ }
+
+ static void CALLBACK error_cb(GLenum errorCode)
+ {
+ BOOST_ASSERT(!gluErrorString(errorCode));
+ //const GLubyte *errorStr;
+ //errorStr = gluErrorString(errorCode);
+ //std::cerr << "[ERROR]: " << errorStr << std::endl;
+ }
+
+ public:
+ tess() {
+ m_tess = gluNewTess(); // create a tessellator
+ BOOST_ASSERT(m_tess);
+ if(!m_tess) return ;
+ gluTessCallback(m_tess, GLU_TESS_BEGIN, (void (CALLBACK *)())&tess::begin_cb);
+ gluTessCallback(m_tess, GLU_TESS_END, (void (CALLBACK *)())&tess::end_cb);
+ gluTessCallback(m_tess, GLU_TESS_ERROR, (void (CALLBACK *)())&tess::error_cb);
+ gluTessCallback(m_tess, GLU_TESS_VERTEX, (void (CALLBACK *)())&tess::vertex_cb);
+ }
+ ~tess() { gluDeleteTess(m_tess); }
+
+ bool operator!() const {return !m_tess;}
+
+ class polygon : boost::noncopyable {
+ private:
+ GLUtesselator *m_tess;
+ friend class contour;
+
+ public:
+ explicit polygon(tess const& t)
+ : m_tess(t.m_tess)
+ {
+ BOOST_ASSERT(m_tess);
+ gluTessBeginPolygon(m_tess, 0);
+ }
+ ~polygon(){ gluTessEndPolygon(m_tess); }
+
+ class contour : boost::noncopyable {
+ private:
+ GLUtesselator *m_tess;
+
+ public:
+ explicit contour(polygon const& pg)
+ : m_tess(pg.m_tess)
+ {
+ BOOST_ASSERT(m_tess);
+ gluTessBeginContour(m_tess);
+ }
+ ~contour(){ gluTessEndContour(m_tess); }
+
+ inline void operator()(double coord[3], void *data) const {
+ gluTessVertex(m_tess, coord, data);
+ }
+
+ inline void operator()(double coord[3]) const {
+ (*this)(coord, coord);
+ }
+
+ inline void operator()(boost::guigl::position_type const& pos) const {
+ double coord[3] = {pos.x, pos.y, 0.};
+ (*this)(coord, (void*)&pos);
+ }
+ };
+ };
+ };
+
+
+}}}
+
+#endif // BOOST__GUIGL__GL__TESS_HPP

Modified: sandbox-branches/andreo/guigl/libs/guigl/build/vc8ide/build.vcproj
==============================================================================
--- sandbox-branches/andreo/guigl/libs/guigl/build/vc8ide/build.vcproj (original)
+++ sandbox-branches/andreo/guigl/libs/guigl/build/vc8ide/build.vcproj 2009-03-26 19:12:22 EDT (Thu, 26 Mar 2009)
@@ -151,6 +151,10 @@
>
                                         </File>
                                         <File
+ RelativePath="..\..\..\..\boost\guigl\platform\impl\tess.hpp"
+ >
+ </File>
+ <File
                                                 RelativePath="..\..\..\..\boost\guigl\platform\impl\transform.hpp"
>
                                         </File>

Modified: sandbox-branches/andreo/guigl/libs/guigl/example/geometry.cpp
==============================================================================
--- sandbox-branches/andreo/guigl/libs/guigl/example/geometry.cpp (original)
+++ sandbox-branches/andreo/guigl/libs/guigl/example/geometry.cpp 2009-03-26 19:12:22 EDT (Thu, 26 Mar 2009)
@@ -39,25 +39,25 @@
   public:
     void visit(int key, source_point& g) const
       {
- gl::color(blue(0.7));
+ gl::color(blue(0.7f));
       ggl::draw(g.result);
       }
 
     void visit(int key, line_from_two_points& g) const
       {
- glLineWidth(4);
- gl::color(red(0.8));
+ gl::line_width(4);
+ gl::color(red(0.8f));
       ggl::draw(g.result);
       }
 
     void visit(int key, plane_from_three_points& g) const
       {
- gl::color(green(0.5));
+ gl::color(green(0.5f));
       glBegin(GL_POLYGON);
       ggl::vertex(g.result.outer());
       glEnd();
 
- glLineWidth(2);
+ gl::line_width(2);
       gl::color(black(0.2));
       ggl::draw<geometry::ring_tag>(g.result.outer());
       }
@@ -185,7 +185,7 @@
     if(!i) return ;
 
     point_type center = get_center(obj.result);
- drawString(descriptions.find(*i)->second.c_str(), center.x + 10, center.y, grey(0.1), GLUT_BITMAP_8_BY_13);
+ drawString(descriptions.find(*i)->second.c_str(), center.x + 10, center.y, grey(0.1f), GLUT_BITMAP_8_BY_13);
     }
   };
 
@@ -247,7 +247,7 @@
 
   void operator()() const
     {
- glLineWidth(0.5);
+ gl::line_width(0.5);
     gl::color(black(0.5));
     ggl::draw(w->segment<HC>());
     ggl::draw(w->segment<VC>());
@@ -257,8 +257,8 @@
 
 // drawString("center", 0, 0, grey(0.1), GLUT_BITMAP_8_BY_13);
 
- glPointSize(10);
- //glLineWidth(2);
+ gl::point_size(10);
+ //gl::line_width(2);
     glEnable(GL_LINE_SMOOTH);
     glEnable(GL_POINT_SMOOTH);
 

Modified: sandbox-branches/andreo/guigl/libs/guigl/example/ggl.cpp
==============================================================================
--- sandbox-branches/andreo/guigl/libs/guigl/example/ggl.cpp (original)
+++ sandbox-branches/andreo/guigl/libs/guigl/example/ggl.cpp 2009-03-26 19:12:22 EDT (Thu, 26 Mar 2009)
@@ -31,99 +31,6 @@
 
 using namespace boost::guigl;
 
-void CALLBACK tess_begin_cb(GLenum which) {
- //std::cout << __FUNCTION__ << ": " << which << std::endl;
- glBegin(which);
- }
-void CALLBACK tess_end_cb() {
- //std::cout << __FUNCTION__ << std::endl;
- glEnd();
- }
-void CALLBACK tess_vertex_cb(const GLvoid *data) {
- //std::cout << __FUNCTION__ << std::endl;
- glVertex3dv((const GLdouble*)data);
- }
-void CALLBACK tess_error_cb(GLenum errorCode)
-{
- const GLubyte *errorStr;
- errorStr = gluErrorString(errorCode);
- std::cerr << "[ERROR]: " << errorStr << std::endl;
-}
-
-class tess : boost::noncopyable {
-public:
- GLUtesselator *m_tess;
-
-public:
- tess() {
- m_tess = gluNewTess(); // create a tessellator
- if(!m_tess) throw std::runtime_error("failed to create tessellation object");
- }
- ~tess() { gluDeleteTess(m_tess); }
-
- class polygon : boost::noncopyable {
- public:
- GLUtesselator *m_tess;
- public:
- explicit polygon(tess const& t)
- : m_tess(t.m_tess)
- { gluTessBeginPolygon(m_tess, 0); }
- ~polygon(){ gluTessEndPolygon(m_tess); }
-
- class contour : boost::noncopyable {
- public:
- GLUtesselator *m_tess;
-
- public:
- explicit contour(polygon const& pg)
- : m_tess(pg.m_tess)
- { gluTessBeginContour(m_tess); }
- ~contour(){ gluTessEndContour(m_tess); }
-
- inline void operator()(double coord[3], void *data) const {
- gluTessVertex(m_tess, coord, data);
- }
-
- inline void operator()(double coord[3]) const {
- (*this)(coord, coord);
- }
-
- inline void operator()(position_type const& pos) const {
- double coord[3] = {pos[0], pos[1], 0.0};
- (*this)(coord);
- }
-
- };
- };
-};
-
-GLuint tessellate1()
-{
- glColor3f(1,0,0);
-
- tess tt;
- GLUtesselator* t = tt.m_tess;
- GLdouble quad1[4][3] = { {-10,30,0}, {0,0,0}, {10,30,0}, {0,20,0} };
-
- // register callback functions
- gluTessCallback(t, GLU_TESS_BEGIN, (void (CALLBACK *)())tess_begin_cb);
- gluTessCallback(t, GLU_TESS_END, (void (CALLBACK *)())tess_end_cb);
- gluTessCallback(t, GLU_TESS_ERROR, (void (CALLBACK *)())tess_error_cb);
- gluTessCallback(t, GLU_TESS_VERTEX, (void (CALLBACK *)())tess_vertex_cb);
-
-// glNewList(id, GL_COMPILE);
- {
- tess::polygon p(tt);
- tess::polygon::contour c(p);
- c(quad1[0]);
- c(quad1[1]);
- c(quad1[2]);
- c(quad1[3]);
- }
-
- return 0;//id; // return handle ID of a display list
-}
-
 typedef view::positioned<> my_widget_base_type;
 class my_widget : public my_widget_base_type
 {
@@ -148,12 +55,12 @@
 
         // linear_ring
         gl::color(yellow());
- glLineWidth(7);
+ gl::line_width(7);
         ggl::draw(r);
 
         // box
         gl::color(blue());
- glLineWidth(1);
+ gl::line_width(1);
         geometry::box<position_type> b(
             point<LT>(),
             point<RB>());
@@ -161,12 +68,12 @@
 
         // segment
         gl::color(green(0.5f));
- glLineWidth(2);
+ gl::line_width(2);
         ggl::draw(segment<HC>());
         ggl::draw(segment<VC>());
 
         gl::color(red(0.2f));
- glLineWidth(5);
+ gl::line_width(5);
         ggl::draw(segment<D1>());
         ggl::draw(segment<D2>());
 
@@ -181,7 +88,7 @@
         ggl::draw<geometry::ring_tag>(v);
 
         // std::vector as a linestring
- glLineWidth(0.5);
+ gl::line_width(0.5);
         gl::color(white());
         ggl::draw<geometry::linestring_tag>(v);
 
@@ -196,57 +103,36 @@
         std::copy(v.begin(), v.end(), std::back_inserter(pg.inners().back()));
         geometry::correct(pg);
 
- //glPointSize(10);
+ //gl::point_size(10);
         //gl::color(red());
         //glBegin(GL_POINTS);
         //ggl::vertex(pg);
         //glEnd();
 
- //GLuint id = glGenLists(1); // create a display list
+ GLuint id = glGenLists(1); // create a display list
+ glNewList(id, GL_COMPILE);
         gl::color(red(0.5));
- //{
- // GLUtesselator *t = gluNewTess(); // create a tessellator
- // //tess t;
- // // register callback functions
- // gluTessCallback(t, GLU_TESS_BEGIN, (void (__stdcall*)(void))tess_begin_cb);
- // gluTessCallback(t, GLU_TESS_END, (void (__stdcall*)(void))tess_end_cb);
- // gluTessCallback(t, GLU_TESS_ERROR, (void (__stdcall*)(void))tess_error_cb);
- // gluTessCallback(t, GLU_TESS_VERTEX, (void (__stdcall*)())tess_vertex_cb);
-
- // glNewList(id, GL_COMPILE);
- // gluTessBeginPolygon(t, 0);
- // //tess::polygon p(t);
- // {
- // {
- // gluTessBeginContour(t);
- // //tess::polygon::contour c(t);
- // BOOST_FOREACH(position_type const& pos, pg.outer())
- // {
- // double coord[3] = {pos[0], pos[1], 0.0};
- // gluTessVertex(t, coord, coord);
- // //c(pos);
- // }
- // gluTessEndContour(t);
- // }
-
- // //BOOST_FOREACH(
- // // geometry::linear_ring<position_type> const& ring,
- // // pg.inners())
- // //{
- // // tess::polygon::contour c(t);
- // // BOOST_FOREACH(position_type const& pos, ring)
- // // { c(pos); }
- // //}
- // }
- // gluTessEndPolygon(t);
- // glEndList();
- // gluDeleteTess(t);
- //}
-
- //std::cout << "tess-begin" << std::endl;
- tessellate1();
- //std::cout << "tess-end" << std::endl;
-// glCallList(tessellate1());
+
+ {
+ gl::tess t;
+ gl::tess::polygon p(t);
+ {
+ gl::tess::polygon::contour c(p);
+ BOOST_FOREACH(position_type const& pos, pg.outer())
+ c(pos);
+ }
+ BOOST_FOREACH(
+ geometry::linear_ring<position_type> const& ring,
+ pg.inners())
+ {
+ gl::tess::polygon::contour c(p);
+ BOOST_FOREACH(position_type const& pos, ring)
+ c(pos);
+ }
+ }
+ glEndList();
+
+ glCallList(id);
     }
 
     BOOST_GUIGL_WIDGET_DRAW_IMPL(my_widget);

Modified: sandbox-branches/andreo/guigl/libs/guigl/example/sexy_button.cpp
==============================================================================
--- sandbox-branches/andreo/guigl/libs/guigl/example/sexy_button.cpp (original)
+++ sandbox-branches/andreo/guigl/libs/guigl/example/sexy_button.cpp 2009-03-26 19:12:22 EDT (Thu, 26 Mar 2009)
@@ -208,7 +208,7 @@
             glEnd();
 
 
- glLineWidth(0.5);
+ gl::line_width(0.5);
             gl::color(black(mouse_state().inside ? 1.0f : 0.7f));
             glBegin(GL_LINE_LOOP);
             draw_rounded_rect();


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