cgv
Loading...
Searching...
No Matches
ellipsoid_renderer.h
1#pragma once
2
3#include "surface_renderer.h"
4
5#include "gl/lib_begin.h"
6
7namespace cgv { // @<
8 namespace render { // @<
9 class CGV_API ellipsoid_renderer;
10
12
15 extern CGV_API ellipsoid_renderer& ref_ellipsoid_renderer(context& ctx, int ref_count_change = 0);
16
19 {
20 /*@name ellipsoid rendering attributes*/
22
23 float size_scale = 1.0f;
25 cgv::vec3 size = { 1.0f };
27 };
28
30 class CGV_API ellipsoid_renderer : public surface_renderer
31 {
32 protected:
33 bool has_sizes = false;
34 bool has_orientations = false;
36 std::string get_default_prog_name() const override { return "ellipsoid.glpr"; }
38 render_style* create_render_style() const override { return new ellipsoid_render_style(); }
39 public:
43 void enable_attribute_array_manager(const context& ctx, attribute_array_manager& aam);
45 void disable_attribute_array_manager(const context& ctx, attribute_array_manager& aam);
47 template <typename T = float>
48 void set_size(const context& ctx, const T& size) {
49 has_sizes = true;
50 ref_prog().set_attribute(ctx, ref_prog().get_attribute_location(ctx, "size"), size);
51 }
53 template <typename T = float>
54 void set_size_array(const context& ctx, const std::vector<T>& sizes) {
55 has_sizes = true;
56 set_attribute_array(ctx, "size", sizes);
57 }
59 template <typename T>
60 void set_size_array(const context& ctx, const T* sizes, size_t nr_elements, unsigned stride_in_bytes = 0) {
61 has_sizes = true;
62 set_attribute_array(ctx, "size", sizes, nr_elements, stride_in_bytes);
63 }
65 void remove_size_array(const context& ctx);
67 template <typename T = float>
68 void set_orientation(const context& ctx, const cgv::math::quaternion<T>& orientation) {
69 has_orientations = true;
70 ref_prog().set_attribute(ctx, ref_prog().get_attribute_location(ctx, "orientation"), orientation);
71 }
73 template <typename T = float>
74 void set_orientation_array(const context& ctx, const std::vector<cgv::math::quaternion<T>>& orientations) {
75 has_orientations = true;
76 set_attribute_array(ctx, "orientation", orientations);
77 }
79 template <typename T>
80 void set_orientation_array(const context& ctx, const T* orientations, size_t nr_elements, unsigned stride_in_bytes = 0) {
81 has_orientations = true;
82 set_attribute_array(ctx, "orientation", orientations, nr_elements, stride_in_bytes);
83 }
85 void remove_orientation_array(const context& ctx);
87 bool validate_attributes(const context& ctx) const;
89 bool enable(context& ctx);
91 bool disable(context& ctx);
93 void draw(context& ctx, size_t start, size_t count,
94 bool use_strips = false, bool use_adjacency = false, uint32_t strip_restart_index = -1);
95 };
96
98 {
99 bool self_reflect(cgv::reflect::reflection_handler& rh);
100 };
102 }
103}
104
105
106#include <cgv/config/lib_end.h>
implements a quaternion.
Definition quaternion.h:21
the self reflection handler is passed to the virtual self_reflect() method of cgv::base::base.
attribute array manager used to upload arrays to gpu
base class for all drawables, which is independent of the used rendering API.
Definition context.h:627
renderer that supports splatting of ellipsoids
void set_orientation_array(const context &ctx, const std::vector< cgv::math::quaternion< T > > &orientations)
use this function if you store spheres in vec4 with the 4th component the radius
render_style * create_render_style() const override
create and return the default render style
std::string get_default_prog_name() const override
return the default shader program name
base classes for renderers that support surface rendering
ellipsoid_renderer & ref_ellipsoid_renderer(context &ctx, int ref_count_change)
reference to a singleton ellipsoid renderer that can be shared among drawables
the cgv namespace
Definition print.h:11
this reflection traits implementation is used for external self_reflect implementations of instances ...
render style for ellipsoid rendere
base class for all render styles
Definition renderer.h:16