cgv
context.h
1 #pragma once
2 
3 #define _USE_MATH_DEFINES
4 #include <cgv/defines/deprecated.h>
5 #include <cgv/data/data_view.h>
6 #include <cgv/media/font/font.h>
7 #include <cgv/media/axis_aligned_box.h>
8 #include <cgv/media/illum/phong_material.hh>
9 #include <cgv/media/illum/textured_surface_material.h>
10 #include <cgv/media/illum/light_source.hh>
11 #include <cgv/signal/callback_stream.h>
12 #include <cgv/render/render_types.h>
13 #include <cgv/math/vec.h>
14 #include <cgv/math/inv.h>
15 #include <stack>
16 #include <vector>
17 #include <string>
18 
19 #include "lib_begin.h"
20 
21 namespace cgv {
22  namespace render {
23 
24 class CGV_API drawable;
25 class CGV_API textured_material;
26 
29  ET_VALUE,
30  ET_VECTOR,
31  ET_MATRIX
32 };
33 
36 {
37  cgv::type::info::TypeId coordinate_type : 8;
38  ElementType element_type : 4;
39  unsigned nr_rows : 4;
40  unsigned nr_columns : 4;
41  bool is_row_major : 1;
42  bool is_array : 1;
43  bool normalize : 1;
45  type_descriptor(int td = 0) { *reinterpret_cast<int*>(this) = td; }
47  type_descriptor(cgv::type::info::TypeId _coordinate_type, bool _normalize = false) : coordinate_type(_coordinate_type), element_type(ET_VALUE), nr_rows(1), nr_columns(1), is_row_major(false), is_array(false), normalize(_normalize) {}
49  type_descriptor(cgv::type::info::TypeId _coordinate_type, unsigned _nr_entries, bool _normalize = false) : coordinate_type(_coordinate_type), element_type(ET_VECTOR), nr_rows(_nr_entries), nr_columns(1), is_row_major(false), is_array(false), normalize(_normalize) {}
51  type_descriptor(cgv::type::info::TypeId _coordinate_type, unsigned _nr_rows, unsigned _nr_cols, bool _is_row_major, bool _normalize = false) : coordinate_type(_coordinate_type), element_type(ET_MATRIX), nr_rows(_nr_rows), nr_columns(_nr_cols), is_row_major(_is_row_major), is_array(false), normalize(_normalize) {}
53  type_descriptor(const type_descriptor& td, bool _is_array) : coordinate_type(td.coordinate_type), element_type(td.element_type), nr_rows(td.nr_rows), nr_columns(td.nr_columns), is_row_major(td.is_row_major), normalize(td.normalize), is_array(_is_array) {}
55  operator int() const { return *reinterpret_cast<const int*>(this); }
56 };
57 
59 enum RenderAPI {
60  RA_OPENGL,
61  RA_DIRECTX
62 };
63 
64 
66 enum RenderPass {
67  RP_NONE,
68  RP_MAIN,
76 };
77 
79 extern CGV_API std::string get_render_pass_name(RenderPass rp);
80 
83  RPF_NONE = 0, // no frame initialization is performed
84  RPF_SET_PROJECTION = 1, // whether to set default projection matrix
85  RPF_SET_MODELVIEW = 1 << 1, // whether to set default modelview matrix
86  RPF_SET_MODELVIEW_PROJECTION = RPF_SET_PROJECTION|RPF_SET_MODELVIEW, // whether to set default modelview and projection matrix
87  RPF_SET_LIGHTS = 1 << 2, // whether to define default lights
88  RPF_SET_MATERIAL = 1 << 3, // whether to define default material
89  RPF_SET_LIGHTS_ON = 1 << 4, // whether to turn on default lights
90  RPF_ENABLE_MATERIAL = 1 << 5, // whether to enable material
91  RPF_SET_LIGHTING = RPF_SET_LIGHTS|RPF_SET_LIGHTS_ON|RPF_ENABLE_MATERIAL, // whether to define and enable default lighting
92  RPF_CLEAR_COLOR = 1 << 6, // whether to clear the color buffer
93  RPF_CLEAR_DEPTH = 1 << 7, // whether to clear the depth buffer
94  RPF_CLEAR_STENCIL = 1 << 8, // whether to clear the depth buffer
95  RPF_CLEAR_ACCUM = 1 << 9, // whether to clear the accumulation buffer
96  RPF_CLEAR_ALL = RPF_CLEAR_COLOR|RPF_CLEAR_DEPTH|RPF_CLEAR_STENCIL|RPF_CLEAR_ACCUM, // whether to clear all buffers
97  RPF_DRAWABLES_INIT_FRAME = 1 << 10, // whether to call the init_frame method of the drawables
98  RPF_SET_STATE_FLAGS = 1 << 11, // whether to set depth buffer and culling flags
99  RPF_SET_CLEAR_COLOR = 1 << 12, // whether to set the clear color
100  RPF_SET_CLEAR_DEPTH = 1 << 13, // whether to set the clear color
101  RPF_SET_CLEAR_STENCIL = 1 << 14, // whether to set the clear color
102  RPF_SET_CLEAR_ACCUM = 1 << 15, // whether to set the accumulation buffer clear color
103  RPF_DRAWABLES_DRAW = 1 << 16, // whether to call draw and finish_draw methods of drawables
104  RPF_DRAWABLES_FINISH_FRAME = 1 << 17, // whether to call finish frame method of drawables
105  RPF_DRAW_TEXTUAL_INFO = 1 << 18, // whether to draw textual information
106  RPF_DRAWABLES_AFTER_FINISH = 1 << 19, // whether to call after finish method of drawables
107  RPF_HANDLE_SCREEN_SHOT = 1 << 20, // whether to perform a screen shot if this was scheduled
108  RPF_ALL = (1 << 21) - 1, // all flags set, defines default render pass
109  RPF_DEFAULT = RPF_ALL & ~ (RPF_CLEAR_ACCUM|RPF_SET_CLEAR_ACCUM|RPF_CLEAR_STENCIL|RPF_SET_CLEAR_STENCIL) // all flags set, defines default render pass
110 };
111 
113 enum MaterialSide { MS_NONE, MS_FRONT, MS_BACK, MS_FRONT_AND_BACK };
114 
117  IM_OFF, IM_ONE_SIDED, IM_TWO_SIDED
118 };
119 
122  CM_OFF, CM_BACKFACE, CM_FRONTFACE
123 };
124 
125 
127 enum TextureWrap {
128  TW_REPEAT = 0,
129  TW_CLAMP = 1,
130  TW_CLAMP_TO_EDGE = 2,
131  TW_CLAMP_TO_BORDER = 3,
132  TW_MIRROR_CLAMP = 4,
133  TW_MIRROR_CLAMP_TO_EDGE = 5,
134  TW_MIRROR_CLAMP_TO_BORDER = 6,
135  TW_MIRRORED_REPEAT = 7,
136  TW_LAST
137 };
138 
140 extern CGV_API std::string to_string(TextureWrap wrap);
141 
144  TF_NEAREST = 0,
145  TF_LINEAR = 1,
146  TF_NEAREST_MIPMAP_NEAREST = 2,
147  TF_LINEAR_MIPMAP_NEAREST = 3,
148  TF_NEAREST_MIPMAP_LINEAR = 4,
149  TF_LINEAR_MIPMAP_LINEAR = 5,
150  TF_ANISOTROP = 6,
151  TF_LAST
152 };
153 
156  TT_UNDEF,
157  TT_1D = 1,
158  TT_2D,
159  TT_3D,
160  TT_1D_ARRAY,
161  TT_2D_ARRAY,
162  TT_CUBEMAP,
163  TT_BUFFER
164 };
165 
168  TCS_PLUS_X,
169  TCS_MINUS_X,
170  TCS_PLUS_Y,
171  TCS_MINUS_Y,
172  TCS_PLUS_Z,
173  TCS_MINUS_Z
174 };
175 
178  PT_UNDEF,
179  PT_POINTS,
180  PT_LINES,
181  PT_LINES_ADJACENCY,
182  PT_LINE_STRIP,
183  PT_LINE_STRIP_ADJACENCY,
184  PT_LINE_LOOP,
185  PT_TRIANGLES,
186  PT_TRIANGLES_ADJACENCY,
187  PT_TRIANGLE_STRIP,
188  PT_TRIANGLE_STRIP_ADJACENCY,
189  PT_TRIANGLE_FAN,
190  PT_QUADS,
191  PT_QUAD_STRIP,
192  PT_POLYGON,
193  PT_PATCHES,
194  PT_LAST
195 };
196 
199 {
200  TS_CELL = 0,
201  TS_VERTEX = 1
202 };
203 
206 {
207  CF_LEQUAL,
208  CF_GEQUAL,
209  CF_LESS,
210  CF_GREATER,
211  CF_EQUAL,
212  CF_NOTEQUAL,
213  CF_ALWAYS,
214  CF_NEVER
215 };
216 
219  TA_NONE = 0,
220  TA_LEFT = 1, // center of left edge of text bounds
221  TA_RIGHT = 2, // center of right edge of text bounds
222  TA_TOP = 4, // center of top edge of text bounds
223  TA_BOTTOM = 8, // center of bottom edge of text bounds
224  TA_TOP_LEFT = TA_LEFT+TA_TOP, // top left corner of text bounds
225  TA_TOP_RIGHT = TA_RIGHT+TA_TOP, // top right corner of text bounds
226  TA_BOTTOM_LEFT = TA_LEFT+TA_BOTTOM, // bottom left corner of text bounds
227  TA_BOTTOM_RIGHT = TA_RIGHT+TA_BOTTOM // bottom right corner of text bounds
228 };
229 
231 extern CGV_API std::string to_string(TextureFilter filter_type);
232 
234 extern CGV_API std::string to_string(PrimitiveType pt);
235 
237 extern CGV_API std::string to_string(TextureType tt);
238 
240 extern CGV_API std::string to_string(TextureCubeSides tcs);
241 
242 class CGV_API context;
243 
245 class CGV_API render_component
246 {
247 public:
248  void* handle;
249  void* internal_format;
250  void* user_data;
252  const context* ctx_ptr;
254  mutable std::string last_error;
258  virtual bool is_created() const;
261  void put_id_void(void* ptr) const;
263  template <typename T>
264  void put_id(T& id) const { put_id_void(&id); }
265 };
266 
268 class CGV_API texture_base : public render_component
269 {
270 public:
271  TextureFilter mag_filter;
272  TextureFilter min_filter;
273  TextureWrap wrap_s;
274  TextureWrap wrap_t;
275  TextureWrap wrap_r;
276  float anisotropy;
277  float priority;
278  float border_color[4];
279  CompareFunction compare_function;
280  bool use_compare_function;
281  TextureType tt;
282  bool have_mipmaps;
284  texture_base(TextureType _tt = TT_UNDEF);
285 };
286 
287 
289 class CGV_API shader_program_base : public render_component
290 {
291 protected:
292  bool is_enabled;
293  friend class context;
294 
295  bool auto_detect_uniforms;
296  bool auto_detect_vertex_attributes;
297 
298  // uniforms
299  bool uses_view;
300  bool uses_material;
301  bool uses_lights;
302  bool uses_gamma;
303 
304  // vertex attribute names
305  int position_index;
306  int color_index;
307  bool context_sets_color;
308  int normal_index;
309  int texcoord_index;
310 
311 public:
312  PrimitiveType geometry_shader_input_type;
313  PrimitiveType geometry_shader_output_type;
314  int geometry_shader_output_count;
317  // configure program
318  void specify_standard_uniforms(bool view, bool material, bool lights, bool gamma);
319  void specify_standard_vertex_attribute_names(context& ctx, bool color = true, bool normal = true, bool texcoord = true);
320  void specify_vertex_attribute_names(context& ctx, const std::string& position, const std::string& color = "", const std::string& normal = "", const std::string& texcoord = "");
321  // uniforms
322  bool does_use_view() const { return uses_view; }
323  bool does_use_material() const { return uses_material; }
324  bool does_use_lights() const { return uses_lights; }
325  bool does_use_gamma() const { return uses_gamma; }
326 
327  // vertex attribute names
328  void allow_context_to_set_color(bool allow);
329  int get_position_index() const { return position_index; }
330  int get_color_index() const { return color_index; }
331  bool does_context_set_color() const { return context_sets_color; }
332  int get_normal_index() const { return normal_index; }
333  int get_texcoord_index() const { return texcoord_index; }
334 };
335 
338 {
339 protected:
340  bool is_enabled;
341  friend class context;
342 public:
345 };
346 
347 
350  VBT_UNDEF = -1,
351  VBT_VERTICES,
352  VBT_INDICES,
353  VBT_TEXTURE,
354  VBT_UNIFORM,
355  VBT_FEEDBACK
356 };
357 
360  VBU_STREAM_DRAW, VBU_STREAM_READ, VBU_STREAM_COPY, VBU_STATIC_DRAW, VBU_STATIC_READ, VBU_STATIC_COPY, VBU_DYNAMIC_DRAW, VBU_DYNAMIC_READ, VBU_DYNAMIC_COPY
361 };
362 
364 class CGV_API vertex_buffer_base : public render_component
365 {
366 public:
373 };
374 
375 
377 class CGV_API frame_buffer_base : public render_component
378 {
379 protected:
380  friend class context;
381  bool is_enabled;
382  std::vector<int> enabled_color_attachments;
383  bool attached[16];
384  int width, height;
385 public:
388 };
389 
391 enum ShaderType { ST_DETECT, ST_COMPUTE, ST_VERTEX, ST_TESS_CONTROL, ST_TESS_EVALUATION, ST_GEOMETRY, ST_FRAGMENT };
392 
395  FB_0 = 0,
396  FB_1 = 1,
397  FB_2 = 2,
398  FB_3 = 3,
399  FB_4 = 4,
400  FB_5 = 5,
401  FB_6 = 6,
402  FB_7 = 7,
403  FB_BACK = 128,
404  FB_FRONT = 129,
405  FB_LEFT = 512,
406  FB_RIGHT = 1024,
407  FB_BACK_LEFT = FB_BACK+FB_LEFT,
408  FB_BACK_RIGHT = FB_BACK+FB_RIGHT,
409  FB_FRONT_LEFT = FB_FRONT+FB_LEFT,
410  FB_FRONT_RIGHT = FB_FRONT+FB_RIGHT
411 };
412 
415  MAX_NR_GEOMETRY_SHADER_OUTPUT_VERTICES
416 };
417 
418 // forward declaration of all render components
419 class CGV_API texture;
420 class CGV_API render_buffer;
421 class CGV_API frame_buffer;
422 class CGV_API shader_code;
423 class CGV_API shader_program;
424 
425 // declare some colors by name
426 extern CGV_API float black[4], white[4], gray[4], green[4], brown[4], dark_red[4];
427 extern CGV_API float cyan[4], yellow[4], red[4], blue[4];
428 
430 struct CGV_API context_config
431 {
434  bool depth_buffer;
456 
464  bool debug;
468  context_config();
471  bool self_reflect(cgv::reflect::reflection_handler& srh);
472 };
473 
476 
478 struct CGV_API render_config : public cgv::base::base, public context_config
479 {
482  int fullscreen_monitor;
489 
492  bool abort_on_error;
499 
501  render_config();
503  std::string get_type_name() const;
505  bool self_reflect(cgv::reflect::reflection_handler& srh);
506 };
507 
510 
512 extern CGV_API render_config_ptr get_render_config();
513 
516 {
521 };
522 
524 class CGV_API context : public render_types, public context_config
525 {
526 public:
527  friend class CGV_API attribute_array_manager;
528  friend class CGV_API render_component;
529  friend class CGV_API texture;
530  friend class CGV_API render_buffer;
531  friend class CGV_API frame_buffer;
532  friend class CGV_API shader_code;
533  friend class CGV_API shader_program;
534  friend class CGV_API attribute_array_binding;
535  friend class CGV_API vertex_buffer;
544 protected:
545  friend class shader_program_base;
546 
568  float gamma;
570  std::stack<dmat4> modelview_matrix_stack, projection_matrix_stack;
572  std::stack<std::vector<window_transformation> > window_transformation_stack;
574  std::stack<frame_buffer_base*> frame_buffer_stack;
576  std::stack<shader_program_base*> shader_program_stack;
577 public:
579  shader_program_base* get_current_program() const;
580 protected:
582  std::stack<attribute_array_binding_base*> attribute_array_binding_stack;
585  {
586  bool enabled;
587  vec3 eye_position;
588  vec3 eye_spot_direction;
589  int light_source_index;
590  };
592  std::vector<void*> enabled_light_source_handles;
596  std::map<void*, std::pair<cgv::media::illum::light_source, light_source_status> > light_sources;
598  virtual void on_lights_changed();
600  static const unsigned nr_default_light_sources = 2;
602  cgv::media::illum::light_source default_light_source[nr_default_light_sources];
604  void* default_light_source_handles[nr_default_light_sources];
612  struct render_info
613  {
614  RenderPass pass;
615  RenderPassFlags flags;
616  void* user_data;
617  };
619  std::stack<render_info> render_pass_stack;
623  float bg_r, bg_g, bg_b, bg_a, bg_d;
624  int bg_s;
625  float bg_accum_r, bg_accum_g, bg_accum_b, bg_accum_a;
631  int cursor_x, cursor_y;
639  int tab_size;
641  int x_offset, y_offset;
647  bool do_screen_shot;
649  virtual void process_text(const std::string& text);
651  virtual void draw_text(const std::string& text);
652 
653  virtual int query_integer_constant(ContextIntegerConstant cic) const = 0;
654  virtual void destruct_render_objects();
655  virtual void put_id(void* handle, void* ptr) const = 0;
656 
657  virtual cgv::data::component_format texture_find_best_format(const cgv::data::component_format& cf, render_component& rc, const std::vector<cgv::data::data_view>* palettes = 0) const = 0;
658  virtual bool texture_create (texture_base& tb, cgv::data::data_format& df) const = 0;
659  virtual bool texture_create (texture_base& tb, cgv::data::data_format& target_format, const cgv::data::const_data_view& data, int level, int cube_side = -1, int num_array_layers = 0, const std::vector<cgv::data::data_view>* palettes = 0) const = 0;
660  virtual bool texture_create_from_buffer (texture_base& tb, cgv::data::data_format& df, int x, int y, int level) const = 0;
661  virtual bool texture_replace (texture_base& tb, int x, int y, int z_or_cube_side, const cgv::data::const_data_view& data, int level, const std::vector<cgv::data::data_view>* palettes = 0) const = 0;
662  virtual bool texture_replace_from_buffer(texture_base& tb, int x, int y, int z_or_cube_side, int x_buffer, int y_buffer, unsigned int width, unsigned int height, int level) const = 0;
663  virtual bool texture_generate_mipmaps (texture_base& tb, unsigned int dim) const = 0;
664  virtual bool texture_destruct (texture_base& tb) const = 0;
665  virtual bool texture_set_state (const texture_base& tb) const = 0;
666  virtual bool texture_enable (texture_base& tb, int tex_unit, unsigned int nr_dims) const = 0;
667  virtual bool texture_disable (texture_base& tb, int tex_unit, unsigned int nr_dims) const = 0;
668 
669  virtual bool render_buffer_create (render_component& rc, cgv::data::component_format& cf, int& _width, int& _height) const = 0;
670  virtual bool render_buffer_destruct (render_component& rc) const = 0;
671 
672  static void get_buffer_list(frame_buffer_base& fbb, std::vector<int>& buffers, int offset = 0);
673  virtual bool frame_buffer_create (frame_buffer_base& fbb) const;
674  virtual bool frame_buffer_attach (frame_buffer_base& fbb, const render_component& rb, bool is_depth, int i) const;
675  virtual bool frame_buffer_attach (frame_buffer_base& fbb, const texture_base& t, bool is_depth, int level, int i, int z) const;
676  virtual bool frame_buffer_is_complete(const frame_buffer_base& fbb) const = 0;
677  virtual bool frame_buffer_enable (frame_buffer_base& fbb);
678  virtual bool frame_buffer_disable (frame_buffer_base& fbb);
679  virtual bool frame_buffer_destruct (frame_buffer_base& fbb) const;
680  virtual int frame_buffer_get_max_nr_color_attachments() const = 0;
681  virtual int frame_buffer_get_max_nr_draw_buffers() const = 0;
682 
683  virtual bool shader_code_create (render_component& sc, ShaderType st, const std::string& source) const = 0;
684  virtual bool shader_code_compile (render_component& sc) const = 0;
685  virtual void shader_code_destruct(render_component& sc) const = 0;
686 
687  virtual bool shader_program_create (shader_program_base& spb) const = 0;
688  virtual void shader_program_attach(shader_program_base& spb, const render_component& sc) const = 0;
689  virtual void shader_program_detach(shader_program_base& spb, const render_component& sc) const = 0;
690  virtual bool shader_program_link(shader_program_base& spb) const;
691  virtual bool shader_program_set_state(shader_program_base& spb) const = 0;
692  virtual bool shader_program_enable (shader_program_base& spb);
693  virtual bool shader_program_disable(shader_program_base& spb);
694  virtual bool shader_program_destruct(shader_program_base& spb) const;
695  virtual int get_uniform_location(const shader_program_base& spb, const std::string& name) const = 0;
696  virtual bool set_uniform_void(shader_program_base& spb, int loc, type_descriptor value_type, const void* value_ptr) const = 0;
697  virtual bool set_uniform_array_void(shader_program_base& spb, int loc, type_descriptor value_type, const void* value_ptr, size_t nr_elements) const = 0;
698  virtual int get_attribute_location(const shader_program_base& spb, const std::string& name) const = 0;
699  virtual bool set_attribute_void(shader_program_base& spb, int loc, type_descriptor value_type, const void* value_ptr) const = 0;
700 
701  virtual bool attribute_array_binding_create (attribute_array_binding_base& aab) const = 0;
702  virtual bool attribute_array_binding_destruct(attribute_array_binding_base& aab) const;
703  virtual bool attribute_array_binding_enable (attribute_array_binding_base& aab);
704  virtual bool attribute_array_binding_disable (attribute_array_binding_base& aab);
705  virtual bool set_attribute_array_void(attribute_array_binding_base* aab, int loc, type_descriptor value_type, const vertex_buffer_base* vbb, const void* ptr, size_t nr_elements = 0, unsigned stride_in_bytes = 0) const = 0;
706  virtual bool set_element_array(attribute_array_binding_base* aab, const vertex_buffer_base* vbb) const = 0;
707  virtual bool enable_attribute_array(attribute_array_binding_base* aab, int loc, bool do_enable) const = 0;
708  virtual bool is_attribute_array_enabled(const attribute_array_binding_base* aab, int loc) const = 0;
709 
710  virtual bool vertex_buffer_bind(const vertex_buffer_base& vbb, VertexBufferType _type) const = 0;
711  virtual bool vertex_buffer_create(vertex_buffer_base& vbb, const void* array_ptr, size_t size_in_bytes) const = 0;
712  virtual bool vertex_buffer_replace(vertex_buffer_base& vbb, size_t offset, size_t size_in_bytes, const void* array_ptr) const = 0;
713  virtual bool vertex_buffer_copy(const vertex_buffer_base& src, size_t src_offset, vertex_buffer_base& target, size_t target_offset, size_t size_in_bytes) const = 0;
714  virtual bool vertex_buffer_copy_back(vertex_buffer_base& vbb, size_t offset, size_t size_in_bytes, void* array_ptr) const = 0;
715  virtual bool vertex_buffer_destruct(vertex_buffer_base& vbb) const = 0;
716 public:
718  context();
720  virtual ~context();
722  virtual void error(const std::string& message, const render_component* rc = 0) const;
723 
726  virtual void init_render_pass();
729  virtual void draw_textual_info();
731  virtual void perform_screen_shot();
733  virtual void finish_render_pass();
735 
738  virtual void configure_new_child(cgv::base::base_ptr child);
741  virtual RenderAPI get_render_api() const = 0;
743  unsigned get_render_pass_recursion_depth() const;
745  virtual RenderPass get_render_pass() const;
747  virtual RenderPassFlags get_render_pass_flags() const;
749  virtual void* get_render_pass_user_data() const;
751  virtual RenderPassFlags get_default_render_pass_flags() const;
753  virtual void set_default_render_pass_flags(RenderPassFlags);
755  virtual void render_pass(RenderPass render_pass = RP_MAIN,
756  RenderPassFlags render_pass_flags = RPF_ALL,
757  void* user_data = 0);
759  void set_debug_render_passes(bool _debug);
761  bool get_debug_render_passes() const { return debug_render_passes; }
763  virtual bool in_render_process() const = 0;
765  virtual bool is_created() const = 0;
767  virtual bool is_current() const = 0;
769  virtual bool recreate_context();
771  virtual bool make_current() const = 0;
773  virtual void clear_current() const = 0;
775  virtual void attach_alpha_buffer(bool attach = true) = 0;
777  virtual void attach_depth_buffer(bool attach = true) = 0;
779  virtual void attach_stencil_buffer(bool attach = true) = 0;
781  virtual bool is_stereo_buffer_supported() const = 0;
783  virtual void attach_stereo_buffer(bool attach = true) = 0;
785  virtual void attach_accumulation_buffer(bool attach = true) = 0;
787  virtual void attach_multi_sample_buffer(bool attach = true) = 0;
789 
791  virtual unsigned int get_width() const = 0;
793  virtual unsigned int get_height() const = 0;
795  virtual void resize(unsigned int width, unsigned int height) = 0;
796 
797 
813  virtual bool read_frame_buffer(
814  data::data_view& dv,
815  unsigned int x = 0, unsigned int y = 0,
816  FrameBufferType buffer_type = FB_BACK,
819  int w = -1, int h = -1) = 0;
823  bool write_frame_buffer_to_image(
824  const std::string& file_name,
826  FrameBufferType buffer_type = FB_BACK,
827  unsigned int x = 0, unsigned int y = 0,
828  int w = -1, int h = -1,
829  float depth_offset = 0.9f, float depth_scale = 10.0f);
831  virtual void set_bg_color(float r, float g, float b, float a);
833  virtual void set_bg_alpha(float a);
835  virtual void set_bg_depth(float d);
837  virtual void set_bg_stencil(int s);
839  virtual void set_bg_accum_color(float r, float g, float b, float a);
841  virtual void set_bg_accum_alpha(float a);
843  virtual void set_bg_clr_idx(unsigned int idx);
845  unsigned int get_bg_clr_idx() const;
847  void put_bg_color(float* rgba) const;
849  float get_bg_alpha() const;
851  void put_bg_accum_color(float* rgba) const;
853  float get_bg_accum_alpha() const;
855  float get_bg_depth() const;
857  int get_bg_stencil() const;
859  virtual void post_redraw() = 0;
861  virtual void force_redraw() = 0;
863  virtual void announce_external_frame_buffer_change(void*& cgv_fbo_storage) = 0;
865  virtual void recover_from_external_frame_buffer_change(void* cgv_fbo_storage) = 0;
866 
869  virtual void enable_font_face(media::font::font_face_ptr font_face, float font_size);
872  virtual float get_current_font_size() const;
874  virtual media::font::font_face_ptr get_current_font_face() const;
876 
879  DEPRECATED("deprecated and ignored.") virtual void enable_phong_shading();
880  DEPRECATED("deprecated and ignored.") virtual void disable_phong_shading();
881  DEPRECATED("deprecated, use set_material instead.") virtual void enable_material(const cgv::media::illum::phong_material& mat = cgv::media::illum::default_material(), MaterialSide ms = MS_FRONT_AND_BACK, float alpha = 1);
882  DEPRECATED("deprecated and ignored.") virtual void disable_material(const cgv::media::illum::phong_material& mat = cgv::media::illum::default_material());
883  DEPRECATED("deprecated, use enable_material(textured_surface_material) instead.") virtual void enable_material(const textured_material& mat, MaterialSide ms = MS_FRONT_AND_BACK, float alpha = 1);
884  //DEPRECATED("deprecated, use disable_material(textured_surface_material) instead.") virtual void disable_material(const textured_material& mat) = 0;
886  virtual void set_gamma(float _gamma);
888  float get_gamma() const { return gamma; }
890  virtual void enable_sRGB_framebuffer(bool do_enable = true);
892  bool sRGB_framebuffer_enabled() { return sRGB_framebuffer; }
894  const rgba& get_color() const;
896  virtual void set_color(const rgba& clr);
898  virtual void set_color(const rgb& clr, float opacity = 1.0f) { set_color(rgba(clr[0], clr[1], clr[2], opacity)); }
900  virtual void set_material(const cgv::media::illum::surface_material& mat);
902  const cgv::media::illum::surface_material* get_current_material() const;
904  virtual void set_textured_material(const textured_material& mat);
906  virtual void enable_material(textured_material& mat) = 0;
908  virtual void disable_material(textured_material& mat) = 0;
910  void set_current_view(shader_program& prog, bool modelview_deps = true, bool projection_deps = true) const;
912  void set_current_material(shader_program& prog) const;
914  void set_current_lights(shader_program& prog) const;
916  vec3 get_light_eye_position(const cgv::media::illum::light_source& light, bool place_now) const;
918  vec3 get_light_eye_spot_direction(const cgv::media::illum::light_source& light, bool place_now) const;
920  virtual shader_program& ref_default_shader_program(bool texture_support = false) = 0;
922  virtual shader_program& ref_surface_shader_program(bool texture_support = false) = 0;
924  virtual void enumerate_program_uniforms(shader_program& prog, std::vector<std::string>& names, std::vector<int>* locations_ptr = 0, std::vector<int>* sizes_ptr = 0, std::vector<int>* types_ptr = 0, bool show = false) const = 0;
926  virtual void enumerate_program_attributes(shader_program& prog, std::vector<std::string>& names, std::vector<int>* locations_ptr = 0, std::vector<int>* sizes_ptr = 0, std::vector<int>* types_ptr = 0, bool show = false) const = 0;
928 
931  DEPRECATED("deprecated, use add_light_source instead.") void* enable_light(const cgv::media::illum::light_source& light) { return add_light_source(light); }
932  DEPRECATED("deprecated, use enable_light_source instead.") void disable_light(void* handle) { disable_light_source(handle); }
933  DEPRECATED("deprecated, use get_max_nr_enabled_light_sources instead.") unsigned get_max_nr_lights() const { return get_max_nr_enabled_light_sources(); }
935  size_t get_nr_light_sources() const;
937  void* add_light_source(const cgv::media::illum::light_source& light, bool enabled = true, bool place_now = false);
939  bool remove_light_source(void* handle);
941  const cgv::media::illum::light_source& get_light_source(void* handle) const;
943  const light_source_status& get_light_source_status(void* handle) const;
945  void set_light_source(void* handle, const cgv::media::illum::light_source& light, bool place_now = true);
947  void place_light_source(void* handle);
948 
950  virtual unsigned get_max_nr_enabled_light_sources() const;
952  size_t get_nr_enabled_light_sources() const;
954  void* get_enabled_light_source_handle(size_t i) const;
956  bool enable_light_source(void* handle);
958  bool disable_light_source(void* handle);
960 
969  virtual std::ostream& output_stream();
972  virtual void set_cursor(int x, int y);
974  virtual void get_cursor(int& x, int& y) const;
977  virtual void put_cursor_coords(const vec_type& p, int& x, int& y) const;
983  virtual void set_cursor(const vec_type& pos,
984  const std::string& text = "", TextAlignment ta = TA_BOTTOM_LEFT,
985  int x_offset=0, int y_offset=0);
987 
990  virtual void draw_edges_of_faces(
992  const float* vertices, const float* normals, const float* tex_coords,
993  const int* vertex_indices, const int* normal_indices, const int* tex_coord_indices,
994  int nr_faces, int face_degree, bool flip_normals = false) const = 0;
997  const float* vertices, const float* normals, const float* tex_coords,
998  const int* vertex_indices, const int* normal_indices, const int* tex_coord_indices,
999  int nr_faces, int face_degree, bool is_fan, bool flip_normals = false) const = 0;
1001  virtual void draw_faces(
1002  const float* vertices, const float* normals, const float* tex_coords,
1003  const int* vertex_indices, const int* normal_indices, const int* tex_coord_indices,
1004  int nr_faces, int face_degree, bool flip_normals = false) const = 0;
1006  virtual void draw_strip_or_fan(
1007  const float* vertices, const float* normals, const float* tex_coords,
1008  const int* vertex_indices, const int* normal_indices, const int* tex_coord_indices,
1009  int nr_faces, int face_degree, bool is_fan, bool flip_normals = false) const = 0;
1010 
1012  void tesselate_unit_square(bool flip_normals = false, bool edges = false);
1014  void tesselate_unit_cube(bool flip_normals = false, bool edges = false);
1016  virtual void tesselate_box(const cgv::media::axis_aligned_box<double, 3>& B, bool flip_normals, bool edges = false) const;
1018  void tesselate_unit_prism(bool flip_normals = false, bool edges = false);
1020  void tesselate_unit_disk(int resolution = 25, bool flip_normals = false, bool edges = false);
1022  void tesselate_unit_cone(int resolution = 25, bool flip_normals = false, bool edges = false);
1024  void tesselate_unit_cylinder(int resolution = 25, bool flip_normals = false, bool edges = false);
1026  void tesselate_unit_sphere(int resolution = 25, bool flip_normals = false, bool edges = false);
1028  void tesselate_unit_tetrahedron(bool flip_normals = false, bool edges = false);
1030  void tesselate_unit_octahedron(bool flip_normals = false, bool edges = false);
1032  void tesselate_unit_dodecahedron(bool flip_normals = false, bool edges = false);
1034  void tesselate_unit_icosahedron(bool flip_normals = false, bool edges = false);
1036  void tesselate_unit_torus(float minor_radius = 0.2f, int resolution = 25, bool flip_normals = false, bool edges = false);
1038 
1045  virtual void tesselate_arrow(double length = 1, double aspect = 0.1, double rel_tip_radius = 2.0, double tip_aspect = 0.3, int res = 25, bool edges = false);
1047  virtual void tesselate_arrow(const dvec3& start, const dvec3& end, double aspect = 0.1f, double rel_tip_radius = 2.0f, double tip_aspect = 0.3f, int res = 25, bool edges = false);
1049 
1052  virtual void draw_light_source(const cgv::media::illum::light_source& l, float intensity_scale, float light_scale);
1054 
1057  DEPRECATED("deprecated: use get_modelview_matrix() instead.") dmat_type get_V() const { return dmat_type(4,4,&get_modelview_matrix()(0,0)); }
1058  DEPRECATED("deprecated: use set_modelview_matrix() instead.") void set_V(const dmat_type& V) const { const_cast<context*>(this)->set_modelview_matrix(dmat4(4,4,&V(0,0))); }
1059  DEPRECATED("deprecated: use push_modelview_matrix() instead.") void push_V() { push_modelview_matrix(); }
1060  DEPRECATED("deprecated: use pop_modelview_matrix() instead.") void pop_V() { pop_modelview_matrix(); }
1061  DEPRECATED("deprecated: use get_projection_matrix() instead.") dmat_type get_P() const { return dmat_type(4, 4, &get_projection_matrix()(0, 0)); }
1062  DEPRECATED("deprecated: use set_projection_matrix() instead.") void set_P(const dmat_type& P) const { const_cast<context*>(this)->set_projection_matrix(dmat4(4,4,&P(0, 0))); }
1063  DEPRECATED("deprecated: use push_projection_matrix() instead.") void push_P() { push_projection_matrix(); }
1064  DEPRECATED("deprecated: use pop_projection_matrix() instead.") void pop_P() { pop_projection_matrix(); }
1065  DEPRECATED("deprecated: use get_device_matrix() instead.") dmat_type get_D() const { return dmat_type(4, 4, &get_window_matrix()(0, 0)); }
1066  DEPRECATED("deprecated: use get_modelview_projection_device_matrix() instead.") mat_type get_DPV() const { return dmat_type(4, 4, &get_modelview_projection_window_matrix()(0, 0)); }
1070  virtual void push_pixel_coords() = 0;
1072  virtual void pop_pixel_coords() = 0;
1074  virtual dmat4 get_modelview_matrix() const = 0;
1076  virtual void set_modelview_matrix(const dmat4& MV);
1078  virtual void mul_modelview_matrix(const dmat4& MV);
1080 
1086  void push_modelview_matrix();
1088  void pop_modelview_matrix();
1090  virtual dmat4 get_projection_matrix() const = 0;
1092  virtual void set_projection_matrix(const dmat4& P);
1094  virtual void mul_projection_matrix(const dmat4& P);
1096  void push_projection_matrix();
1098  void pop_projection_matrix();
1100  void push_window_transformation_array();
1102 
1104  virtual void pop_window_transformation_array();
1106  virtual void announce_external_viewport_change(ivec4& cgv_viewport_storage) = 0;
1108  virtual void recover_from_external_viewport_change(const ivec4& cgv_viewport_storage) = 0;
1110  virtual unsigned get_max_window_transformation_array_size() const = 0;
1111 protected:
1112  bool ensure_window_transformation_index(int& array_index);
1113 public:
1115 
1125  virtual void set_viewport(const ivec4& viewport, int array_index = -1);
1127 
1129  virtual void set_depth_range(const dvec2& depth_range = dvec2(0, 1), int array_index = -1);
1131  const std::vector<window_transformation>& get_window_transformation_array() const;
1133 
1138  dmat4 get_window_matrix(unsigned array_index = 0) const;
1140  dmat4 get_modelview_projection_window_matrix(unsigned array_index = 0) const;
1142  virtual double get_window_z(int x_window, int y_window) const = 0;
1144 
1146  inline vec3 get_model_point(int x_window, int y_window) const {
1147  return get_model_point(x_window, y_window, get_window_z(x_window, y_window));
1148  }
1150 
1152  inline vec3 get_model_point(int x_window, int y_window, double z_window) const {
1153  return get_model_point(x_window, y_window, z_window, get_modelview_projection_window_matrix());
1154  }
1156 
1158  inline vec3 get_model_point(int x_window, int y_window, const dmat4& modelview_projection_window_matrix) const {
1159  return get_model_point(x_window, y_window, get_window_z(x_window, y_window), modelview_projection_window_matrix);
1160  }
1162 
1164  inline vec3 get_model_point(int x_window, int y_window, double z_window, const dmat4& modelview_projection_window_matrix) const {
1165  return get_model_point(dvec3(x_window+0.5, y_window+0.5, z_window), modelview_projection_window_matrix);
1166  }
1168 
1170  inline vec3 get_model_point(const vec3& p_window) const {
1171  return get_model_point(p_window, get_modelview_projection_window_matrix());
1172  }
1174 
1176  vec3 get_model_point(const dvec3& p_window, const dmat4& modelview_projection_window_matrix) const;
1178  DEPRECATED("use get_window_matrix() instead.") dmat4 get_device_matrix() const { return get_window_matrix(); }
1180  DEPRECATED("use get_modelview_projection_window_matrix() instead.") dmat4 get_modelview_projection_device_matrix() const;
1182  DEPRECATED("use get_window_z()") double get_z_D(int x_D, int y_D) const { return get_window_z(x_D, y_D); }
1184  DEPRECATED("use get_model_point()") vec3 get_point_W(int x_D, int y_D) const { return get_model_point(x_D, y_D); }
1186  DEPRECATED("use get_model_point()") vec3 get_point_W(int x_D, int y_D, const dmat4& MPD) const { return get_model_point(x_D, y_D, MPD); }
1188  DEPRECATED("use get_model_point()") vec3 get_point_W(int x_D, int y_D, double z_D) const { return get_model_point(x_D, y_D, z_D); }
1190  DEPRECATED("use get_model_point()") vec3 get_point_W(int x_D, int y_D, double z_D, const dmat4& MPD) const { return get_model_point(x_D, y_D, z_D, MPD); }
1192  DEPRECATED("use get_model_point()") vec3 get_point_W(const vec3& p_D) const { return get_model_point(p_D); }
1194  DEPRECATED("use get_model_point()") vec3 get_point_W(const vec3& p_D, const dmat4& MPD) const { return get_model_point(p_D, MPD); }
1196 };
1197 
1202 extern CGV_API context* create_context(RenderAPI api = RA_OPENGL,
1203  unsigned int w = 800, unsigned int h = 600,
1204  const std::string& title = "", bool show = false);
1205 
1206 typedef context* (*context_creation_function_type)(RenderAPI api, unsigned int w, unsigned int h, const std::string& title, bool show);
1207 
1209 extern CGV_API void register_context_factory(context_creation_function_type);
1210 
1211 struct CGV_API context_factory_registration
1212 {
1213  context_factory_registration(context_creation_function_type fp);
1214 };
1215 
1216  }
1217 }
1218 
1219 #include <cgv/config/lib_end.h>
cgv::render::RP_SHADOW_MAP
@ RP_SHADOW_MAP
rendering of second eye
Definition: context.h:70
cgv::render::context::default_render_flags
RenderPassFlags default_render_flags
default render flags with which the main render pass is initialized
Definition: context.h:621
cgv::render::context::out_stream
cgv::signal::callback_stream out_stream
use a callback stream to write text to the opengl context
Definition: context.h:633
cgv::render::attribute_array_binding
Definition: attribute_array_binding.h:20
cgv::media::illum::light_source
>simple class to hold the properties of a light source
Definition: light_source.hh:17
cgv::render::context::post_redraw
virtual void post_redraw()=0
the context will be redrawn when the system is idle again
cgv::render::render_component
base interface for all render components
Definition: context.h:246
cgv::render::context::get_width
virtual unsigned int get_width() const =0
return the width of the window
cgv::data::component_format
Definition: component_format.h:58
cgv::math::fmat
matrix of fixed size dimensions
Definition: fmat.h:23
cgv::data::CF_RGB
@ CF_RGB
color format with two components R and G
Definition: component_format.h:29
cgv::render::type_descriptor
compact type description of data that can be sent to the context; convertible to int
Definition: context.h:36
cgv::render::context::pop_pixel_coords
virtual void pop_pixel_coords()=0
pop previously changed transformation matrices
cgv::render::context::enumerate_program_attributes
virtual void enumerate_program_attributes(shader_program &prog, std::vector< std::string > &names, std::vector< int > *locations_ptr=0, std::vector< int > *sizes_ptr=0, std::vector< int > *types_ptr=0, bool show=false) const =0
get list of program attributes
cgv::render::attribute_array_binding_base
base class for attribute_array_bindings
Definition: context.h:338
cgv::render::context::draw_edges_of_strip_or_fan
virtual void draw_edges_of_strip_or_fan(const float *vertices, const float *normals, const float *tex_coords, const int *vertex_indices, const int *normal_indices, const int *tex_coord_indices, int nr_faces, int face_degree, bool is_fan, bool flip_normals=false) const =0
pass geometry of given strip or fan to current shader program and generate draw calls to render lines...
cgv::render::ContextIntegerConstant
ContextIntegerConstant
integer constants that can be queried from context
Definition: context.h:414
cgv::render::view
Definition: view.h:22
cgv::render::MaterialSide
MaterialSide
different sides of a material
Definition: context.h:113
cgv::render::ShaderType
ShaderType
different shader types
Definition: context.h:391
cgv::render::context::DEPRECATED
DEPRECATED("use get_modelview_projection_window_matrix() instead.") dmat4 get_modelview_projection_device_matrix() const
return matrix to transfrom from model to device coordinates, i.e. the product of modelview,...
cgv::render::context::get_window_z
virtual double get_window_z(int x_window, int y_window) const =0
read the window z-coordinate from the depth buffer for the given window x- and y-coordinates
cgv::render::render_component::last_error
std::string last_error
a string that contains the last error
Definition: context.h:254
cgv::render::window_transformation::viewport
render_types::ivec4 viewport
viewport parameters [x0,y0,width,height]
Definition: context.h:518
cgv::render::render_buffer
Definition: render_buffer.h:16
cgv::render::type_descriptor::type_descriptor
type_descriptor(cgv::type::info::TypeId _coordinate_type, unsigned _nr_entries, bool _normalize=false)
construct descriptor for vectors
Definition: context.h:49
cgv::render::render_config::show_error_on_console
bool show_error_on_console
default: true
Definition: context.h:497
cgv::render::RP_TRANSPARENT_SURFACES
@ RP_TRANSPARENT_SURFACES
opaque surface rendering using z-Buffer
Definition: context.h:73
cgv::render::context::announce_external_viewport_change
virtual void announce_external_viewport_change(ivec4 &cgv_viewport_storage)=0
announce an external viewport change performed with rendering API to the cgv framework providing spac...
cgv::render::VertexBufferType
VertexBufferType
different vertex buffer types
Definition: context.h:349
cgv::render::context::announce_external_frame_buffer_change
virtual void announce_external_frame_buffer_change(void *&cgv_fbo_storage)=0
announce an external frame buffer change performed with rendering API to the cgv framework providing ...
cgv::type::info::TypeId
TypeId
ids for the different types and type constructs
Definition: type_id.h:12
cgv::render::context::current_font_size
float current_font_size
store current font size
Definition: context.h:635
cgv::render::VertexBufferUsage
VertexBufferUsage
different vertex buffer usages as defined in OpenGL
Definition: context.h:359
cgv::render::context::vec_type
cgv::math::vec< float > vec_type
dimension independent type of vectors
Definition: context.h:537
cgv::render::context::in_render_process
virtual bool in_render_process() const =0
return whether the context is currently in process of rendering
cgv::render::context::tab_size
int tab_size
size a tabs
Definition: context.h:639
cgv::render::TS_VERTEX
@ TS_VERTEX
for texture resulution N x M x L the tex_coord ranges from [1/2N, 1/2M, 1/2L] to [1-1/2N,...
Definition: context.h:201
cgv::render::context::debug_render_passes
bool debug_render_passes
whether to debug render passes
Definition: context.h:560
cgv::signal::callback_stream
connect to the write signal of the callback stream in order to process all text written to the stream
Definition: callback_stream.h:48
cgv::render::render_config
Definition: context.h:479
cgv::math::fvec< int32_t, 4 >
cgv::render::context::get_render_api
virtual RenderAPI get_render_api() const =0
return the used rendering API
cgv::render::vertex_buffer
Definition: vertex_buffer.h:13
cgv::render::RP_STEREO
@ RP_STEREO
the main rendering pass triggered by the redraw event
Definition: context.h:69
cgv::render::RP_SHADOW_VOLUME
@ RP_SHADOW_VOLUME
construction of shadow map
Definition: context.h:71
cgv::render::context::draw_in_compatibility_mode
bool draw_in_compatibility_mode
whether to do all drawing in compatibility mode, only possible if support_compatibility_mode is true,...
Definition: context.h:558
cgv::render::context_config::forward_compatible
bool forward_compatible
default: false
Definition: context.h:462
cgv::math::mat
Definition: mat.h:14
cgv::render::context::x_offset
int x_offset
offset in x and y direction where text starts
Definition: context.h:641
cgv::render::context::nr_identations
int nr_identations
current number of indentations
Definition: context.h:643
cgv::render::type_descriptor::type_descriptor
type_descriptor(const type_descriptor &td, bool _is_array)
construct descriptor for an array
Definition: context.h:53
cgv::render::context::current_material_ptr
const cgv::media::illum::surface_material * current_material_ptr
store pointer to current material
Definition: context.h:608
cgv::render::context::render_pass_stack
std::stack< render_info > render_pass_stack
store the current render pass
Definition: context.h:619
cgv::render::context::light_sources
std::map< void *, std::pair< cgv::media::illum::light_source, light_source_status > > light_sources
map handle to light source and light source status information
Definition: context.h:596
cgv::data::const_data_view
Definition: data_view.h:211
cgv::render::context::attach_stencil_buffer
virtual void attach_stencil_buffer(bool attach=true)=0
attach or detach (attach=false) stencil buffer to the current frame buffer if not present
cgv::render::render_config::window_height
int window_height
default: 480
Definition: context.h:487
cgv::render::texture_base
base interface for a texture
Definition: context.h:269
cgv::render::context_config::multi_sample_buffer
bool multi_sample_buffer
default: false
Definition: context.h:447
cgv::render::context::auto_set_view_in_current_shader_program
bool auto_set_view_in_current_shader_program
whether to automatically set viewing matrixes in current shader program, defaults to true
Definition: context.h:548
cgv::math::vec
A column vector class.
Definition: fvec.h:13
cgv::render::to_string
std::string to_string(TextureWrap wrap)
convert texture wrap to string
Definition: context.cxx:871
cgv::data::ref_ptr
Definition: ref_ptr.h:19
cgv::render::context::get_height
virtual unsigned int get_height() const =0
return the height of the window
cgv::render::context::mat_type
cgv::math::mat< float > mat_type
dimension independent type of matrices
Definition: context.h:539
cgv::render::vertex_buffer_base
base interface for a vertex buffer
Definition: context.h:365
cgv::render::context::window_transformation_stack
std::stack< std::vector< window_transformation > > window_transformation_stack
keep stack of window transformations
Definition: context.h:572
cgv::render::context::recover_from_external_viewport_change
virtual void recover_from_external_viewport_change(const ivec4 &cgv_viewport_storage)=0
restore cgv viewport to the state before the external change
cgv::render::texture
Definition: texture.h:15
cgv::render::context_config::version_minor
int version_minor
default: -1 ... minor version of maximum supported OpenGL version
Definition: context.h:460
cgv::render::vertex_buffer_base::usage
VertexBufferUsage usage
usage defaults to VBU_STATIC_DRAW
Definition: context.h:370
cgv::render::context::dmat_type
cgv::math::mat< double > dmat_type
dimension independent type of matrices
Definition: context.h:543
cgv::render::context::auto_set_gamma_in_current_shader_program
bool auto_set_gamma_in_current_shader_program
whether to automatically set gamma in current shader program, defaults to true
Definition: context.h:554
cgv::render::context::dvec_type
cgv::math::vec< double > dvec_type
dimension independent type of vectors
Definition: context.h:541
cgv::render::context::current_background
int current_background
current back ground color index
Definition: context.h:629
cgv::render::textured_material
class that extends obj_material with the management of textures
Definition: textured_material.h:13
cgv::render::context_config_ptr
cgv::data::ref_ptr< context_config > context_config_ptr
type of ref counted pointer to context creation configuration
Definition: context.h:475
cgv::render::context::get_model_point
vec3 get_model_point(int x_window, int y_window, const dmat4 &modelview_projection_window_matrix) const
compute model space 3D point from the given window location and modelview_projection_window matrix
Definition: context.h:1158
cgv::render::context_config::stencil_bits
int stencil_bits
default: -1
Definition: context.h:451
cgv::render::context::current_font_face
cgv::media::font::font_face_ptr current_font_face
store current font
Definition: context.h:637
cgv::render::context::current_material_is_textured
bool current_material_is_textured
store flag to tell whether current material is textured
Definition: context.h:610
cgv::render::context::phong_shading
bool phong_shading
whether to use phong shading
Definition: context.h:627
cgv::render::context::get_modelview_matrix
virtual dmat4 get_modelview_matrix() const =0
return homogeneous 4x4 viewing matrix, which transforms from world to eye space
cgv::render::get_render_pass_name
std::string get_render_pass_name(RenderPass rp)
convert render pass type into string
Definition: context.cxx:631
cgv::render::attribute_array_manager
attribute array manager used to upload arrays to gpu
Definition: renderer.h:21
cgv::render::CompareFunction
CompareFunction
different sampling strategies for rendering to textures that steer the computation of the tex_coord i...
Definition: context.h:206
cgv::render::context::draw_faces
virtual void draw_faces(const float *vertices, const float *normals, const float *tex_coords, const int *vertex_indices, const int *normal_indices, const int *tex_coord_indices, int nr_faces, int face_degree, bool flip_normals=false) const =0
pass geometry of given faces to current shader program and generate draw calls to render triangles
cgv::render::context_config::double_buffer
bool double_buffer
default: true
Definition: context.h:437
cgv::render::context::draw_strip_or_fan
virtual void draw_strip_or_fan(const float *vertices, const float *normals, const float *tex_coords, const int *vertex_indices, const int *normal_indices, const int *tex_coord_indices, int nr_faces, int face_degree, bool is_fan, bool flip_normals=false) const =0
pass geometry of given strip or fan to current shader program and generate draw calls to render trian...
cgv::render::context_config
Definition: context.h:431
cgv::render::shader_program
Definition: shader_program.h:25
cgv::render::context::auto_set_lights_in_current_shader_program
bool auto_set_lights_in_current_shader_program
whether to automatically set lights in current shader program, defaults to true
Definition: context.h:550
cgv::render::TextureFilter
TextureFilter
different texture filter
Definition: context.h:143
cgv::render::context_config::depth_bits
int depth_bits
default: -1
Definition: context.h:449
cgv::media::color
Definition: color.h:51
cgv::media::axis_aligned_box< double, 3 >
cgv::render::FrameBufferType
FrameBufferType
different frame buffer types which can be combined together with or
Definition: context.h:394
cgv::render::context::sRGB_framebuffer_enabled
bool sRGB_framebuffer_enabled()
check whether sRGB framebuffer is enabled
Definition: context.h:892
cgv::render::context::enabled_light_source_handles
std::vector< void * > enabled_light_source_handles
keep track of enabled light source handles
Definition: context.h:592
cgv::render::context::support_compatibility_mode
bool support_compatibility_mode
whether to support view and lighting management of compatibility mode, defaults to true
Definition: context.h:556
cgv::media::illum::surface_material
simple class to hold the material properties of a phong material
Definition: surface_material.h:26
cgv::render::context::DEPRECATED
DEPRECATED("use get_model_point()") vec3 get_point_W(const vec3 &p_D) const
compute a the location in world space of a device point.
Definition: context.h:1192
cgv::reflect::reflection_handler
Definition: reflection_handler.h:63
cgv::render::context::get_model_point
vec3 get_model_point(const vec3 &p_window) const
compute model space 3D point from the given window space point
Definition: context.h:1170
cgv::render::context_config::accumulation_bits
int accumulation_bits
default: -1
Definition: context.h:453
cgv::render::RenderPassFlags
RenderPassFlags
available flags that can be queried from the context and set for a new render pass
Definition: context.h:82
cgv::render::context::attach_stereo_buffer
virtual void attach_stereo_buffer(bool attach=true)=0
attach or detach (attach=false) stereo buffer to the current frame buffer if not present
cgv::render::RP_USER_DEFINED
@ RP_USER_DEFINED
in picking pass a small rectangle around the mouse is rendered
Definition: context.h:75
cgv::data::data_view
Definition: data_view.h:155
cgv::render::context::get_model_point
vec3 get_model_point(int x_window, int y_window, double z_window) const
compute model space 3D point from the given window coordinates
Definition: context.h:1152
cgv::render::context::default_material
cgv::media::illum::surface_material default_material
store a default material
Definition: context.h:606
cgv::render::context::set_color
virtual void set_color(const rgb &clr, float opacity=1.0f)
set the current color
Definition: context.h:898
cgv::render::context::ref_default_shader_program
virtual shader_program & ref_default_shader_program(bool texture_support=false)=0
return a reference to a shader program used to render without illumination
cgv::render::render_component::ctx_ptr
const context * ctx_ptr
keep pointer to my context
Definition: context.h:252
cgv::render::frame_buffer_base
base interface for framebuffer
Definition: context.h:378
cgv::render::render_config::window_width
int window_width
default: 640
Definition: context.h:485
cgv::render::context::get_model_point
vec3 get_model_point(int x_window, int y_window) const
compute model space 3D point from the given window location
Definition: context.h:1146
cgv::render::context::sRGB_framebuffer
bool sRGB_framebuffer
whether to use opengl option to support sRGB framebuffer
Definition: context.h:566
cgv::render::context::gamma
float gamma
gamma value passed to shader programs that have gamma uniform
Definition: context.h:568
cgv::render::type_descriptor::type_descriptor
type_descriptor(int td=0)
construct from int
Definition: context.h:45
cgv::render::render_component::put_id
void put_id(T &id) const
cast the refence to rendering api specific representation of component id to the specified type
Definition: context.h:264
cgv::render::context::shader_program_stack
std::stack< shader_program_base * > shader_program_stack
stack of currently enabled shader programs
Definition: context.h:576
cgv::render::context::light_source_status
status information of light sources
Definition: context.h:585
cgv::render::type_descriptor::type_descriptor
type_descriptor(cgv::type::info::TypeId _coordinate_type, bool _normalize=false)
construct descriptor for values
Definition: context.h:47
cgv::render::create_context
context * create_context(RenderAPI api, unsigned int w, unsigned int h, const std::string &title, bool show)
Definition: context.cxx:2207
cgv::render::context::make_current
virtual bool make_current() const =0
make the current context current if possible
cgv::render::context::get_max_window_transformation_array_size
virtual unsigned get_max_window_transformation_array_size() const =0
query the maximum number of supported window transformations, which is at least 1
cgv::render::context::is_stereo_buffer_supported
virtual bool is_stereo_buffer_supported() const =0
return whether the graphics card supports stereo buffer mode
cgv::render::context::force_redraw
virtual void force_redraw()=0
the context will be redrawn right now. This method cannot be called inside the following methods of a...
cgv::render::context::push_pixel_coords
virtual void push_pixel_coords()=0
cgv::render::context_config::core_profile
bool core_profile
default: false
Definition: context.h:466
cgv::render::vertex_buffer_base::type
VertexBufferType type
buffer type defaults to VBT_VERTICES
Definition: context.h:368
cgv::render::context::get_model_point
vec3 get_model_point(int x_window, int y_window, double z_window, const dmat4 &modelview_projection_window_matrix) const
compute model space 3D point from the given window coordinates with the given modelview_projection_wi...
Definition: context.h:1164
cgv::render::window_transformation
parameters necessary to define window transformation
Definition: context.h:516
cgv::data::data_format
Definition: data_format.h:18
cgv::render::context::clear_current
virtual void clear_current() const =0
clear the current context, typically used in multi-threaded rendering to allow usage of context in se...
cgv::render::context::frame_buffer_stack
std::stack< frame_buffer_base * > frame_buffer_stack
stack of currently enabled frame buffers
Definition: context.h:574
cgv::render::context::render_info
information necessary for a rendering pass
Definition: context.h:613
cgv::render::TextureWrap
TextureWrap
different texture wrap modes
Definition: context.h:127
cgv::render::context::attach_alpha_buffer
virtual void attach_alpha_buffer(bool attach=true)=0
attach or detach (attach=false) an alpha buffer to the current frame buffer if not present
cgv::render::context::is_created
virtual bool is_created() const =0
return whether the context is created
cgv::render::context::enumerate_program_uniforms
virtual void enumerate_program_uniforms(shader_program &prog, std::vector< std::string > &names, std::vector< int > *locations_ptr=0, std::vector< int > *sizes_ptr=0, std::vector< int > *types_ptr=0, bool show=false) const =0
get list of program uniforms
cgv::render::context::cursor_x
int cursor_x
current cursor location for textual output
Definition: context.h:631
cgv::render::context_config::debug
bool debug
default: false in release and true in debug version
Definition: context.h:464
cgv::render::context::at_line_begin
bool at_line_begin
store whether we are at the beginning of the line
Definition: context.h:645
cgv::render::register_context_factory
void register_context_factory(context_creation_function_type fp)
registration context creation functions
Definition: context.cxx:2194
cgv::render::context::bg_r
float bg_r
current background color, depth, stencil and accum color
Definition: context.h:623
cgv::render::context::read_frame_buffer
virtual bool read_frame_buffer(data::data_view &dv, unsigned int x=0, unsigned int y=0, FrameBufferType buffer_type=FB_BACK, TypeId type=type::info::TI_UINT8, data::ComponentFormat cf=data::CF_RGB, int w=-1, int h=-1)=0
cgv::render::context::attribute_array_binding_stack
std::stack< attribute_array_binding_base * > attribute_array_binding_stack
stack of currently enabled attribute array binding
Definition: context.h:582
cgv::render::context_config::stereo_buffer
bool stereo_buffer
default: false
Definition: context.h:441
cgv::render::context::get_projection_matrix
virtual dmat4 get_projection_matrix() const =0
return homogeneous 4x4 projection matrix, which transforms from eye to clip space
cgv::render::get_render_config
render_config_ptr get_render_config()
return a pointer to the current shader configuration
Definition: context.cxx:118
cgv::render::context::light_source_handle
size_t light_source_handle
counter to construct light source handles
Definition: context.h:594
cgv::render::context_config::version_major
int version_major
default: -1 ... major version of maximum supported OpenGL version
Definition: context.h:458
cgv::render::context_config::nr_multi_samples
int nr_multi_samples
default: -1
Definition: context.h:455
cgv::render::TextureSampling
TextureSampling
different sampling strategies for rendering to textures that steer the computation of the tex_coord i...
Definition: context.h:199
cgv::render::context::modelview_matrix_stack
std::stack< dmat4 > modelview_matrix_stack
keep two matrix stacks for model view and projection matrices
Definition: context.h:570
cgv::base::base
Definition: base.h:57
cgv::render::type_descriptor::type_descriptor
type_descriptor(cgv::type::info::TypeId _coordinate_type, unsigned _nr_rows, unsigned _nr_cols, bool _is_row_major, bool _normalize=false)
construct descriptor for matrices
Definition: context.h:51
cgv::render::frame_buffer
Definition: frame_buffer.h:17
cgv::render::TextAlignment
TextAlignment
different text alignments
Definition: context.h:218
cgv::render::context::attach_accumulation_buffer
virtual void attach_accumulation_buffer(bool attach=true)=0
attach or detach (attach=false) accumulation buffer to the current frame buffer if not present
cgv::render::context::enable_vsynch
bool enable_vsynch
whether vsynch should be enabled
Definition: context.h:562
cgv::render::shader_code
Definition: shader_code.h:54
cgv::render::RP_OPAQUE_SURFACES
@ RP_OPAQUE_SURFACES
construction of shadow map
Definition: context.h:72
cgv::render::window_transformation::depth_range
render_types::dvec2 depth_range
range of depth values [min_depth, max_depth]
Definition: context.h:520
cgv::render::context_config::accumulation_buffer
bool accumulation_buffer
default: false
Definition: context.h:445
cgv::render::CullingMode
CullingMode
different culling modes
Definition: context.h:121
cgv::type::info::TI_UINT8
@ TI_UINT8
signed integer stored in 64 bits
Definition: type_id.h:23
cgv::render::shader_program_base
base interface for shader programs
Definition: context.h:290
cgv::render::IlluminationMode
IlluminationMode
different illumination modes
Definition: context.h:116
cgv::type::info::get_type_name
const char * get_type_name(TypeId tid)
function that returns the name of a type specified through TypeId
Definition: type_id.cxx:117
cgv::render::context::DEPRECATED
DEPRECATED("use get_model_point()") vec3 get_point_W(int x_D
compute the location in world space of a device x/y-location. For this the device point is extended w...
cgv::render::context::DEPRECATED
DEPRECATED("use get_window_matrix() instead.") dmat4 get_device_matrix() const
return homogeneous 4x4 projection matrix, which transforms from clip to device space
Definition: context.h:1178
cgv::render::context::attach_multi_sample_buffer
virtual void attach_multi_sample_buffer(bool attach=true)=0
attach or detach (attach=false) multi sample buffer to the current frame buffer if not present
cgv::render::context::recover_from_external_frame_buffer_change
virtual void recover_from_external_frame_buffer_change(void *cgv_fbo_storage)=0
restore cgv frame buffer to the state before the external change
cgv::render::render_config_ptr
cgv::data::ref_ptr< render_config > render_config_ptr
type of ref counted pointer to render configuration
Definition: context.h:509
cgv::render::RP_PICK
@ RP_PICK
transparent surface rendering using depth peeling
Definition: context.h:74
cgv::data::ComponentFormat
ComponentFormat
Definition: component_format.h:18
cgv::render::render_config::dialog_on_error
bool dialog_on_error
default: true (only in case a gui_driver, which supports this, is loaded)
Definition: context.h:495
cgv::render::TextureType
TextureType
different texture types
Definition: context.h:155
cgv::render::RenderAPI
RenderAPI
enumeration of rendering APIs which can be queried from the context
Definition: context.h:59
cgv::render::context_config::stencil_buffer
bool stencil_buffer
default: false
Definition: context.h:443
cgv::render::context::current_color
rgba current_color
current color value
Definition: context.h:564
cgv::render::context::attach_depth_buffer
virtual void attach_depth_buffer(bool attach=true)=0
attach or detach (attach=false) depth buffer to the current frame buffer if not present
cgv::render::context::get_debug_render_passes
bool get_debug_render_passes() const
check whether render passes are debugged
Definition: context.h:761
cgv
the cgv namespace
Definition: vr_calib.cxx:9
cgv::render::context::auto_set_material_in_current_shader_program
bool auto_set_material_in_current_shader_program
whether to automatically set material in current shader program, defaults to true
Definition: context.h:552
cgv::render::context::ref_surface_shader_program
virtual shader_program & ref_surface_shader_program(bool texture_support=false)=0
return a reference to the default shader program used to render surfaces
cgv::render::RenderPass
RenderPass
enumeration of different render passes, which can be queried from the context and used to specify a n...
Definition: context.h:66
cgv::render::context_config::alpha_buffer
bool alpha_buffer
default: false
Definition: context.h:439
cgv::render::context
Definition: context.h:525
cgv::render::TextureCubeSides
TextureCubeSides
the six different sides of a cube
Definition: context.h:167
cgv::render::PrimitiveType
PrimitiveType
different primitive types
Definition: context.h:177
cgv::render::context::is_current
virtual bool is_current() const =0
return whether the context is current
cgv::render::ElementType
ElementType
different compond types for data elements
Definition: context.h:28
cgv::render::context::resize
virtual void resize(unsigned int width, unsigned int height)=0
resize the context to the given dimensions
cgv::render::context::DEPRECATED
DEPRECATED("use get_model_point()") vec3 get_point_W(const vec3 &p_D
compute a the location in world space of a device point.