g4tools  5.4.0
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
tools::sg::render_gstos Class Referenceabstract
Inheritance diagram for tools::sg::render_gstos:
Inheritance graph
[legend]
Collaboration diagram for tools::sg::render_gstos:
Collaboration graph
[legend]

Public Member Functions

virtual void visit (gstos_add &a_visitor, draw_type a_style)=0
 
bool gstos_render (render_action &a_action)
 
bool gstos_render_no_style (render_action &a_action)
 
 render_gstos ()
 
virtual ~render_gstos ()
 
 render_gstos (const render_gstos &a_from)
 
render_gstosoperator= (const render_gstos &a_from)
 
- Public Member Functions inherited from tools::sg::gstos
size_t num_gstos () const
 

Protected Member Functions

virtual unsigned int create_gsto (std::ostream &, sg::render_manager &a_mgr)
 
- Protected Member Functions inherited from tools::sg::gstos
 gstos ()
 
virtual ~gstos ()
 
 gstos (const gstos &)
 
gstosoperator= (const gstos &a_from)
 
unsigned int get_tex_id (std::ostream &a_out, render_manager &a_mgr, const img_byte &a_img, bool a_NEAREST)
 
unsigned int get_gsto_id (std::ostream &a_out, render_manager &a_mgr)
 
void clean_gstos ()
 
void clean_gstos (render_manager *a_mgr)
 
unsigned int _find (render_manager *a_mgr)
 

Protected Attributes

size_t m_gstos_points_sz
 
size_t m_gstos_lines_sz
 
size_t m_gstos_tris_sz
 
size_t m_gstos_nms_sz
 
- Protected Attributes inherited from tools::sg::gstos
std::vector< std::pair< unsigned int, render_manager * > > m_gstos
 

Detailed Description

Definition at line 15 of file render_gstos.

Constructor & Destructor Documentation

◆ render_gstos() [1/2]

tools::sg::render_gstos::render_gstos ( )
inline

Definition at line 121 of file render_gstos.

◆ ~render_gstos()

virtual tools::sg::render_gstos::~render_gstos ( )
inlinevirtual

Definition at line 122 of file render_gstos.

122 {}

◆ render_gstos() [2/2]

tools::sg::render_gstos::render_gstos ( const render_gstos a_from)
inline

Definition at line 124 of file render_gstos.

Member Function Documentation

◆ create_gsto()

virtual unsigned int tools::sg::render_gstos::create_gsto ( std::ostream &  ,
sg::render_manager a_mgr 
)
inlineprotectedvirtual

Reimplemented from tools::sg::gstos.

Definition at line 20 of file render_gstos.

20  {
21  std::vector<float> gsto_data;
22 
23  gstos_add _add;
24  visit(_add,draw_points);
25  append(gsto_data,_add.m_xyzs);
26  m_gstos_points_sz = _add.m_xyzs.size();
27 
28  _add.clear();
29  visit(_add,draw_lines);
30  append(gsto_data,_add.m_xyzs);
31  m_gstos_lines_sz = _add.m_xyzs.size();
32 
33  _add.clear();
34  visit(_add,draw_filled);
35  append(gsto_data,_add.m_xyzs);
36  m_gstos_tris_sz = _add.m_xyzs.size();
37  append(gsto_data,_add.m_nms);
38  m_gstos_nms_sz = _add.m_nms.size();
39 
40  if(gsto_data.empty()) return 0;
41 
42  return a_mgr.create_gsto_from_data(gsto_data);
43  }

◆ gstos_render()

bool tools::sg::render_gstos::gstos_render ( render_action a_action)
inline

_id

Definition at line 45 of file render_gstos.

45  {
46  const state& state = a_action.state();
47 
48  bool draw_edges = false;
49  if(state.m_draw_type==draw_filled) draw_edges = state.m_GL_LIGHTING?false:true;
50 
51  if(state.m_use_gsto) {
52  unsigned int _id = get_gsto_id(a_action.out(),a_action.render_manager());
53  if(_id) {
54  bufpos pxyzs = 0;
55  bufpos plines = pxyzs+m_gstos_points_sz*sizeof(float);
56  bufpos ptris = plines+m_gstos_lines_sz*sizeof(float);
57  bufpos pnms = ptris+m_gstos_tris_sz*sizeof(float);
58 
59  a_action.begin_gsto(_id);
60  if(draw_edges) {
61  //a_action.set_lighting(false); //NOTE : we should do that if style==draw_fill !
62  a_action.color4f(0,0,0,1); //if lighten, then rendered grey.
63  a_action.line_width(1);
64 
65  a_action.draw_gsto_v(gl::lines(),m_gstos_lines_sz/3,plines);
66 
67  //pushes back the filled polygons to avoid z-fighting with lines
68  a_action.set_polygon_offset(true);
69 
70  a_action.color4f(state.m_color);
71  a_action.line_width(state.m_line_width);
72  //a_action.set_lighting(state.m_GL_LIGHTING);
73  }
74  if(state.m_draw_type==draw_points) {
75  a_action.draw_gsto_v(gl::points(),m_gstos_points_sz/3,pxyzs);
76  } else if(state.m_draw_type==draw_lines) {
77  a_action.draw_gsto_v(gl::lines(),m_gstos_lines_sz/3,plines);
78  } else {
79  a_action.draw_gsto_vn(gl::triangles(),m_gstos_tris_sz/3,ptris,pnms);
80  }
81  if(draw_edges) a_action.set_polygon_offset(state.m_GL_POLYGON_OFFSET_FILL);
82  a_action.end_gsto();
83  return true;
84 
85  } else {
86  // use immediate rendering.
87  }
88 
89  } else {
90  clean_gstos(&a_action.render_manager());
91  }
92  return false;
93  }

