Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r48691 - in sandbox/guigl: boost/guigl boost/guigl/platform boost/guigl/view boost/guigl/view/impl libs/guigl/build/xcodeide/guigl.xcodeproj libs/guigl/example libs/guigl/src
From: stipe_at_[hidden]
Date: 2008-09-09 20:11:29


Author: srajko
Date: 2008-09-09 20:11:28 EDT (Tue, 09 Sep 2008)
New Revision: 48691
URL: http://svn.boost.org/trac/boost/changeset/48691

Log:
added three-dimensional view and example
Added:
   sandbox/guigl/boost/guigl/platform/glu.hpp (contents, props changed)
   sandbox/guigl/boost/guigl/view/impl/three_dimensional.hpp (contents, props changed)
   sandbox/guigl/boost/guigl/view/three_dimensional.hpp (contents, props changed)
   sandbox/guigl/libs/guigl/example/two_spheres.cpp (contents, props changed)
   sandbox/guigl/libs/guigl/example/two_spheres.hpp (contents, props changed)
Text files modified:
   sandbox/guigl/boost/guigl/parameters.hpp | 1 +
   sandbox/guigl/libs/guigl/build/xcodeide/guigl.xcodeproj/project.pbxproj | 10 ++++++++++
   sandbox/guigl/libs/guigl/example/Jamfile | 4 ++--
   sandbox/guigl/libs/guigl/example/window_example.cpp | 6 ++++++
   sandbox/guigl/libs/guigl/src/window.cpp | 10 +++++++---
   5 files changed, 26 insertions(+), 5 deletions(-)

Modified: sandbox/guigl/boost/guigl/parameters.hpp
==============================================================================
--- sandbox/guigl/boost/guigl/parameters.hpp (original)
+++ sandbox/guigl/boost/guigl/parameters.hpp 2008-09-09 20:11:28 EDT (Tue, 09 Sep 2008)
@@ -21,6 +21,7 @@
     BOOST_PARAMETER_TYPED_NAME_WDEFAULT(background,const color_type,(color_type(0,0,0)))
     BOOST_PARAMETER_TYPED_NAME_WDEFAULT(color,const color_type,(color_type(1,1,1)))
     BOOST_PARAMETER_TYPED_NAME_WDEFAULT(active_color,const color_type,(color_type(1,0,0)))
+ BOOST_PARAMETER_TYPED_NAME_WDEFAULT(depth,const bool,false)
     
     typedef boost::parameter::aux::empty_typed_arg_list default_parameters;
 }

Added: sandbox/guigl/boost/guigl/platform/glu.hpp
==============================================================================
--- (empty file)
+++ sandbox/guigl/boost/guigl/platform/glu.hpp 2008-09-09 20:11:28 EDT (Tue, 09 Sep 2008)
@@ -0,0 +1,9 @@
+/*=================================---------------------------------------------
+ Copyright 2008 Stjepan Rajko
+
+ 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)
+-----------------------------------------------===============================*/
+
+#include <OpenGL/glu.h>
\ No newline at end of file

