cgv
render_info.h
1 #pragma once
2 
3 #include <vector>
4 #include <cgv/render/context.h>
5 #include <cgv/render/vertex_buffer.h>
6 #include <cgv/render/shader_program.h>
7 #include <cgv/render/attribute_array_binding.h>
8 #include <cgv/render/textured_material.h>
9 
10 #include "lib_begin.h"
11 
12 namespace cgv {
13  namespace render {
14 enum DrawCallType
15 {
16  RCT_ARRAYS,
17  RCT_INDEXED,
18  RCT_ARRAYS_INSTANCED,
19  RCT_INDEXED_INSTANCED
20 };
21 enum AlphaMode
22 {
23  AM_OPAQUE = 0,
24  AM_MASK = 1,
25  AM_BLEND = 2,
26  AM_MASK_AND_BLEND = 3
27 };
28 enum VertexAttributeID
29 {
30  VA_BY_NAME = -1,
31  VA_POSITION,
32  VA_NORMAL,
33  VA_TEXCOORD,
34  VA_COLOR
35 };
36 struct vertex_attribute
37 {
38  VertexAttributeID vertex_attribute_id;
39  std::string name;
40  type_descriptor element_type;
41  uint32_t vbo_index;
42  size_t byte_offset;
43  size_t element_count;
44  uint32_t stride;
45 };
46 struct CGV_API attribute_array
47 {
48  std::vector<vertex_attribute> vas;
49  attribute_array_binding* aab_ptr;
50  shader_program* prog;
51 
52  void add_attribute(type_descriptor element_type, uint32_t vbo_index,
53  size_t byte_offset, size_t element_count, uint32_t stride,
54  VertexAttributeID vertex_attribute_id, std::string name = "");
55 };
56 struct draw_call {
57  AlphaMode alpha_mode;
58  float alpha_cutoff;
59  DrawCallType draw_call_type;
60  PrimitiveType primitive_type;
61  uint32_t material_index;
62  uint32_t aa_index;
63  uint32_t vertex_offset;
64  uint32_t count;
65  cgv::type::info::TypeId index_type;
66  void* indices;
67  uint32_t instance_count;
68  shader_program* prog;
69 };
75 class CGV_API render_info : public render_types
76 {
77 public:
80 protected:
82  std::vector<textured_material*> materials;
84  std::vector<texture*> textures;
86  std::vector<vertex_buffer*> vbos;
88  std::vector<attribute_array> aas;
90  std::vector<draw_call> draw_calls;
92  void draw(context& ctx, const draw_call& dc, const draw_call* prev_dc = 0, const draw_call* next_dc = 0, bool use_materials = true);
93 public:
95  render_info();
97  const std::vector<textured_material*>& get_materials() const;
99  const std::vector<vertex_buffer*>& get_vbos() const;
101  const std::vector<attribute_array>& get_aas() const;
103  const std::vector<texture*>& get_textures() const;
105  const std::vector<draw_call>& get_draw_calls() const;
107  std::vector<textured_material*>& ref_materials();
109  std::vector<vertex_buffer*>& ref_vbos();
111  std::vector<attribute_array>& ref_aas();
113  std::vector<texture*>& ref_textures();
115  std::vector<draw_call>& ref_draw_calls();
117  virtual bool bind(context& ctx, shader_program& prog, bool force_success, int aa_index = -1);
119  void draw_all(context& ctx, bool skip_opaque = false, bool skip_blended = false, bool use_materials = true);
121  void destruct(cgv::render::context& ctx);
122 };
123  }
124 }
125 
126 #include <cgv/config/lib_end.h>
cgv::type::info::TypeId
TypeId
ids for the different types and type constructs
Definition: type_id.h:12
cgv::render::render_info::aas
std::vector< attribute_array > aas
store attribute bindings
Definition: render_info.h:88
cgv::render::render_info::idx_type
cgv::type::uint32_type idx_type
define index type
Definition: render_info.h:79
cgv::render::shader_program
Definition: shader_program.h:25
cgv::render::render_info
Definition: render_info.h:76
cgv::type::uint32_type
unsigned int uint32_type
this type provides an 32 bit unsigned integer type
Definition: standard_types.h:20
cgv::render::render_info::materials
std::vector< textured_material * > materials
store materials
Definition: render_info.h:82
cgv
the cgv namespace
Definition: vr_calib.cxx:9
cgv::render::render_info::vbos
std::vector< vertex_buffer * > vbos
store buffers
Definition: render_info.h:86
cgv::render::context
Definition: context.h:525
cgv::render::PrimitiveType
PrimitiveType
different primitive types
Definition: context.h:177
cgv::render::render_info::textures
std::vector< texture * > textures
store textures
Definition: render_info.h:84
cgv::render::render_info::draw_calls
std::vector< draw_call > draw_calls
store vector of render calls
Definition: render_info.h:90