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 ] [ 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 ]

  1 // Copyright (C) 2010, Guy Barrand. All rights reserved.
  2 // See the file tools.license for terms.
  3 
  4 #ifndef toolx_sg_GL_viewer
  5 #define toolx_sg_GL_viewer
  6 
  7 #include <tools/sg/viewer>
  8 
  9 #include "GL_manager"
 10 #include "GL_action"
 11 
 12 namespace toolx {
 13 namespace sg {
 14 
 15 class GL_viewer : public tools::sg::viewer {
 16   TOOLS_HEADER(GL_viewer,toolx::sg::GL_viewer,tools::sg::viewer)
 17 public:
 18   void render() {
 19     if(!m_ww) return;
 20     if(!m_wh) return;
 21 
 22     m_gl_mgr.begin_render(0,0,m_ww,m_wh,
 23                           m_clear_color.r(),
 24                           m_clear_color.g(),
 25                           m_clear_color.b(),
 26                           m_clear_color.a());
 27 
 28     GL_action action(m_gl_mgr,m_out,m_ww,m_wh);
 29     action.state().m_use_gsto = m_use_gsto;
 30 
 31     action.set_do_transparency(false);
 32     action.set_have_to_do_transparency(false);
 33     
 34     m_sg.render(action);
 35     if(!action.end()) { //check that matrices stack are ok.
 36       m_out << "toolx::sg::GL_viewer : bad gl_action end." << std::endl;
 37     } else {
 38       if(action.have_to_do_transparency()) {
 39         action.set_do_transparency(true);
 40         m_sg.render(action);
 41         if(!action.end()) { //check that matrices stack are ok.
 42           m_out << "toolx::sg::GL_viewer : bad gl_action end." << std::endl;
 43         }
 44       }
 45     }
 46 
 47     //after_render();
 48 
 49     m_gl_mgr.end_render();
 50   }
 51 
 52 public:
 53   GL_viewer(std::ostream& a_out,unsigned int a_width,unsigned int a_height)
 54   :parent(a_out,a_width,a_height)
 55   ,m_gl_mgr(a_out)
 56   {}
 57   virtual ~GL_viewer(){
 58     //WARNING : nodes may refer m_gl_mgr (to handle gstos/texs), then
 59     //          we have to delete them first.
 60     m_sg.clear();
 61   }
 62 public:
 63   GL_viewer(const GL_viewer& a_from)
 64   :parent(a_from)
 65   ,m_gl_mgr(a_from.m_gl_mgr)
 66   {}
 67   GL_viewer& operator=(const GL_viewer& a_from){
 68     parent::operator=(a_from);
 69     m_gl_mgr = a_from.m_gl_mgr;
 70     return *this;
 71   }
 72 protected:
 73   GL_manager m_gl_mgr;
 74 };
 75 
 76 }}
 77 
 78 #endif