Added: sandbox/guigl/boost/guigl/view/impl/three_dimensional.hpp
==============================================================================
--- (empty file)
+++ sandbox/guigl/boost/guigl/view/impl/three_dimensional.hpp 2008-09-09 20:11:28 EDT (Tue, 09 Sep 2008)
@@ -0,0 +1,44 @@
+/*=================================---------------------------------------------
+ Copyright 2008 Stjepan Rajko
+
+ 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__VIEW__IMPL__THREE_DIMENSIONAL_HPP
+#define BOOST__GUIGL__VIEW__IMPL__THREE_DIMENSIONAL_HPP
+
+#include <boost/guigl/view/three_dimensional.hpp>
+#include <boost/guigl/platform/opengl.hpp>
+
+
+namespace boost { namespace guigl { namespace view {
+
+template<typename BaseView>
+inline void three_dimensional<BaseView>::draw_prologue()
+{
+ BaseView::draw_prologue();
+ glPushMatrix();
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ double xy_aspect = BaseView::size().x / BaseView::size().y;
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glFrustum(xy_aspect*-0.5, xy_aspect*0.5, -0.5, 0.5, 0.5, 5000);
+
+ glMatrixMode(GL_MODELVIEW);
+ glTranslatef(0, 0, -500);
+}
+
+template<typename BaseView>
+inline void three_dimensional<BaseView>::draw_epilogue()
+{
+ glPopMatrix();
+ BaseView::draw_epilogue();
+}
+
+}}}
+
+#endif // BOOST__GUIGL__VIEW__IMPL__THREE_DIMENSIONAL_HPP
\ No newline at end of file

Added: sandbox/guigl/boost/guigl/view/three_dimensional.hpp
==============================================================================
--- (empty file)
+++ sandbox/guigl/boost/guigl/view/three_dimensional.hpp 2008-09-09 20:11:28 EDT (Tue, 09 Sep 2008)
@@ -0,0 +1,36 @@
+/*=================================---------------------------------------------
+ Copyright 2008 Stjepan Rajko
+
+ 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__VIEW__THREE_DIMENSIONAL_HPP
+#define BOOST__GUIGL__VIEW__THREE_DIMENSIONAL_HPP
+
+#include <boost/guigl/view/base.hpp>
+
+namespace boost { namespace guigl { namespace view {
+
+/// Behavior adding three-dimensionality to the view.
+/** three_dimensional adds support for three-dimensional graphics in a view.
+*/
+template<typename BaseView=base>
+class three_dimensional : public BaseView
+{
+ typedef BaseView base_type;
+public:
+ template<typename ArgumentPack>
+ three_dimensional(const ArgumentPack &args)
+ : base_type(args)
+ {}
+
+protected:
+ void draw_prologue();
+ void draw_epilogue();
+};
+
+}}}
+
+#endif // BOOST__GUIGL__VIEW__THREE_DIMENSIONAL_HPP
\ No newline at end of file

Modified: sandbox/guigl/libs/guigl/build/xcodeide/guigl.xcodeproj/project.pbxproj
==============================================================================
--- sandbox/guigl/libs/guigl/build/xcodeide/guigl.xcodeproj/project.pbxproj (original)
+++ sandbox/guigl/libs/guigl/build/xcodeide/guigl.xcodeproj/project.pbxproj 2008-09-09 20:11:28 EDT (Tue, 09 Sep 2008)
@@ -151,6 +151,11 @@
                 08D560D70E5299E6005A2391 /* window_example.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = window_example.cpp; sourceTree = "<group>"; };
                 08D5614B0E529DF1005A2391 /* application.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = application.hpp; sourceTree = "<group>"; };
                 08D561500E529E3E005A2391 /* application.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = application.cpp; sourceTree = "<group>"; };
+ 08E17F600E76DE81008EAE5E /* three_dimensional.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = three_dimensional.hpp; sourceTree = "<group>"; };
+ 08E17F660E76E062008EAE5E /* three_dimensional.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = three_dimensional.hpp; sourceTree = "<group>"; };
+ 08E17F6E0E773D25008EAE5E /* two_spheres.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = two_spheres.cpp; sourceTree = "<group>"; };
+ 08E17F6F0E773D30008EAE5E /* two_spheres.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = two_spheres.hpp; sourceTree = "<group>"; };
+ 08E17FC10E774298008EAE5E /* glu.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = glu.hpp; sourceTree = "<group>"; };
                 08E225F00E65D5C700C3319B /* mouse_tracking.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = mouse_tracking.hpp; sourceTree = "<group>"; };
                 08F506AB0E5B41AD0020D95E /* typed_tagged_argument.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = typed_tagged_argument.hpp; sourceTree = "<group>"; };
                 08F506AF0E5B42930020D95E /* typed_arg_list.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = typed_arg_list.hpp; sourceTree = "<group>"; };
@@ -186,6 +191,8 @@
                         children = (
                                 08D560D20E529971005A2391 /* Jamfile */,
                                 08D560D70E5299E6005A2391 /* window_example.cpp */,
