cgv
Loading...
Searching...
No Matches
drawable.h
1#pragma once
2
3#include <cgv/base/base.h>
4#include <cgv/base/traverser.h>
5#include <cgv/render/context.h>
6#include <cgv/math/fray.h>
7#include <cgv/render/view.h>
8
9#include "lib_begin.h"
10
11namespace cgv {
12 namespace render {
13
15class CGV_API drawable : public base::traverse_policy
16{
17private:
19 context* ctx;
20public:
22 drawable();
23
25 void hide();
27 void show();
29 bool is_visible() const;
30
32 context* get_context() const;
34 void set_context(context* _ctx);
36
37 view* find_view_as_node(size_t view_idx = 0) const;
39
41 bool get_world_location(int x, int y, const view& V, dvec3& world_location, double* window_z_ptr = 0) const;
43 cgv::ray3 get_world_ray(int x, int y, view* view_ptr, const cgv::dmat4& modelview_projection_window_matrix) const;
45 void post_redraw();
47 void force_redraw();
48
50 virtual bool init(context&);
52 virtual void resize(unsigned int w, unsigned int h);
54 virtual void init_frame(context&);
56 virtual void draw(context&);
58 virtual void finish_draw(context&);
60 virtual void finish_frame(context&);
62 virtual void after_finish(context&);
64 virtual void clear(context&);
66 virtual void destruct(context&) final;
67};
68
70class CGV_API multi_pass_drawable : public drawable
71{
72protected:
73 // mark current render pass
74 int current_render_pass;
75 // store recursion depth on which render passes are initiated
76 unsigned render_pass_recursion_depth;
77public:
83 void perform_render_pass(context& ctx, int rp_idx, RenderPass rp = RP_USER_DEFINED, int excluded_flags = RPF_HANDLE_SCREEN_SHOT, int included_flags = 0);
85 void initiate_terminal_render_pass(int rp_idx);
87 bool multi_pass_ignore_finish(const context& ctx);
89 bool multi_pass_terminate(const context& ctx);
90};
91
92 } // namespace render
93} // namespace cgv
94
95#include <cgv/config/lib_end.h>
nodes should inherit from this policy class to allow selective tree traversals
Definition traverser.h:24
base class for all drawables, which is independent of the used rendering API.
Definition context.h:670
bool get_world_location(int x, int y, const view &V, dvec3 &world_location, double *window_z_ptr=0) const
use given view together with depth buffer of context in order to compute the world location of the po...
Definition drawable.cxx:59
context * get_context() const
access the current context. The context will be available latestly in the init method but not in the ...
Definition drawable.cxx:37
virtual void init_frame(context &)
this method is called in one pass over all drawables before the draw method
Definition drawable.cxx:125
cgv::ray3 get_world_ray(int x, int y, view *view_ptr, const cgv::dmat4 &modelview_projection_window_matrix) const
compute ray from eye of given view_ptr through pixel at given mouse location (x,y) according to given...
Definition drawable.cxx:91
void set_context(context *_ctx)
set the current focus context, this should only be called by the context itself
Definition drawable.cxx:9
virtual void finish_draw(context &)
this method is called when the current drawable is left in a tree traversal that calls the draw metho...
Definition drawable.cxx:133
virtual void destruct(context &) final
do not use destruct for a drawable but clear!!
Definition drawable.cxx:150
virtual void draw(context &)
overload to draw the content of this drawable
Definition drawable.cxx:129
void force_redraw()
forces a redraw right now. This cannot be called from init, init_frame, draw, finish_draw,...
Definition drawable.cxx:109
virtual void resize(unsigned int w, unsigned int h)
callback to announce resizing of the output window
Definition drawable.cxx:121
void hide()
hide the drawable
Definition drawable.cxx:21
virtual void after_finish(context &)
this method is called in one pass over all drawables after finish frame
Definition drawable.cxx:142
virtual void finish_frame(context &)
this method is called in one pass over all drawables after drawing
Definition drawable.cxx:137
drawable()
default construction
Definition drawable.cxx:14
virtual bool init(context &)
this method is called after creation or recreation of the context, return whether all necessary funct...
Definition drawable.cxx:116
virtual void clear(context &)
clear all objects living in the context like textures or display lists
Definition drawable.cxx:147
view * find_view_as_node(size_t view_idx=0) const
convenience function to find the view control in the current hierarchy
Definition drawable.cxx:49
void show()
show the drawable
Definition drawable.cxx:26
void post_redraw()
posts a redraw event to the current context if one is available
Definition drawable.cxx:43
bool is_visible() const
check whether the drawable is visible
Definition drawable.cxx:31
bool multi_pass_terminate(const context &ctx)
check in after_finish method, whether this was the terminating render pass
Definition drawable.cxx:193
void perform_render_pass(context &ctx, int rp_idx, RenderPass rp=RP_USER_DEFINED, int excluded_flags=RPF_HANDLE_SCREEN_SHOT, int included_flags=0)
call to initiate a render pass in the init_frame method after initiate_render_pass_recursion() has su...
Definition drawable.cxx:171
bool initiate_render_pass_recursion(context &ctx)
call in init_frame method to check whether the recursive render passes need to be initiated
Definition drawable.cxx:163
bool multi_pass_ignore_finish(const context &ctx)
check in after_finish method, whether this should be directly exited with a return statement
Definition drawable.cxx:183
void initiate_terminal_render_pass(int rp_idx)
call after last recursive render pass to use current render pass for last render pass
Definition drawable.cxx:178
multi_pass_drawable()
construct to be not inside of a render pass
Definition drawable.cxx:157
defines a symmetric view with the following quantities:
Definition view.h:22
namespace for api independent GPU programming
RenderPass
Enumeration of different render passes, which can be queried from the context and used to specify a n...
Definition context.h:133
@ RP_USER_DEFINED
user defined renderpass
Definition context.h:142
@ RPF_HANDLE_SCREEN_SHOT
whether to perform a screen shot if this was scheduled
Definition context.h:177
this header is dependency free
Definition print.h:11
cgv::math::fray< float, 3 > ray3
3d ray using 32 bit single precision floating point type
Definition fray.h:87
cgv::math::fvec< double, 3 > dvec3
declare type of 3d double precision floating point vectors
Definition fvec.h:701
cgv::math::fmat< double, 4, 4 > dmat4
declare type of 4x4 matrices
Definition fmat.h:481