Warning, /include/Geant4/toolx/sg/GL_viewer 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_viewer
0005 #define toolx_sg_GL_viewer
0006
0007 #include <tools/sg/viewer>
0008
0009 #include "GL_manager"
0010 #include "GL_action"
0011
0012 namespace toolx {
0013 namespace sg {
0014
0015 class GL_viewer : public tools::sg::viewer {
0016 TOOLS_HEADER(GL_viewer,toolx::sg::GL_viewer,tools::sg::viewer)
0017 public:
0018 void render() {
0019 if(!m_ww) return;
0020 if(!m_wh) return;
0021
0022 m_gl_mgr.begin_render(0,0,m_ww,m_wh,
0023 m_clear_color.r(),
0024 m_clear_color.g(),
0025 m_clear_color.b(),
0026 m_clear_color.a());
0027
0028 GL_action action(m_gl_mgr,m_out,m_ww,m_wh);
0029 action.state().m_use_gsto = m_use_gsto;
0030
0031 action.set_do_transparency(false);
0032 action.set_have_to_do_transparency(false);
0033
0034 m_sg.render(action);
0035 if(!action.end()) { //check that matrices stack are ok.
0036 m_out << "toolx::sg::GL_viewer : bad gl_action end." << std::endl;
0037 } else {
0038 if(action.have_to_do_transparency()) {
0039 action.set_do_transparency(true);
0040 m_sg.render(action);
0041 if(!action.end()) { //check that matrices stack are ok.
0042 m_out << "toolx::sg::GL_viewer : bad gl_action end." << std::endl;
0043 }
0044 }
0045 }
0046
0047 //after_render();
0048
0049 m_gl_mgr.end_render();
0050 }
0051
0052 public:
0053 GL_viewer(std::ostream& a_out,unsigned int a_width,unsigned int a_height)
0054 :parent(a_out,a_width,a_height)
0055 ,m_gl_mgr(a_out)
0056 {}
0057 virtual ~GL_viewer(){
0058 //WARNING : nodes may refer m_gl_mgr (to handle gstos/texs), then
0059 // we have to delete them first.
0060 m_sg.clear();
0061 }
0062 public:
0063 GL_viewer(const GL_viewer& a_from)
0064 :parent(a_from)
0065 ,m_gl_mgr(a_from.m_gl_mgr)
0066 {}
0067 GL_viewer& operator=(const GL_viewer& a_from){
0068 parent::operator=(a_from);
0069 m_gl_mgr = a_from.m_gl_mgr;
0070 return *this;
0071 }
0072 protected:
0073 GL_manager m_gl_mgr;
0074 };
0075
0076 }}
0077
0078 #endif