cgv
Loading...
Searching...
No Matches
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
12namespace cgv {
13 namespace render {
14enum DrawCallType
15{
16 RCT_ARRAYS,
17 RCT_INDEXED,
18 RCT_ARRAYS_INSTANCED,
19 RCT_INDEXED_INSTANCED
20};
21enum AlphaMode
22{
23 AM_OPAQUE = 0,
24 AM_MASK = 1,
25 AM_BLEND = 2,
26 AM_MASK_AND_BLEND = 3
27};
28enum VertexAttributeID
29{
30 VA_BY_NAME = -1,
31 VA_POSITION,
32 VA_NORMAL,
33 VA_TEXCOORD,
34 VA_COLOR
35};
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};
46struct CGV_API attribute_array
47{
48 std::vector<vertex_attribute> vas;
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};
56struct 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};
75class CGV_API render_info
76{
77public:
80protected:
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);
93public:
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>
the attribute_array_binding allows to define vertex attributes (i.e.
base class for all drawables, which is independent of the used rendering API.
Definition context.h:621
the mesh_render_info structure manages vertex buffer objects for attribute and element buffers as wel...
Definition render_info.h:76
std::vector< texture * > textures
store textures
Definition render_info.h:84
std::vector< textured_material * > materials
store materials
Definition render_info.h:82
std::vector< vertex_buffer * > vbos
store buffers
Definition render_info.h:86
std::vector< attribute_array > aas
store attribute bindings
Definition render_info.h:88
std::vector< draw_call > draw_calls
store vector of render calls
Definition render_info.h:90
cgv::type::uint32_type idx_type
define index type
Definition render_info.h:79
a shader program combines several shader code fragments to a complete definition of the shading pipel...
PrimitiveType
different primitive types
Definition context.h:225
TypeId
ids for the different types and type constructs
Definition type_id.h:12
unsigned int uint32_type
this type provides an 32 bit unsigned integer type
the cgv namespace
Definition print.h:11
compact type description of data that can be sent to the context; convertible to int
Definition context.h:47