72 lines
1.6 KiB
Plaintext
72 lines
1.6 KiB
Plaintext
// Copyright (C) 2010, Guy Barrand. All rights reserved.
|
|
// See the file tools.license for terms.
|
|
|
|
#ifndef tools_sg_GL_viewer
|
|
#define tools_sg_GL_viewer
|
|
|
|
#include <tools/sg/viewer>
|
|
|
|
#include "GL_manager"
|
|
#include "GL_action"
|
|
|
|
namespace tools {
|
|
namespace sg {
|
|
|
|
class GL_viewer : public tools::sg::viewer {
|
|
TOOLS_HEADER(GL_viewer,tools::sg::GL_viewer,tools::sg::viewer)
|
|
//public:
|
|
//virtual void after_render() {}
|
|
public:
|
|
void render() {
|
|
if(!m_ww) return;
|
|
if(!m_wh) return;
|
|
|
|
m_gl_mgr.begin_render(0,0,m_ww,m_wh,
|
|
m_clear_color.r(),
|
|
m_clear_color.g(),
|
|
m_clear_color.b(),
|
|
m_clear_color.a());
|
|
|
|
GL_action action(m_gl_mgr,m_out,m_ww,m_wh);
|
|
action.state().m_use_gsto = m_use_gsto;
|
|
|
|
m_sg.render(action);
|
|
if(!action.end()) { //check that matrices stack are ok.
|
|
m_out << "exib::sg::GL_viewer :"
|
|
<< " bad gl_action end."
|
|
<< std::endl;
|
|
}
|
|
|
|
//after_render();
|
|
|
|
m_gl_mgr.end_render();
|
|
}
|
|
|
|
public:
|
|
GL_viewer(std::ostream& a_out,unsigned int a_width,unsigned int a_height)
|
|
:parent(a_out,a_width,a_height)
|
|
,m_gl_mgr(a_out)
|
|
{}
|
|
virtual ~GL_viewer(){
|
|
//WARNING : nodes may refer m_gl_mgr (to handle gstos/texs), then
|
|
// we have to delete them first.
|
|
m_sg.clear();
|
|
}
|
|
public:
|
|
GL_viewer(const GL_viewer& a_from)
|
|
:parent(a_from)
|
|
,m_gl_mgr(a_from.m_gl_mgr)
|
|
{}
|
|
GL_viewer& operator=(const GL_viewer& a_from){
|
|
parent::operator=(a_from);
|
|
m_gl_mgr = a_from.m_gl_mgr;
|
|
return *this;
|
|
}
|
|
protected:
|
|
GL_manager m_gl_mgr;
|
|
};
|
|
|
|
}}
|
|
|
|
#endif
|