Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/externals/g4tools/include/tools/sg/render_action

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /externals/g4tools/include/tools/sg/render_action (Version 11.3.0) and /externals/g4tools/include/tools/sg/render_action (Version 11.0.p2)


  1 // Copyright (C) 2010, Guy Barrand. All rights      1 // Copyright (C) 2010, Guy Barrand. All rights reserved.
  2 // See the file tools.license for terms.            2 // See the file tools.license for terms.
  3                                                     3 
  4 #ifndef tools_sg_render_action                      4 #ifndef tools_sg_render_action
  5 #define tools_sg_render_action                      5 #define tools_sg_render_action
  6                                                     6 
  7 #include "matrix_action"                            7 #include "matrix_action"
  8                                                     8 
  9 #include "../glprims"                               9 #include "../glprims"
 10 #include "../vdata"                                10 #include "../vdata"
 11 #include "../colorf"                               11 #include "../colorf"
 12                                                    12 
 13 namespace tools {                                  13 namespace tools {
 14 namespace sg {                                     14 namespace sg {
 15   class render_manager;                            15   class render_manager;
 16 }}                                                 16 }}
 17                                                    17 
 18                                                    18 
 19 namespace tools {                                  19 namespace tools {
 20 namespace sg {                                     20 namespace sg {
 21                                                    21 
 22 typedef size_t bufpos;                             22 typedef size_t bufpos;
 23                                                    23 
 24 class render_action : public matrix_action {       24 class render_action : public matrix_action {
 25   TOOLS_ACTION_NO_COPY(render_action,tools::sg     25   TOOLS_ACTION_NO_COPY(render_action,tools::sg::render_action,matrix_action)
 26 public:                                            26 public:
 27   typedef unsigned int gstoid;                     27   typedef unsigned int gstoid;
 28 public:                                            28 public:
 29   virtual void load_proj_matrix(const mat4f&)      29   virtual void load_proj_matrix(const mat4f&) = 0;
 30   virtual void load_model_matrix(const mat4f&)     30   virtual void load_model_matrix(const mat4f&) = 0;
 31 public:                                            31 public:
 32   virtual void draw_vertex_array(gl::mode_t,si     32   virtual void draw_vertex_array(gl::mode_t,size_t,const float*) = 0;
 33   virtual void draw_vertex_array_xy(gl::mode_t     33   virtual void draw_vertex_array_xy(gl::mode_t,size_t,const float*) = 0;
 34   virtual void draw_vertex_color_array(gl::mod     34   virtual void draw_vertex_color_array(gl::mode_t,size_t,const float*,const float*) = 0;
 35   virtual void draw_vertex_normal_array(gl::mo     35   virtual void draw_vertex_normal_array(gl::mode_t,size_t,const float*,const float*) = 0;
 36   virtual void draw_vertex_color_normal_array(     36   virtual void draw_vertex_color_normal_array(gl::mode_t,size_t,const float*,const float*,const float*) = 0;
 37                                                    37 
 38   ////////////////////////////////////////////     38   /////////////////////////////////////////////////////////////////
 39   /// texture ////////////////////////////////     39   /// texture /////////////////////////////////////////////////////
 40   ////////////////////////////////////////////     40   /////////////////////////////////////////////////////////////////
 41   virtual void draw_vertex_array_texture(gl::m     41   virtual void draw_vertex_array_texture(gl::mode_t,size_t,const float*,gstoid,const float*) = 0;
 42   virtual void draw_vertex_normal_array_textur     42   virtual void draw_vertex_normal_array_texture(gl::mode_t,size_t,const float*,const float*,gstoid,const float*) = 0;
 43                                                    43 
 44   ////////////////////////////////////////////     44   /////////////////////////////////////////////////////////////////
 45   /// VBO ////////////////////////////////////     45   /// VBO /////////////////////////////////////////////////////////
 46   ////////////////////////////////////////////     46   /////////////////////////////////////////////////////////////////
 47   virtual void begin_gsto(gstoid) = 0;             47   virtual void begin_gsto(gstoid) = 0;
 48   virtual void draw_gsto_v(gl::mode_t,size_t,b     48   virtual void draw_gsto_v(gl::mode_t,size_t,bufpos) = 0;
 49   virtual void draw_gsto_vc(gl::mode_t,size_t,     49   virtual void draw_gsto_vc(gl::mode_t,size_t,bufpos,bufpos) = 0;
 50   virtual void draw_gsto_vn(gl::mode_t,size_t,     50   virtual void draw_gsto_vn(gl::mode_t,size_t,bufpos,bufpos) = 0;
 51   virtual void draw_gsto_vcn(gl::mode_t,size_t     51   virtual void draw_gsto_vcn(gl::mode_t,size_t,bufpos,bufpos,bufpos) = 0;
 52   virtual void end_gsto() = 0;                     52   virtual void end_gsto() = 0;
 53   ////////////////////////////////////////////     53   /////////////////////////////////////////////////////////////////
 54   ////////////////////////////////////////////     54   /////////////////////////////////////////////////////////////////
 55   ////////////////////////////////////////////     55   /////////////////////////////////////////////////////////////////
 56                                                    56 
 57   virtual void clear_color(float,float,float,f     57   virtual void clear_color(float,float,float,float) = 0;
 58   virtual void color4f(float,float,float,float     58   virtual void color4f(float,float,float,float) = 0;
 59   virtual void line_width(float) = 0;              59   virtual void line_width(float) = 0;
 60   virtual void point_size(float) = 0;              60   virtual void point_size(float) = 0;
 61   virtual void set_polygon_offset(bool) = 0;       61   virtual void set_polygon_offset(bool) = 0;
 62   virtual void set_winding(winding_type) = 0;      62   virtual void set_winding(winding_type) = 0;
 63   virtual void set_shade_model(shade_type) = 0     63   virtual void set_shade_model(shade_type) = 0;
 64   virtual void set_cull_face(bool) = 0;            64   virtual void set_cull_face(bool) = 0;
 65   virtual void set_point_smooth(bool) = 0;         65   virtual void set_point_smooth(bool) = 0;
 66   virtual void set_line_smooth(bool) = 0;          66   virtual void set_line_smooth(bool) = 0;
 67   virtual void normal(float,float,float) = 0;      67   virtual void normal(float,float,float) = 0;
 68   virtual void set_depth_test(bool) = 0;           68   virtual void set_depth_test(bool) = 0;
 69   virtual unsigned int max_lights() = 0;           69   virtual unsigned int max_lights() = 0;
 70   virtual void enable_light(unsigned int,          70   virtual void enable_light(unsigned int,
 71                             float,float,float, <<  71                             float,float,float, //directrion
 72                             float,float,float, <<  72                             float,float,float,float) = 0; //RGBA
 73                             float,float,float, << 
 74   virtual void set_lighting(bool) = 0;             73   virtual void set_lighting(bool) = 0;
 75   virtual void set_blend(bool) = 0;                74   virtual void set_blend(bool) = 0;
 76   virtual void restore_state(unsigned int) = 0     75   virtual void restore_state(unsigned int) = 0;
 77                                                    76 
 78   virtual sg::render_manager& render_manager()     77   virtual sg::render_manager& render_manager() = 0; //sg:: is needed.
 79 public:                                            78 public:
 80   render_action(std::ostream& a_out,unsigned i     79   render_action(std::ostream& a_out,unsigned int a_ww,unsigned int a_wh)
 81   :parent(a_out,a_ww,a_wh)                         80   :parent(a_out,a_ww,a_wh)
 82   ,m_do_transparency(false)                        81   ,m_do_transparency(false)
 83   ,m_have_to_do_transparency(false)                82   ,m_have_to_do_transparency(false)
 84   {}                                               83   {}
 85   virtual ~render_action(){}                       84   virtual ~render_action(){}
 86 public:                                            85 public:
 87   render_action(const render_action& a_from)       86   render_action(const render_action& a_from)
 88   :parent(a_from)                                  87   :parent(a_from)
 89   ,m_do_transparency(a_from.m_do_transparency)     88   ,m_do_transparency(a_from.m_do_transparency)
 90   ,m_have_to_do_transparency(a_from.m_have_to_     89   ,m_have_to_do_transparency(a_from.m_have_to_do_transparency)
 91   {}                                               90   {}
 92   render_action& operator=(const render_action     91   render_action& operator=(const render_action& a_from){
 93     parent::operator=(a_from);                     92     parent::operator=(a_from);
 94     m_do_transparency = a_from.m_do_transparen     93     m_do_transparency = a_from.m_do_transparency;
 95     m_have_to_do_transparency = a_from.m_have_     94     m_have_to_do_transparency = a_from.m_have_to_do_transparency;
 96     return *this;                                  95     return *this;
 97   }                                                96   }
 98 public:                                            97 public:
 99   void set_do_transparency(bool a_value) {m_do     98   void set_do_transparency(bool a_value) {m_do_transparency = a_value;}
100   bool do_transparency() const {return m_do_tr     99   bool do_transparency() const {return m_do_transparency;}
101   void set_have_to_do_transparency(bool a_valu    100   void set_have_to_do_transparency(bool a_value) {m_have_to_do_transparency = a_value;}
102   bool have_to_do_transparency() const {return    101   bool have_to_do_transparency() const {return m_have_to_do_transparency;}
103                                                   102 
104   bool have_to_render() {                         103   bool have_to_render() {
105     bool transparent = state().m_color.a()!=1. << 104     bool transparent = state().m_color.a()!=1?true:false;
106     if(transparent && state().m_GL_BLEND) {    << 105     if(transparent) {
107       if(m_do_transparency) return true;          106       if(m_do_transparency) return true;
108       m_have_to_do_transparency = true;           107       m_have_to_do_transparency = true;
109       return false;                               108       return false;
110     }                                             109     }
111     if(m_do_transparency) return false;           110     if(m_do_transparency) return false;
112     return true;                                  111     return true;
113   }                                               112   }
114                                                   113 
115   void load_matrices_to_identity() {              114   void load_matrices_to_identity() {
116     load_proj_matrix(m_identity);                 115     load_proj_matrix(m_identity);
117     load_model_matrix(m_identity);                116     load_model_matrix(m_identity);
118   }                                               117   }
119   void load_matrices_from_state() {               118   void load_matrices_from_state() {
120     const sg::state& _state = state();            119     const sg::state& _state = state();
121     load_proj_matrix(_state.m_proj);              120     load_proj_matrix(_state.m_proj);
122     load_model_matrix(_state.m_model);            121     load_model_matrix(_state.m_model);
123   }                                               122   }
124                                                   123 
125   void clear_color(const colorf& a_color){        124   void clear_color(const colorf& a_color){
126     clear_color(a_color[0],a_color[1],a_color[    125     clear_color(a_color[0],a_color[1],a_color[2],a_color[3]);
127   }                                               126   }
128   void color4f(const colorf& a_color){            127   void color4f(const colorf& a_color){
129     color4f(a_color[0],a_color[1],a_color[2],a    128     color4f(a_color[0],a_color[1],a_color[2],a_color[3]);
130   }                                               129   }
131                                                   130 
132   void enable_light(unsigned int a_light,         131   void enable_light(unsigned int a_light,
133                     const vec3f& a_dir,           132                     const vec3f& a_dir,
134                     const colorf& a_col,const  << 133                     const colorf& a_col) {
135     enable_light(a_light,                         134     enable_light(a_light,
136                  a_dir[0],a_dir[1],a_dir[2],      135                  a_dir[0],a_dir[1],a_dir[2],
137                  a_col[0],a_col[1],a_col[2],a_ << 136                  a_col[0],a_col[1],a_col[2],1);
138                  a_ambient[0],a_ambient[1],a_a << 
139   }                                               137   }
140                                                   138 
141   void draw_vertex_array(gl::mode_t a_mode,con    139   void draw_vertex_array(gl::mode_t a_mode,const std::vector<float>& a_xyzs){
142     const float* _xyzs = vec_data<float>(a_xyz    140     const float* _xyzs = vec_data<float>(a_xyzs);
143     draw_vertex_array(a_mode,a_xyzs.size(),_xy    141     draw_vertex_array(a_mode,a_xyzs.size(),_xyzs);
144   }                                               142   }
145                                                   143 
146   void draw_vertex_array_xy(gl::mode_t a_mode,    144   void draw_vertex_array_xy(gl::mode_t a_mode,const std::vector<float>& a_xys){
147     const float* _xys = vec_data<float>(a_xys)    145     const float* _xys = vec_data<float>(a_xys);
148     draw_vertex_array_xy(a_mode,a_xys.size(),_    146     draw_vertex_array_xy(a_mode,a_xys.size(),_xys);
149   }                                               147   }
150                                                   148 
151   void draw_vertex_color_array(gl::mode_t a_mo    149   void draw_vertex_color_array(gl::mode_t a_mode,
152                                const std::vect    150                                const std::vector<float>& a_xyzs,
153                                const std::vect    151                                const std::vector<float>& a_rgbas){
154     const float* _xyzs = vec_data<float>(a_xyz    152     const float* _xyzs = vec_data<float>(a_xyzs);
155     const float* _rgbas = vec_data<float>(a_rg    153     const float* _rgbas = vec_data<float>(a_rgbas);
156     draw_vertex_color_array(a_mode,a_xyzs.size    154     draw_vertex_color_array(a_mode,a_xyzs.size(),_xyzs,_rgbas);
157   }                                               155   }
158                                                   156 
159   void draw_vertex_normal_array(gl::mode_t a_m    157   void draw_vertex_normal_array(gl::mode_t a_mode,
160                                 const std::vec    158                                 const std::vector<float>& a_xyzs,
161                                 const std::vec    159                                 const std::vector<float>& a_nms){
162     const float* _xyzs = vec_data<float>(a_xyz    160     const float* _xyzs = vec_data<float>(a_xyzs);
163     const float* _nms = vec_data<float>(a_nms)    161     const float* _nms = vec_data<float>(a_nms);
164     draw_vertex_normal_array(a_mode,a_xyzs.siz    162     draw_vertex_normal_array(a_mode,a_xyzs.size(),_xyzs,_nms);
165   }                                               163   }
166                                                   164 
167   void draw_vertex_color_normal_array(gl::mode    165   void draw_vertex_color_normal_array(gl::mode_t a_mode,
168                                       const st    166                                       const std::vector<float>& a_xyzs,
169                                       const st    167                                       const std::vector<float>& a_rgbas,
170                                       const st    168                                       const std::vector<float>& a_nms){
171     const float* _xyzs = vec_data<float>(a_xyz    169     const float* _xyzs = vec_data<float>(a_xyzs);
172     const float* _rgbas = vec_data<float>(a_rg    170     const float* _rgbas = vec_data<float>(a_rgbas);
173     const float* _nms = vec_data<float>(a_nms)    171     const float* _nms = vec_data<float>(a_nms);
174     draw_vertex_color_normal_array(a_mode,a_xy    172     draw_vertex_color_normal_array(a_mode,a_xyzs.size(),_xyzs,_rgbas,_nms);
175   }                                               173   }
176                                                   174 
177   void normal(const vec3f& a_vec) {normal(a_ve    175   void normal(const vec3f& a_vec) {normal(a_vec[0],a_vec[1],a_vec[2]);}
178                                                   176 
179 public:                                           177 public:
180   // for sphere::visit template.                  178   // for sphere::visit template.
181   bool add_triangles_normal(size_t a_floatn,co    179   bool add_triangles_normal(size_t a_floatn,const float* a_xyzs,const float* a_nms) {
182     draw_vertex_normal_array(gl::triangles(),a    180     draw_vertex_normal_array(gl::triangles(),a_floatn,a_xyzs,a_nms);
183     return true;                                  181     return true;
184   }                                               182   }
185   bool add_triangle_fan_normal(size_t a_floatn    183   bool add_triangle_fan_normal(size_t a_floatn,const float* a_xyzs,const float* a_nms) {
186     draw_vertex_normal_array(gl::triangle_fan(    184     draw_vertex_normal_array(gl::triangle_fan(),a_floatn,a_xyzs,a_nms);
187     return true;                                  185     return true;
188   }                                               186   }
189   bool add_triangle_fan_normal_rgba(size_t a_f    187   bool add_triangle_fan_normal_rgba(size_t a_floatn,const float* a_xyzs,float* a_nms,const float* a_rgbas) {
190     draw_vertex_color_normal_array(gl::triangl    188     draw_vertex_color_normal_array(gl::triangle_fan(),a_floatn,a_xyzs,a_rgbas,a_nms);
191     return true;                                  189     return true;
192   }                                               190   }
193   bool add_triangle_strip_normal(size_t a_floa    191   bool add_triangle_strip_normal(size_t a_floatn,const float* a_xyzs,const float* a_nms) {
194     draw_vertex_normal_array(gl::triangle_stri    192     draw_vertex_normal_array(gl::triangle_strip(),a_floatn,a_xyzs,a_nms);
195     return true;                                  193     return true;
196   }                                               194   }
197   bool add_triangle_strip_normal_rgba(size_t a    195   bool add_triangle_strip_normal_rgba(size_t a_floatn,const float* a_xyzs,const float* a_nms,const float* a_rgbas) {
198     draw_vertex_color_normal_array(gl::triangl    196     draw_vertex_color_normal_array(gl::triangle_strip(),a_floatn,a_xyzs,a_rgbas,a_nms);
199     return true;                                  197     return true;
200   }                                               198   }
201   bool add_lines(size_t a_floatn,const float*     199   bool add_lines(size_t a_floatn,const float* a_xyzs) {
202     draw_vertex_array(gl::lines(),a_floatn,a_x    200     draw_vertex_array(gl::lines(),a_floatn,a_xyzs);
203     return true;                                  201     return true;
204   }                                               202   }
205   bool add_line_loop(size_t a_floatn,const flo    203   bool add_line_loop(size_t a_floatn,const float* a_xyzs) {
206     draw_vertex_array(gl::line_loop(),a_floatn    204     draw_vertex_array(gl::line_loop(),a_floatn,a_xyzs);
207     return true;                                  205     return true;
208   }                                               206   }
209   bool add_line_strip(size_t a_floatn,const fl    207   bool add_line_strip(size_t a_floatn,const float* a_xyzs) {
210     draw_vertex_array(gl::line_strip(),a_float    208     draw_vertex_array(gl::line_strip(),a_floatn,a_xyzs);
211     return true;                                  209     return true;
212   }                                               210   }
213   bool add_points(size_t a_floatn,const float*    211   bool add_points(size_t a_floatn,const float* a_xyzs) {
214     draw_vertex_array(gl::points(),a_floatn,a_    212     draw_vertex_array(gl::points(),a_floatn,a_xyzs);
215     return true;                                  213     return true;
216   }                                               214   }
217                                                   215 
218 /*                                                216 /*
219   bool add_triangles_texture(size_t a_floatn,c    217   bool add_triangles_texture(size_t a_floatn,const float* a_xyzs,gstoid a_tex,const float* a_texs){
220     draw_vertex_array_texture(gl::triangles(),    218     draw_vertex_array_texture(gl::triangles(),a_floatn,a_xyzs,a_tex,a_texs);
221     return true;                                  219     return true;
222   }                                               220   }
223   bool add_triangle_fan_texture(size_t a_float    221   bool add_triangle_fan_texture(size_t a_floatn,const float* a_xyzs,gstoid a_tex,const float* a_texs){
224     draw_vertex_array_texture(gl::triangle_fan    222     draw_vertex_array_texture(gl::triangle_fan(),a_floatn,a_xyzs,a_tex,a_texs);
225     return true;                                  223     return true;
226   }                                               224   }
227   bool add_triangle_strip_texture(size_t a_flo    225   bool add_triangle_strip_texture(size_t a_floatn,const float* a_xyzs,gstoid a_tex,const float* a_texs){
228     draw_vertex_array_texture(gl::triangle_str    226     draw_vertex_array_texture(gl::triangle_strip(),a_floatn,a_xyzs,a_tex,a_texs);
229     return true;                                  227     return true;
230   }                                               228   }
231 */                                                229 */
232   bool add_triangle_fan_texture_normal(size_t     230   bool add_triangle_fan_texture_normal(size_t a_floatn,const float* a_xyzs,const float* a_nms,gstoid a_tex,const float* a_texs){
233     draw_vertex_normal_array_texture(gl::trian    231     draw_vertex_normal_array_texture(gl::triangle_fan(),a_floatn,a_xyzs,a_nms,a_tex,a_texs);
234     return true;                                  232     return true;
235   }                                               233   }
236   bool add_triangle_strip_texture_normal(size_    234   bool add_triangle_strip_texture_normal(size_t a_floatn,const float* a_xyzs,const float* a_nms,gstoid a_tex,const float* a_texs){
237     draw_vertex_normal_array_texture(gl::trian    235     draw_vertex_normal_array_texture(gl::triangle_strip(),a_floatn,a_xyzs,a_nms,a_tex,a_texs);
238     return true;                                  236     return true;
239   }                                               237   }
240                                                   238 
241   bool add_line_loop(const std::vector<float>&    239   bool add_line_loop(const std::vector<float>& a_xyzs){
242     const float* _xyzs = vec_data<float>(a_xyz    240     const float* _xyzs = vec_data<float>(a_xyzs);
243     draw_vertex_array(gl::line_loop(),a_xyzs.s    241     draw_vertex_array(gl::line_loop(),a_xyzs.size(),_xyzs);
244     return true;                                  242     return true;
245   }                                               243   }
246                                                   244 
247   bool add_line_strip(const std::vector<float>    245   bool add_line_strip(const std::vector<float>& a_xyzs){
248     const float* _xyzs = vec_data<float>(a_xyz    246     const float* _xyzs = vec_data<float>(a_xyzs);
249     draw_vertex_array(gl::line_strip(),a_xyzs.    247     draw_vertex_array(gl::line_strip(),a_xyzs.size(),_xyzs);
250     return true;                                  248     return true;
251   }                                               249   }
252                                                   250 
253 /*                                                251 /*
254   ////////////////////////////////////////////    252   /////////////////////////////////////////////////////////
255   /// for sg::markers and gstos : ////////////    253   /// for sg::markers and gstos : /////////////////////////
256   ////////////////////////////////////////////    254   /////////////////////////////////////////////////////////
257   bool add_lines(const std::vector<float>& a_x    255   bool add_lines(const std::vector<float>& a_xyzs){
258     const float* _xyzs = vec_data<float>(a_xyz    256     const float* _xyzs = vec_data<float>(a_xyzs);
259     draw_vertex_array(gl::lines(),a_xyzs.size(    257     draw_vertex_array(gl::lines(),a_xyzs.size(),_xyzs);
260     return true;                                  258     return true;
261   }                                               259   }
262   bool add_triangles_normal(const std::vector<    260   bool add_triangles_normal(const std::vector<float>& a_xyzs,const std::vector<float>& a_nms){
263     if(a_xyzs.size()!=a_nms.size()) return fal    261     if(a_xyzs.size()!=a_nms.size()) return false;
264     const float* _xyzs = vec_data<float>(a_xyz    262     const float* _xyzs = vec_data<float>(a_xyzs);
265     const float* _nms = vec_data<float>(a_nms)    263     const float* _nms = vec_data<float>(a_nms);
266     draw_vertex_normal_array(gl::triangles(),a    264     draw_vertex_normal_array(gl::triangles(),a_xyzs.size(),_xyzs,_nms);
267     return true;                                  265     return true;
268   }                                               266   }
269   bool project_point(const mat4f& a_model_matr    267   bool project_point(const mat4f& a_model_matrix,const mat4f& a_projection_matrix,
270                      float& a_x,float& a_y,flo    268                      float& a_x,float& a_y,float& a_z,float& a_w) {
271     //return project_point(a_x,a_y,a_z,a_w);      269     //return project_point(a_x,a_y,a_z,a_w);
272     a_w = 1;                                      270     a_w = 1;
273     a_model_matrix.mul_4f(a_x,a_y,a_z,a_w);       271     a_model_matrix.mul_4f(a_x,a_y,a_z,a_w);
274     a_projection_matrix.mul_4f(a_x,a_y,a_z,a_w    272     a_projection_matrix.mul_4f(a_x,a_y,a_z,a_w);
275     if(a_w==0.0F) return false;                   273     if(a_w==0.0F) return false;
276     a_x /= a_w;                                   274     a_x /= a_w;
277     a_y /= a_w;                                   275     a_y /= a_w;
278     a_z /= a_w;                                   276     a_z /= a_w;
279     return true;                                  277     return true;
280   }                                               278   }
281   ////////////////////////////////////////////    279   /////////////////////////////////////////////////////////
282   ////////////////////////////////////////////    280   /////////////////////////////////////////////////////////
283   ////////////////////////////////////////////    281   /////////////////////////////////////////////////////////
284 */                                                282 */
285                                                   283 
286   bool add_triangle_strip_as_triangles(size_t     284   bool add_triangle_strip_as_triangles(size_t a_floatn,const float* a_xyzs,const float* a_nms) { //used in sg::sphere, icosahedron_sphere.
287     // It appears that if glShadeModel is GL_F    285     // It appears that if glShadeModel is GL_FLAT, triangle strip does not look the same in "gsto mode" where it is rendered as triangles.
288     // We use this function for immediate rend    286     // We use this function for immediate rendering, in case we want the same rendering as "gsto mode".
289                                                   287 
290     size_t num = a_floatn/3;                      288     size_t num = a_floatn/3;
291     if(num<3) return false;                       289     if(num<3) return false;
292     size_t nxyzs = (num-2)*3*3;                   290     size_t nxyzs = (num-2)*3*3;
293                                                   291 
294     std::vector<float> m_xyzs(nxyzs);             292     std::vector<float> m_xyzs(nxyzs);
295     std::vector<float> m_nms(nxyzs);              293     std::vector<float> m_nms(nxyzs);
296                                                   294 
297    {float* pxyzs = vec_data<float>(m_xyzs);       295    {float* pxyzs = vec_data<float>(m_xyzs);
298     float* pnms = vec_data<float>(m_nms);         296     float* pnms = vec_data<float>(m_nms);
299     gl::triangle_strip_to_triangles_nms(num,a_    297     gl::triangle_strip_to_triangles_nms(num,a_xyzs,a_nms,pxyzs,pnms);}
300                                                   298 
301     return add_triangles_normal(nxyzs,vec_data    299     return add_triangles_normal(nxyzs,vec_data<float>(m_xyzs),vec_data<float>(m_nms));
302   }                                               300   }
303                                                   301 
304   void dump_vertex_array_xy(std::ostream& a_ou    302   void dump_vertex_array_xy(std::ostream& a_out,gl::mode_t /*a_mode*/,size_t a_floatn,const float* a_xys) {
305     size_t num = a_floatn/2;                      303     size_t num = a_floatn/2;
306     if(!num) return;                              304     if(!num) return;
307     a_out << "dump_vertex_array_xy : begin : "    305     a_out << "dump_vertex_array_xy : begin : " << num << std::endl;
308     for(size_t index=0;index<num;index++) {       306     for(size_t index=0;index<num;index++) {
309       a_out << "xy : " << index                   307       a_out << "xy : " << index
310             << " " << a_xys[2*index]              308             << " " << a_xys[2*index]
311             << " " << a_xys[2*index+1]            309             << " " << a_xys[2*index+1]
312             << std::endl;                         310             << std::endl;
313     }                                             311     }
314     a_out << "dump_vertex_array_xy : end." <<     312     a_out << "dump_vertex_array_xy : end." << std::endl;
315   }                                               313   }
316 protected:                                        314 protected:
317   bool m_do_transparency;                         315   bool m_do_transparency;
318   bool m_have_to_do_transparency;                 316   bool m_have_to_do_transparency;
319 };                                                317 };
320                                                   318 
321 }}                                                319 }}
322                                                   320 
323 #endif                                            321 #endif