◆ gstos_render_no_style()

bool tools::sg::render_gstos::gstos_render_no_style ( render_action a_action)
inline

_id

Definition at line 94 of file render_gstos.

94  { //for sg::markers.
95  const state& state = a_action.state();
96  if(state.m_use_gsto) {
97  unsigned int _id = get_gsto_id(a_action.out(),a_action.render_manager());
98  if(_id) {
99  bufpos pxyzs = 0;
100  bufpos plines = pxyzs+m_gstos_points_sz*sizeof(float);
101  bufpos ptris = plines+m_gstos_lines_sz*sizeof(float);
102  bufpos pnms = ptris+m_gstos_tris_sz*sizeof(float);
103 
104  a_action.begin_gsto(_id);
105  a_action.draw_gsto_v(gl::points(),m_gstos_points_sz/3,pxyzs);
106  a_action.draw_gsto_v(gl::lines(),m_gstos_lines_sz/3,plines);
107  a_action.draw_gsto_vn(gl::triangles(),m_gstos_tris_sz/3,ptris,pnms);
108  a_action.end_gsto();
109  return true;
110 
111  } else {
112  // use immediate rendering.
113  }
114 
115  } else {
116  clean_gstos(&a_action.render_manager());
117  }
118  return false;
119  }

◆ operator=()

render_gstos& tools::sg::render_gstos::operator= ( const render_gstos a_from)
inline

Definition at line 125 of file render_gstos.

125  {
126  parent::operator=(a_from);
127  m_gstos_points_sz = 0;
128  m_gstos_lines_sz = 0;
129  m_gstos_tris_sz = 0;
130  m_gstos_nms_sz = 0;
131  return *this;
132  }

◆ visit()

virtual void tools::sg::render_gstos::visit ( gstos_add a_visitor,
draw_type  a_style 
)
pure virtual

Implemented in tools::sg::cube.

Member Data Documentation

◆ m_gstos_lines_sz

size_t tools::sg::render_gstos::m_gstos_lines_sz
protected

Definition at line 135 of file render_gstos.

◆ m_gstos_nms_sz

size_t tools::sg::render_gstos::m_gstos_nms_sz
protected

Definition at line 137 of file render_gstos.

◆ m_gstos_points_sz

size_t tools::sg::render_gstos::m_gstos_points_sz
protected

Definition at line 134 of file render_gstos.

◆ m_gstos_tris_sz

size_t tools::sg::render_gstos::m_gstos_tris_sz
protected

Definition at line 136 of file render_gstos.


The documentation for this class was generated from the following file:
tools::sg::render_gstos::m_gstos_tris_sz
size_t m_gstos_tris_sz
Definition: render_gstos:136
tools::sg::render_gstos::m_gstos_points_sz
size_t m_gstos_points_sz
Definition: render_gstos:134
tools::gl::triangles
mode_t triangles()
Definition: glprims:20
tools::sg::gstos::clean_gstos
void clean_gstos()
Definition: gstos:89
tools::gl::lines
mode_t lines()
Definition: glprims:17
tools::sg::render_gstos::visit
virtual void visit(gstos_add &a_visitor, draw_type a_style)=0
tools::sg::draw_points
@ draw_points
Definition: enums:191
tools::sg::gstos::operator=
gstos & operator=(const gstos &a_from)
Definition: gstos:22
tools::sg::render_gstos::m_gstos_lines_sz
size_t m_gstos_lines_sz
Definition: render_gstos:135
tools::append
void append(std::vector< T > &a_vec, const std::vector< T > &a_from)
Definition: vmanip:66
tools::sg::draw_filled
@ draw_filled
Definition: enums:193
tools::sg::render_gstos::m_gstos_nms_sz
size_t m_gstos_nms_sz
Definition: render_gstos:137
tools::gl::points
mode_t points()
Definition: glprims:16
tools::sg::gstos::get_gsto_id
unsigned int get_gsto_id(std::ostream &a_out, render_manager &a_mgr)
Definition: gstos:60
tools::sg::bufpos
size_t bufpos
Definition: render_action:22
tools::sg::draw_lines
@ draw_lines
Definition: enums:192