+ 08E17F6E0E773D25008EAE5E /* two_spheres.cpp */,
+ 08E17F6F0E773D30008EAE5E /* two_spheres.hpp */,
                         );
                         name = example;
                         path = ../../example;
@@ -206,6 +213,7 @@
                                 081B078D0E5FF94A00EF7F91 /* draggable.hpp */,
                                 081B07930E5FFBEC00EF7F91 /* mouse_tracking.hpp */,
                                 08D0F2550E6712E90026C6DF /* active_colored.hpp */,
+ 08E17F600E76DE81008EAE5E /* three_dimensional.hpp */,
                         );
                         path = view;
                         sourceTree = "<group>";
@@ -234,6 +242,7 @@
                                 081B07900E5FF9B000EF7F91 /* draggable.hpp */,
                                 08E225F00E65D5C700C3319B /* mouse_tracking.hpp */,
                                 08D0F25D0E67139E0026C6DF /* active_colored.hpp */,
+ 08E17F660E76E062008EAE5E /* three_dimensional.hpp */,
                         );
                         path = impl;
                         sourceTree = "<group>";
@@ -301,6 +310,7 @@
                         children = (
                                 08AD8F620E5CD63400BFB2C8 /* opengl.hpp */,
                                 0897913B0E5DBC1000C79062 /* glut.hpp */,
+ 08E17FC10E774298008EAE5E /* glu.hpp */,
                         );
                         path = platform;
                         sourceTree = "<group>";

Modified: sandbox/guigl/libs/guigl/example/Jamfile
==============================================================================
--- sandbox/guigl/libs/guigl/example/Jamfile (original)
+++ sandbox/guigl/libs/guigl/example/Jamfile 2008-09-09 20:11:28 EDT (Tue, 09 Sep 2008)
@@ -6,9 +6,9 @@
 # http://www.boost.org/LICENSE_1_0.txt)
 #----------------------------------------------===============================*/
 
-project boost/guigl/test
+project boost/guigl/example
     : requirements
         <library>$(TOP)/libs/guigl/build//boost_guigl/<link>static
     ;
 
-exe window_example : window_example.cpp ;
\ No newline at end of file
+exe window_example : window_example.cpp two_spheres.cpp ;
\ No newline at end of file

Added: sandbox/guigl/libs/guigl/example/two_spheres.cpp
==============================================================================
--- (empty file)
+++ sandbox/guigl/libs/guigl/example/two_spheres.cpp 2008-09-09 20:11:28 EDT (Tue, 09 Sep 2008)
@@ -0,0 +1,40 @@
+/*=================================---------------------------------------------
+ Copyright 2008 Stjepan Rajko
+
+ 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)
+-----------------------------------------------===============================*/
+
+#include "two_spheres.hpp"
+
+#include <boost/guigl/view/impl/colored.hpp>
+#include <boost/guigl/view/impl/positioned.hpp>
+#include <boost/guigl/view/impl/solid_background.hpp>
+#include <boost/guigl/view/impl/three_dimensional.hpp>
+#include <boost/guigl/platform/glu.hpp>
+
+void two_spheres::draw_prologue()
+{
+ base_type::draw_prologue();
+ glPushMatrix();
+ gluSphere(static_cast<GLUquadric *>(sphere()), 10, 4, 4);
+ glTranslatef(50,50,50);
+ gluSphere(static_cast<GLUquadric *>(sphere()), 10, 4, 4);
+ glPopMatrix();
+}
+
+void two_spheres::draw()
+{
+ draw_prologue();
+ draw_epilogue();
+}
+
+void *two_spheres::sphere()
+{
+ if(!s_sphere)
+ s_sphere = gluNewQuadric();
+ return s_sphere;
+}
+
+void *two_spheres::s_sphere = 0;

