versor  3.0
C++11 library for Geometric algebra
vsr_draw.h
1 /*
2  * =====================================================================================
3  *
4  * Filename: vsr_draw.h
5  *
6  * Description: instantiations of Drawable for Mulvector types (calls Immediate(...)) and Field<T>
7  *
8  * Version: 1.0
9  * Created: 04/17/2015 12:11:53
10  * Revision: none
11  * Compiler: gcc
12  *
13  * Author: Pablo Colapinto (), gmail->wolftype
14  * Organization: wolftype
15  *
16  * =====================================================================================
17  */
18 
19 #include "gfx/gfx_render.h"
20 
21 #include "detail/vsr_multivector.h"
22 #include "form/vsr_field.h"
23 
24 #ifndef vsr_draw_INC
25 #define vsr_draw_INC
26 
27 namespace gfx{
28 
29 
30 // template<class A, class B>
31 // void Renderable< vsr::MV<A,B> >::DrawImmediate( const vsr::MV<A,B>& t){
32 // vsr::cga::Immediate(t);
33 // }
34 
35 
36  //Draw Routine
37  template<class A>
38  void Draw( const A& s, float r = 1, float g = 1, float b = 1, float a = 1){
39  render::begin(r,g,b,a);
40  render::draw(s);
41  }
42 
43  //Draw Routine (Immediate Mode)
44  template<class A, class B>
45  void DrawAt( const A& s, const B& p, float r = 1, float g = 1, float b = 1, float a = 1){
46  render::begin(r,g,b,a);
47  render::drawAt(s,p);
48  }
49  /*-----------------------------------------------------------------------------
50  * General Drawing strategy for a type T calls "Advanced" method from RenderCall<T>
51  *-----------------------------------------------------------------------------*/
52 // template<class A, class B>
53 // struct Renderable< vsr::Multivector<A,B> >{
54 // static inline void Draw(const vsr::Multivector<A,B>& t, GFXSceneNode * s){
55 // vsr::RenderCall<vsr::MV<A,B>>::Piped(t,s);
56 // }
57 // };
58 
59 
60  /*-----------------------------------------------------------------------------
61  * General drawing strategy for Fields of type T
62  *-----------------------------------------------------------------------------*/
63 
64  template<class T>
65  struct Renderable<vsr::Field<T>> : RenderableBase< vsr::Field<T> > {
66 
67  static void DrawImmediate( const vsr::Field<T>& f){
68  for (int i = 0; i < f.num(); ++i){
69  glPushMatrix();
70  Renderable<T>::DrawImmediate( f[i] );
71  glPopMatrix();
72  }
73  }
74 
75  static void Draw( const vsr::Field<T>& f, GFXSceneNode*){}
76  };
77 
78 // template<class T>
79 // struct Renderable< vsr::Field<T> >{
80 // static inline void DrawImmediate( const vsr::Field<T>& f ){
81 // for (int i = 0; i < f.num(); ++i){
82 // render::draw( f[i] );
83 // }
84 // }
85 // };
86 
87 
88 
89 }
90 
91 #endif /* ----- #ifndef vsr_draw_INC ----- */
Definition: vsr_cga2D_draw.h:13
A Basic 3D Field (slowly porting this over from the now defunct vsr_lattice class) Use to Evaluate Ne...
Definition: vsr_field.h:67
the versor library namespace
Definition: vsr_algebra.h:29
generic multivector class, templated on a geometric algebra and a field