Back to home page

EIC code displayed by LXR

 
 

    


Warning, /include/Geant4/toolx/sg/GL_action is written in an unsupported language. File is not indexed.

0001 // Copyright (C) 2010, Guy Barrand. All rights reserved.
0002 // See the file tools.license for terms.
0003 
0004 #ifndef toolx_sg_GL_action
0005 #define toolx_sg_GL_action
0006 
0007 #include "GL_manager"
0008 
0009 #include <tools/sg/render_action>
0010 
0011 //#include <tools/mathf>
0012 //#include <tools/lina/matout>
0013 
0014 namespace toolx {
0015 namespace sg {
0016 
0017 class GL_action : public tools::sg::render_action {
0018   TOOLS_ACTION(GL_action,toolx::sg::GL_action,tools::sg::render_action)
0019 public:
0020   virtual void draw_vertex_array(tools::gl::mode_t a_mode,size_t a_floatn,const float* a_xyzs){
0021     size_t num = a_floatn/3;
0022     if(!num) return;
0023     _draw_v(a_mode,num,a_xyzs);
0024   }
0025 
0026   virtual void draw_vertex_array_xy(tools::gl::mode_t a_mode,size_t a_floatn,const float* a_xys){
0027     size_t num = a_floatn/2;
0028     if(!num) return;
0029 #ifdef _WIN32
0030     float* vp = new float[num*3];
0031     if(!vp) return;
0032     float* pos = vp;
0033     float* pda = (float*)a_xys;
0034     for(size_t index=0;index<num;index++){
0035       *pos = *pda;pos++;pda++;
0036       *pos = *pda;pos++;pda++;
0037       *pos = 0;pos++; //Windows GL needs a z = 0.
0038     }
0039     ::glEnableClientState(GL_VERTEX_ARRAY);
0040     ::glVertexPointer(3,GL_FLOAT,0,vp);
0041     ::glDrawArrays(a_mode,0,(GLsizei)num);
0042     ::glDisableClientState(GL_VERTEX_ARRAY);
0043     delete [] vp;
0044 #else
0045     ::glEnableClientState(GL_VERTEX_ARRAY);
0046     ::glVertexPointer(2,GL_FLOAT,0,a_xys);
0047     ::glDrawArrays(a_mode,0,(GLsizei)num);
0048     ::glDisableClientState(GL_VERTEX_ARRAY);
0049 #endif
0050   }
0051 
0052   virtual void draw_vertex_color_array(tools::gl::mode_t a_mode,size_t a_floatn,const float* a_xyzs,const float* a_rgbas){
0053     // Used in atb_vertices.
0054     // We expect a_rgbas of size : 4*(a_floatn/3)
0055     // (then one RGBA color per 3D point).
0056     size_t num = a_floatn/3;
0057     if(!num) return;
0058     _draw_vc(a_mode,num,a_xyzs,a_rgbas);
0059   }
0060 
0061   virtual void draw_vertex_normal_array(tools::gl::mode_t a_mode,size_t a_floatn,const float* a_xyzs,const float* a_nms){
0062     // We expect a_nms of size : 3*(a_floatn/3)
0063     // (then one normal per 3D point).
0064     size_t num = a_floatn/3;
0065     if(!num) return;
0066     _draw_vn(a_mode,num,a_xyzs,a_nms);
0067   }
0068 
0069   virtual void draw_vertex_color_normal_array(tools::gl::mode_t a_mode,
0070                                        size_t a_floatn,const float* a_xyzs,const float* a_rgbas,const float* a_nms){
0071     // Used in atb_vertices.
0072     // We expect a_nms of size : 3*(a_floatn/3)
0073     // (then one normal per 3D point).
0074     // We expect a_rgbas of size : 4*(a_floatn/3)
0075     // (then one RGBA color per 3D point).
0076     size_t num = a_floatn/3;
0077     if(!num) return;
0078     _draw_vcn(a_mode,num,a_xyzs,a_rgbas,a_nms);
0079   }
0080 
0081   /////////////////////////////////////////////////////////////////
0082   /// texture /////////////////////////////////////////////////////
0083   /////////////////////////////////////////////////////////////////
0084   virtual void draw_vertex_array_texture(tools::gl::mode_t a_mode,
0085                                          size_t a_floatn,
0086                                          const float* a_xyzs,
0087                                          gstoid a_tex,
0088                                          const float* a_tex_coords) {
0089     size_t num = a_floatn/3;
0090     if(!num) return;
0091 
0092     //expect 2*num a_tex_coords.
0093 
0094     ::glEnable(GL_TEXTURE_2D);
0095 
0096     m_mgr.bind_gsto(a_tex);
0097 
0098     ::glEnableClientState(GL_VERTEX_ARRAY);
0099     ::glEnableClientState(GL_TEXTURE_COORD_ARRAY);
0100     ::glVertexPointer(3,GL_FLOAT,0,a_xyzs);
0101     ::glTexCoordPointer(2,GL_FLOAT,0,a_tex_coords);
0102     ::glDrawArrays(a_mode,0,(GLsizei)num);
0103     ::glDisableClientState(GL_VERTEX_ARRAY);
0104     ::glDisableClientState(GL_TEXTURE_COORD_ARRAY);
0105 
0106     ::glBindTexture(GL_TEXTURE_2D,0);
0107 
0108     ::glDisable(GL_TEXTURE_2D);
0109   }
0110 
0111   virtual void draw_vertex_normal_array_texture(tools::gl::mode_t a_mode,
0112                                          size_t a_floatn,
0113                                          const float* a_xyzs,
0114                                          const float* a_nms,
0115                                          gstoid a_tex,
0116                                          const float* a_tex_coords) {
0117     size_t num = a_floatn/3;
0118     if(!num) return;
0119 
0120     //expect 2*num a_tex_coords.
0121 
0122     ::glEnable(GL_TEXTURE_2D);
0123 
0124     m_mgr.bind_gsto(a_tex);
0125 
0126     ::glEnableClientState(GL_VERTEX_ARRAY);
0127     ::glEnableClientState(GL_NORMAL_ARRAY);
0128     ::glEnableClientState(GL_TEXTURE_COORD_ARRAY);
0129     ::glVertexPointer(3,GL_FLOAT,0,a_xyzs);
0130     ::glNormalPointer(GL_FLOAT,0,a_nms);
0131     ::glTexCoordPointer(2,GL_FLOAT,0,a_tex_coords);
0132     ::glDrawArrays(a_mode,0,(GLsizei)num);
0133     ::glDisableClientState(GL_NORMAL_ARRAY);
0134     ::glDisableClientState(GL_VERTEX_ARRAY);
0135     ::glDisableClientState(GL_TEXTURE_COORD_ARRAY);
0136 
0137     ::glBindTexture(GL_TEXTURE_2D,0);
0138 
0139     ::glDisable(GL_TEXTURE_2D);
0140   }
0141 
0142   /////////////////////////////////////////////////////////////////
0143   /// VBO /////////////////////////////////////////////////////////
0144   /////////////////////////////////////////////////////////////////
0145 
0146   virtual void begin_gsto(gstoid a_id) {
0147     switch(m_mgr.get_gsto_mode()){
0148 
0149     case tools::sg::gsto_gl_vbo:{
0150 #ifdef TOOLX_HAS_GL_VBO
0151       m_mgr.bind_gsto(a_id);
0152 #endif
0153       }break;
0154 
0155     case tools::sg::gsto_gl_list:{
0156 #ifdef TOOLX_HAS_GL_LIST
0157       m_gsto = a_id;
0158       m_created = false;
0159       m_gl_id = m_mgr.gsto_gl_list_id(a_id,m_created);
0160       if(m_gl_id && m_created) {
0161         ::glNewList(m_gl_id,GL_COMPILE);
0162       }
0163 #endif
0164       }break;
0165 
0166     case tools::sg::gsto_memory:{
0167       m_gsto = a_id;
0168       }break;
0169     }
0170   }
0171 
0172   virtual void end_gsto() {
0173     switch(m_mgr.get_gsto_mode()){
0174 
0175     case tools::sg::gsto_gl_vbo:{
0176 #ifdef TOOLX_HAS_GL_VBO
0177       ::glBindBuffer(GL_ARRAY_BUFFER,0);
0178 #endif
0179       }break;
0180 
0181     case tools::sg::gsto_gl_list:{
0182 #ifdef TOOLX_HAS_GL_LIST
0183       if(m_gl_id && m_created) {
0184         ::glEndList();
0185       }
0186       if(m_gl_id) ::glCallList(m_gl_id);
0187       m_created = false;
0188       m_gl_id = 0;
0189       m_gsto = 0;
0190 #endif
0191       }break;
0192 
0193     case tools::sg::gsto_memory:{
0194       m_gsto = 0;
0195       }break;
0196     }
0197   }
0198 
0199   typedef tools::sg::bufpos bufpos;
0200   virtual void draw_gsto_v(tools::gl::mode_t a_mode,size_t a_elems,bufpos a_pos_xyzs){
0201 
0202     switch(m_mgr.get_gsto_mode()){
0203 
0204     case tools::sg::gsto_gl_vbo:{
0205 #ifdef TOOLX_HAS_GL_VBO
0206       _draw_v(a_mode,a_elems,(char*)NULL+a_pos_xyzs);
0207 #endif
0208       }break;
0209 
0210     case tools::sg::gsto_gl_list:{
0211 #ifdef TOOLX_HAS_GL_LIST
0212       float* buffer = m_mgr.gsto_data(m_gsto);
0213       if(!buffer) return;
0214       void* pos_xyzs = (char*)buffer+a_pos_xyzs;
0215       if(m_gl_id && m_created) {
0216         ::glBegin(a_mode);
0217         float* pos = (float*)pos_xyzs;
0218         for(size_t index=0;index<a_elems;index++,pos+=3) {
0219           ::glVertex3f(*(pos+0),*(pos+1),*(pos+2));
0220         }
0221         ::glEnd();
0222       }
0223 #endif
0224       }break;
0225 
0226     case tools::sg::gsto_memory:{
0227       float* buffer = m_mgr.gsto_data(m_gsto);
0228       if(!buffer) return;
0229       void* pos_xyzs = (char*)buffer+a_pos_xyzs;
0230       _draw_v(a_mode,a_elems,pos_xyzs);
0231       }break;
0232     }
0233   }
0234 
0235   virtual void draw_gsto_vc(tools::gl::mode_t a_mode,size_t a_elems,bufpos a_pos_xyzs,bufpos a_pos_rgbas){
0236 
0237     switch(m_mgr.get_gsto_mode()){
0238 
0239     case tools::sg::gsto_gl_vbo:{
0240 #ifdef TOOLX_HAS_GL_VBO
0241       _draw_vc(a_mode,a_elems,(char*)NULL+a_pos_xyzs,(char*)NULL+a_pos_rgbas);
0242 #endif
0243       }break;
0244 
0245     case tools::sg::gsto_gl_list:{
0246 #ifdef TOOLX_HAS_GL_LIST
0247       float* buffer = m_mgr.gsto_data(m_gsto);
0248       if(!buffer) return;
0249       void* pos_xyzs = (char*)buffer+a_pos_xyzs;
0250       void* pos_rgbas = (char*)buffer+a_pos_rgbas;
0251       if(m_gl_id && m_created) {
0252         ::glBegin(a_mode);
0253         float* pos = (float*)pos_xyzs;
0254         float* pco = (float*)pos_rgbas;
0255         for(size_t index=0;index<a_elems;index++,pos+=3,pco+=4) {
0256           ::glColor4f (*(pco+0),*(pco+1),*(pco+2),*(pco+3));
0257           ::glVertex3f(*(pos+0),*(pos+1),*(pos+2));
0258         }
0259         ::glEnd();
0260       }
0261 #endif
0262       }break;
0263 
0264     case tools::sg::gsto_memory:{
0265       float* buffer = m_mgr.gsto_data(m_gsto);
0266       if(!buffer) return;
0267       void* pos_xyzs = (char*)buffer+a_pos_xyzs;
0268       void* pos_rgbas = (char*)buffer+a_pos_rgbas;
0269       _draw_vc(a_mode,a_elems,pos_xyzs,pos_rgbas);
0270       }break;
0271     }
0272   }
0273 
0274   virtual void draw_gsto_vn(tools::gl::mode_t a_mode,size_t a_elems,bufpos a_pos_xyzs,bufpos a_pos_nms){
0275 
0276     switch(m_mgr.get_gsto_mode()){
0277 
0278     case tools::sg::gsto_gl_vbo:{
0279 #ifdef TOOLX_HAS_GL_VBO
0280       _draw_vn(a_mode,a_elems,(char*)NULL+a_pos_xyzs,(char*)NULL+a_pos_nms);
0281 #endif
0282       }break;
0283 
0284     case tools::sg::gsto_gl_list:{
0285 #ifdef TOOLX_HAS_GL_LIST
0286       float* buffer = m_mgr.gsto_data(m_gsto);
0287       if(!buffer) return;
0288       void* pos_xyzs = (char*)buffer+a_pos_xyzs;
0289       //void* pos_nms = (char*)buffer+a_pos_nms;
0290       if(m_gl_id && m_created) {
0291         ::glBegin(a_mode);
0292         float* pos = (float*)pos_xyzs;
0293         for(size_t index=0;index<a_elems;index++,pos+=3) {
0294           ::glVertex3f(*(pos+0),*(pos+1),*(pos+2));
0295         }
0296         ::glEnd();
0297       }
0298 #endif
0299       }break;
0300 
0301     case tools::sg::gsto_memory:{
0302       float* buffer = m_mgr.gsto_data(m_gsto);
0303       if(!buffer) return;
0304       void* pos_xyzs = (char*)buffer+a_pos_xyzs;
0305       void* pos_nms = (char*)buffer+a_pos_nms;
0306       _draw_vn(a_mode,a_elems,pos_xyzs,pos_nms);
0307       }break;
0308     }
0309   }
0310 
0311   virtual void draw_gsto_vcn(tools::gl::mode_t a_mode,size_t a_elems,bufpos a_pos_xyzs,bufpos a_pos_rgbas,bufpos a_pos_nms){
0312 
0313     switch(m_mgr.get_gsto_mode()){
0314 
0315     case tools::sg::gsto_gl_vbo:{
0316 #ifdef TOOLX_HAS_GL_VBO
0317       _draw_vcn(a_mode,a_elems,(char*)NULL+a_pos_xyzs,(char*)NULL+a_pos_rgbas,(char*)NULL+a_pos_nms);
0318 #endif
0319       }break;
0320 
0321     case tools::sg::gsto_gl_list:{
0322 #ifdef TOOLX_HAS_GL_LIST
0323       float* buffer = m_mgr.gsto_data(m_gsto);
0324       if(!buffer) return;
0325       void* pos_xyzs = (char*)buffer+a_pos_xyzs;
0326       void* pos_rgbas = (char*)buffer+a_pos_rgbas;
0327       void* pos_nms = (char*)buffer+a_pos_nms;
0328       if(m_gl_id && m_created) {
0329         ::glBegin(a_mode);
0330         float* pos = (float*)pos_xyzs;
0331         float* pco = (float*)pos_rgbas;
0332         float* pnm = (float*)pos_nms;
0333         for(size_t index=0;index<a_elems;
0334             index++,pos+=3,pco+=4,pnm+=3) {
0335           ::glVertex3f(*(pos+0),*(pos+1),*(pos+2));
0336           ::glColor4f (*(pco+0),*(pco+1),*(pco+2),*(pco+3));
0337           ::glNormal3f(*(pnm+0),*(pnm+1),*(pnm+2));
0338         }
0339         ::glEnd();
0340       }
0341 #endif
0342       }break;
0343 
0344     case tools::sg::gsto_memory:{
0345       float* buffer = m_mgr.gsto_data(m_gsto);
0346       if(!buffer) return;
0347       void* pos_xyzs = (char*)buffer+a_pos_xyzs;
0348       void* pos_rgbas = (char*)buffer+a_pos_rgbas;
0349       void* pos_nms = (char*)buffer+a_pos_nms;
0350       _draw_vcn(a_mode,a_elems,pos_xyzs,pos_rgbas,pos_nms);
0351       }break;
0352     }
0353   }
0354 
0355   /////////////////////////////////////////////////////////////////
0356   /////////////////////////////////////////////////////////////////
0357   /////////////////////////////////////////////////////////////////
0358 
0359   virtual void clear_color(float a_r,float a_g,float a_b,float a_a){
0360     ::glClearColor(a_r,a_g,a_b,a_a);
0361     ::glClear(GL_COLOR_BUFFER_BIT);
0362   }
0363   virtual void color4f(float a_r,float a_g,float a_b,float a_a){
0364     ::glColor4f(a_r,a_g,a_b,a_a);
0365   }
0366   virtual void line_width(float a_v){::glLineWidth(a_v);}
0367   virtual void point_size(float a_v){::glPointSize(a_v);}
0368   virtual void set_polygon_offset(bool a_v) {
0369     if(a_v) ::glEnable(GL_POLYGON_OFFSET_FILL);
0370     else    ::glDisable(GL_POLYGON_OFFSET_FILL);
0371     ::glPolygonOffset(1.,1.);
0372   }
0373   virtual void normal(float a_x,float a_y,float a_z) {
0374     ::glNormal3f(a_x,a_y,a_z);
0375   }
0376 
0377   virtual void set_winding(tools::sg::winding_type a_v) {
0378     if(a_v==tools::sg::winding_ccw)
0379       ::glFrontFace(GL_CCW);
0380     else
0381       ::glFrontFace(GL_CW);
0382   }
0383 
0384   virtual void set_shade_model(tools::sg::shade_type a_v) {
0385     if(a_v==tools::sg::shade_smooth)
0386       ::glShadeModel(GL_SMOOTH);
0387     else
0388       ::glShadeModel(GL_FLAT);
0389   }
0390 
0391   virtual void set_cull_face(bool a_on) {
0392     if(a_on) ::glEnable(GL_CULL_FACE);
0393     else     ::glDisable(GL_CULL_FACE);
0394   }
0395 
0396   virtual void set_point_smooth(bool a_on) {
0397     if(a_on) ::glEnable(GL_POINT_SMOOTH);
0398     else     ::glDisable(GL_POINT_SMOOTH);
0399   }
0400 
0401   virtual void set_line_smooth(bool a_on) {
0402     if(a_on) ::glEnable(GL_LINE_SMOOTH);
0403     else     ::glDisable(GL_LINE_SMOOTH);
0404   }
0405 
0406   virtual void set_depth_test(bool a_on) {
0407     if(a_on) ::glEnable(GL_DEPTH_TEST);
0408     else     ::glDisable(GL_DEPTH_TEST);
0409   }
0410 
0411   virtual void load_proj_matrix(const tools::mat4f& a_mtx) {
0412     ::glMatrixMode(GL_PROJECTION);
0413     ::glLoadMatrixf(a_mtx.data());
0414   }
0415 
0416   virtual void load_model_matrix(const tools::mat4f& a_mtx) {
0417     ::glMatrixMode(GL_MODELVIEW);
0418     ::glLoadMatrixf(a_mtx.data());
0419 /*
0420     tools::mat4f tmp(a_mtx);
0421     tmp.no_translate();
0422     tools::mat4f normal_matrix;
0423     if(!tmp.invert(normal_matrix)) {
0424       m_out << "toolx::sg::GL_action::render::load_model_matrix :"
0425             << " can't invert model matrix."
0426             << std::endl;
0427     }
0428     normal_matrix.transpose();
0429 
0430     tools::mat4f to_check(a_mtx);
0431     to_check.no_translate();
0432     float fepsilon = 1e-10;
0433     if(!normal_matrix.equal_prec(to_check,fepsilon,tools::ffabs)) {
0434       mat_dump(m_out,"problem with normal_matrix ",normal_matrix);
0435       mat_dump(m_out,"expected",to_check);
0436     }
0437 */
0438   }
0439 
0440   virtual unsigned int max_lights() {return GL_MAX_LIGHTS;}
0441 
0442   virtual void enable_light(unsigned int a_light,
0443                             float a_dx,float a_dy,float a_dz,
0444                             float a_r,float a_g,float a_b,float a_a,
0445                             float a_ar,float a_ag,float a_ab,float a_aa){
0446     ::glEnable(GL_LIGHTING);
0447     GLenum light = GL_LIGHT0+a_light;
0448     //::printf("debug : GL_MAX_LIGHTS %d\n",GL_MAX_LIGHTS);
0449 
0450     float params[4];
0451     params[0] = -a_dx;
0452     params[1] = -a_dy;
0453     params[2] = -a_dz;
0454     params[3] = 0; //0 tells that it is a directional light.
0455     ::glLightfv(light,GL_POSITION,params);
0456 
0457     //params[0] = a_dir[0];
0458     //params[1] = a_dir[1];
0459     //params[2] = a_dir[2];
0460     //::glLightfv(light,GL_SPOT_DIRECTION,params);
0461 
0462     params[0] = a_r;
0463     params[1] = a_g;
0464     params[2] = a_b;
0465     params[3] = a_a;
0466     ::glLightfv(light,GL_DIFFUSE,params);
0467     ::glLightfv(light,GL_SPECULAR,params); //coin/SoDirectionalLight does that.
0468 
0469     params[0] = a_ar;
0470     params[1] = a_ag;
0471     params[2] = a_ab;
0472     params[3] = a_aa;
0473     ::glLightfv(light,GL_AMBIENT,params); //coin/SoDirectionalLight does that.
0474 
0475     // coin/SoDirectionalLight does the below :
0476     ::glLightf(light, GL_SPOT_EXPONENT, 0.0);
0477     ::glLightf(light, GL_SPOT_CUTOFF, 180.0);
0478     ::glLightf(light, GL_CONSTANT_ATTENUATION, 1);
0479     ::glLightf(light, GL_LINEAR_ATTENUATION, 0);
0480     ::glLightf(light, GL_QUADRATIC_ATTENUATION, 0);
0481 
0482     //::printf("debug : GL_MAX_LIGHTS %d\n",GL_MAX_LIGHTS);
0483 
0484     ::glEnable(light);
0485   }
0486 
0487   virtual void set_lighting(bool a_on) {
0488     if(a_on) ::glEnable(GL_LIGHTING);
0489     else     ::glDisable(GL_LIGHTING);
0490   }
0491   virtual void set_blend(bool a_on) {
0492     if(a_on) ::glEnable(GL_BLEND);
0493     else     ::glDisable(GL_BLEND);
0494   }
0495 
0496   virtual void restore_state(unsigned int a_ret_num_light) {
0497     const tools::sg::state& _state = state();
0498     ::glMatrixMode(GL_PROJECTION);
0499     ::glLoadMatrixf(_state.m_proj.data());
0500 
0501     ::glMatrixMode(GL_MODELVIEW);
0502     ::glLoadMatrixf(_state.m_model.data());
0503 
0504     if(_state.m_GL_LIGHTING) ::glEnable(GL_LIGHTING);
0505     else                     ::glDisable(GL_LIGHTING);
0506 
0507     if(_state.m_GL_DEPTH_TEST) ::glEnable(GL_DEPTH_TEST);
0508     else                       ::glDisable(GL_DEPTH_TEST);
0509 
0510     if(_state.m_GL_CULL_FACE) ::glEnable(GL_CULL_FACE);
0511     else                      ::glDisable(GL_CULL_FACE);
0512 
0513     if(_state.m_GL_POINT_SMOOTH) ::glEnable(GL_POINT_SMOOTH);
0514     else                         ::glDisable(GL_POINT_SMOOTH);
0515 
0516     if(_state.m_GL_LINE_SMOOTH) ::glEnable(GL_LINE_SMOOTH);
0517     else                        ::glDisable(GL_LINE_SMOOTH);
0518 
0519     if(_state.m_GL_POLYGON_OFFSET_FILL) ::glEnable(GL_POLYGON_OFFSET_FILL);
0520     else                                ::glDisable(GL_POLYGON_OFFSET_FILL);
0521 
0522     if(_state.m_GL_TEXTURE_2D) ::glEnable(GL_TEXTURE_2D);
0523     else                       ::glDisable(GL_TEXTURE_2D);
0524 
0525     if(_state.m_GL_BLEND) ::glEnable(GL_BLEND);
0526     else                  ::glDisable(GL_BLEND);
0527 
0528     if(_state.m_winding==tools::sg::winding_ccw) {
0529       ::glFrontFace(GL_CCW);
0530     } else {
0531       ::glFrontFace(GL_CW);
0532     }
0533 
0534     if(_state.m_shade_model==tools::sg::shade_smooth)
0535       ::glShadeModel(GL_SMOOTH);
0536     else
0537       ::glShadeModel(GL_FLAT);
0538 
0539     ::glColor4f(_state.m_color.r(),
0540                 _state.m_color.g(),
0541                 _state.m_color.b(),
0542                 _state.m_color.a());
0543 
0544     ::glNormal3f(_state.m_normal.x(),
0545                  _state.m_normal.y(),
0546                  _state.m_normal.z());
0547 
0548     // The "return of separator" state had ret_num_light.
0549     // The restored state has m_light.
0550     // We have to glDisable lights with index in [m_light,ret_num_light-1]
0551     for(unsigned int index=_state.m_light;index<a_ret_num_light;index++) {
0552       ::glDisable(GL_LIGHT0+index);
0553     }
0554 
0555     ::glLineWidth(_state.m_line_width);
0556 
0557     ::glPointSize(_state.m_point_size);
0558 
0559 #if TARGET_OS_IPHONE
0560 // GL-ES
0561 #elif defined(ANDROID)
0562 // GL-ES
0563 #else
0564     ::glDisable(GL_POLYGON_STIPPLE); //CoinGL : reading a .wrl having Material::transparency may enable GL_POLYGON_STIPPLE.
0565 #endif
0566   }
0567 
0568   virtual tools::sg::render_manager& render_manager() {return m_mgr;}
0569 public:
0570   GL_action(GL_manager& a_mgr,std::ostream& a_out,unsigned int a_ww,unsigned int a_wh)
0571   :parent(a_out,a_ww,a_wh)
0572   ,m_mgr(a_mgr)
0573   ,m_gsto(0)
0574 #ifdef TOOLX_HAS_GL_LIST
0575   ,m_created(false)
0576   ,m_gl_id(0)
0577 #endif
0578   {}
0579   virtual ~GL_action(){}
0580 public:
0581   GL_action(const GL_action& a_from)
0582   :parent(a_from)
0583   ,m_mgr(a_from.m_mgr)
0584   ,m_gsto(0)
0585 #ifdef TOOLX_HAS_GL_LIST
0586   ,m_created(false)
0587   ,m_gl_id(0)
0588 #endif
0589   {}
0590   GL_action& operator=(const GL_action& a_from){
0591     render_action::operator=(a_from);
0592     m_gsto = 0;
0593 #ifdef TOOLX_HAS_GL_LIST
0594     m_created = false;
0595     m_gl_id = 0;
0596 #endif
0597     return *this;
0598   }
0599 protected:
0600   void _draw_v(tools::gl::mode_t a_mode,size_t a_elems,const void* a_pos_xyzs){
0601     ::glEnableClientState(GL_VERTEX_ARRAY);
0602     ::glVertexPointer(3,GL_FLOAT,0,a_pos_xyzs);
0603     ::glDrawArrays(a_mode,0,(GLsizei)a_elems);
0604     ::glDisableClientState(GL_VERTEX_ARRAY);
0605   }
0606 
0607   void _draw_vc(tools::gl::mode_t a_mode,size_t a_elems,const void* a_pos_xyzs,const void* a_pos_rgbas){
0608 
0609     ::glEnableClientState(GL_VERTEX_ARRAY);
0610     ::glEnableClientState(GL_COLOR_ARRAY);
0611 
0612     ::glVertexPointer(3,GL_FLOAT,0,a_pos_xyzs);
0613     ::glColorPointer(4,GL_FLOAT,0,a_pos_rgbas);
0614 
0615     ::glDrawArrays(a_mode,0,(GLsizei)a_elems);
0616 
0617     ::glDisableClientState(GL_COLOR_ARRAY);
0618     ::glDisableClientState(GL_VERTEX_ARRAY);
0619   }
0620 
0621   void _draw_vn(tools::gl::mode_t a_mode,size_t a_elems,const void* a_pos_xyzs,const void* a_pos_nms){
0622     ::glEnableClientState(GL_VERTEX_ARRAY);
0623     ::glEnableClientState(GL_NORMAL_ARRAY);
0624 
0625     ::glVertexPointer(3,GL_FLOAT,0,a_pos_xyzs);
0626     ::glNormalPointer(GL_FLOAT,0,a_pos_nms);
0627 
0628     ::glDrawArrays(a_mode,0,(GLsizei)a_elems);
0629 
0630     ::glDisableClientState(GL_NORMAL_ARRAY);
0631     ::glDisableClientState(GL_VERTEX_ARRAY);
0632   }
0633 
0634   void _draw_vcn(tools::gl::mode_t a_mode,size_t a_elems,const void* a_pos_xyzs,const void* a_pos_rgbas,const void* a_pos_nms){
0635     ::glEnableClientState(GL_VERTEX_ARRAY);
0636     ::glEnableClientState(GL_COLOR_ARRAY);
0637     ::glEnableClientState(GL_NORMAL_ARRAY);
0638 
0639     ::glVertexPointer(3,GL_FLOAT,0,a_pos_xyzs);
0640     ::glColorPointer(4,GL_FLOAT,0,a_pos_rgbas);
0641     ::glNormalPointer(GL_FLOAT,0,a_pos_nms);
0642 
0643     ::glDrawArrays(a_mode,0,(GLsizei)a_elems);
0644 
0645     ::glDisableClientState(GL_COLOR_ARRAY);
0646     ::glDisableClientState(GL_NORMAL_ARRAY);
0647     ::glDisableClientState(GL_VERTEX_ARRAY);
0648   }
0649 
0650 protected:
0651   GL_manager& m_mgr;
0652   gstoid m_gsto;
0653 #ifdef TOOLX_HAS_GL_LIST
0654   bool m_created;
0655   gstoid m_gl_id;
0656 #endif
0657 };
0658 
0659 }}
0660 
0661 
0662 #endif