Added: sandbox/guigl/libs/guigl/example/two_spheres.hpp
==============================================================================
--- (empty file)
+++ sandbox/guigl/libs/guigl/example/two_spheres.hpp 2008-09-09 20:11:28 EDT (Tue, 09 Sep 2008)
@@ -0,0 +1,40 @@
+/*=================================---------------------------------------------
+ Copyright 2008 Stjepan Rajko
+
+ 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__EXAMPLE__TWO_SPHERES_HPP
+#define BOOST__GUIGL__EXAMPLE__TWO_SPHERES_HPP
+
+#include <boost/guigl/view/colored.hpp>
+#include <boost/guigl/view/positioned.hpp>
+#include <boost/guigl/view/solid_background.hpp>
+#include <boost/guigl/view/three_dimensional.hpp>
+
+typedef
+ boost::guigl::view::colored<
+ boost::guigl::view::three_dimensional<
+ boost::guigl::view::solid_background<
+ boost::guigl::view::positioned<>
+ > > > two_spheres_base_type;
+
+/// A slider storing a floating point value, changable by dragging in the GUI.
+class two_spheres : public two_spheres_base_type
+{
+ typedef two_spheres_base_type base_type;
+public:
+ template<typename Args>
+ two_spheres(const Args &args)
+ : base_type(args)
+ {}
+protected:
+ void draw();
+ void draw_prologue();
+ static void *sphere();
+ static void *s_sphere;
+};
+
+#endif // BOOST__GUIGL__EXAMPLE__TWO_SPHERES_HPP
\ No newline at end of file

Modified: sandbox/guigl/libs/guigl/example/window_example.cpp
==============================================================================
--- sandbox/guigl/libs/guigl/example/window_example.cpp (original)
+++ sandbox/guigl/libs/guigl/example/window_example.cpp 2008-09-09 20:11:28 EDT (Tue, 09 Sep 2008)
@@ -17,6 +17,8 @@
 #include <boost/bind.hpp>
 #include <boost/bind/placeholders.hpp>
 
+#include "two_spheres.hpp"
+
 using namespace boost::guigl;
 
 color_type make_grey(double value)
@@ -24,6 +26,7 @@
     return color_type(value, value, value);
 }
 
+
 int main()
 {
     window test_window1(( _label = "window example 1", _size=size_type(300,300) ));
@@ -64,5 +67,8 @@
     for(int i=1; i<=9; i++)
         test_window3 << grid_layout.create<widget::button>(( _background=color_type(1.0/i,1.0/i,1.0/i) ));
     
+ window test_window_3d(( _depth = true, _label="3D", _color=make_grey(1) ));
+ test_window_3d << new two_spheres(default_parameters());
+
     application::run();
 }
\ No newline at end of file

Modified: sandbox/guigl/libs/guigl/src/window.cpp
==============================================================================
--- sandbox/guigl/libs/guigl/src/window.cpp (original)
+++ sandbox/guigl/libs/guigl/src/window.cpp 2008-09-09 20:11:28 EDT (Tue, 09 Sep 2008)
@@ -26,11 +26,15 @@
         glutInit(&argc,0);
     }
     
- int create_window(const size_type &size, const std::string &label, window::impl *impl)
+ int create_window(const size_type &size, const std::string &label, bool depth, window::impl *impl)
     {
         glutInitWindowSize(size.x, size.y);
- glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_ALPHA );
+ glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_ALPHA | (depth?GLUT_DEPTH:0));
         int id = glutCreateWindow(label.c_str());
+ if(depth)
+ glEnable(GL_DEPTH_TEST);
+ else
+ glDisable(GL_DEPTH_TEST);
         s_windows[id] = impl;
         
                glutDisplayFunc(display);
@@ -66,7 +70,7 @@
         if(!s_glut)
             s_glut = new glut();
         m_label = map[_label];
- m_id = s_glut->create_window(map[_size], m_label, this);
+ m_id = s_glut->create_window(map[_size], m_label, map[_depth], this);
     }
     void display()
     {


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