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> 
   19 #include "lib_begin.h" 
   24 class CGV_API drawable;
 
   25 class CGV_API textured_material;
 
   40         unsigned nr_columns : 4;
 
   41         bool is_row_major : 1;
 
   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); }
 
   84         RPF_SET_PROJECTION = 1,            
 
   85         RPF_SET_MODELVIEW =  1 << 1,             
 
   86         RPF_SET_MODELVIEW_PROJECTION = RPF_SET_PROJECTION|RPF_SET_MODELVIEW,  
 
   87         RPF_SET_LIGHTS = 1 << 2,                
 
   88         RPF_SET_MATERIAL = 1 << 3,              
 
   89         RPF_SET_LIGHTS_ON = 1 << 4,            
 
   90         RPF_ENABLE_MATERIAL = 1 << 5,          
 
   91         RPF_SET_LIGHTING = RPF_SET_LIGHTS|RPF_SET_LIGHTS_ON|RPF_ENABLE_MATERIAL,             
 
   92         RPF_CLEAR_COLOR = 1 << 6,              
 
   93         RPF_CLEAR_DEPTH = 1 << 7,             
 
   94         RPF_CLEAR_STENCIL = 1 << 8,             
 
   95         RPF_CLEAR_ACCUM = 1 << 9,               
 
   96         RPF_CLEAR_ALL = RPF_CLEAR_COLOR|RPF_CLEAR_DEPTH|RPF_CLEAR_STENCIL|RPF_CLEAR_ACCUM, 
 
   97         RPF_DRAWABLES_INIT_FRAME = 1 << 10,    
 
   98         RPF_SET_STATE_FLAGS = 1 << 11,         
 
   99         RPF_SET_CLEAR_COLOR = 1 << 12,        
 
  100         RPF_SET_CLEAR_DEPTH = 1 << 13,        
 
  101         RPF_SET_CLEAR_STENCIL = 1 << 14,        
 
  102         RPF_SET_CLEAR_ACCUM = 1 << 15,        
 
  103         RPF_DRAWABLES_DRAW = 1 << 16,         
 
  104         RPF_DRAWABLES_FINISH_FRAME = 1 << 17, 
 
  105         RPF_DRAW_TEXTUAL_INFO = 1 << 18,      
 
  106         RPF_DRAWABLES_AFTER_FINISH = 1 << 19, 
 
  107         RPF_HANDLE_SCREEN_SHOT = 1 << 20,    
 
  108         RPF_ALL = (1 << 21) - 1,            
 
  109         RPF_DEFAULT = RPF_ALL & ~ (RPF_CLEAR_ACCUM|RPF_SET_CLEAR_ACCUM|RPF_CLEAR_STENCIL|RPF_SET_CLEAR_STENCIL)  
 
  117         IM_OFF, IM_ONE_SIDED, IM_TWO_SIDED
 
  122         CM_OFF, CM_BACKFACE, CM_FRONTFACE
 
  130         TW_CLAMP_TO_EDGE = 2, 
 
  131         TW_CLAMP_TO_BORDER = 3, 
 
  133         TW_MIRROR_CLAMP_TO_EDGE = 5, 
 
  134         TW_MIRROR_CLAMP_TO_BORDER = 6,
 
  135         TW_MIRRORED_REPEAT = 7, 
 
  146         TF_NEAREST_MIPMAP_NEAREST = 2, 
 
  147         TF_LINEAR_MIPMAP_NEAREST = 3, 
 
  148         TF_NEAREST_MIPMAP_LINEAR = 4,
 
  149         TF_LINEAR_MIPMAP_LINEAR = 5,
 
  183         PT_LINE_STRIP_ADJACENCY,
 
  186         PT_TRIANGLES_ADJACENCY,
 
  188         PT_TRIANGLE_STRIP_ADJACENCY,
 
  224         TA_TOP_LEFT = TA_LEFT+TA_TOP,    
 
  225         TA_TOP_RIGHT = TA_RIGHT+TA_TOP,  
 
  226         TA_BOTTOM_LEFT = TA_LEFT+TA_BOTTOM,   
 
  227         TA_BOTTOM_RIGHT = TA_RIGHT+TA_BOTTOM  
 
  242 class CGV_API context;
 
  249         void* internal_format;
 
  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); }
 
  278         float border_color[4];
 
  280         bool use_compare_function;
 
  295         bool auto_detect_uniforms;
 
  296         bool auto_detect_vertex_attributes;
 
  307         bool context_sets_color;
 
  314         int geometry_shader_output_count;
 
  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 = 
"");
 
  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; }
 
  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; }
 
  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
 
  382         std::vector<int> enabled_color_attachments;
 
  391 enum ShaderType { ST_DETECT, ST_COMPUTE, ST_VERTEX, ST_TESS_CONTROL, ST_TESS_EVALUATION, ST_GEOMETRY, ST_FRAGMENT };
 
  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
 
  415         MAX_NR_GEOMETRY_SHADER_OUTPUT_VERTICES 
 
  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;
 
  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];
 
  482         int fullscreen_monitor;
 
  588                 vec3 eye_spot_direction;
 
  589                 int light_source_index;
 
  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;
 
  604         void* default_light_source_handles[nr_default_light_sources];
 
  623         float bg_r, bg_g, bg_b, bg_a, bg_d;
 
  625         float bg_accum_r, bg_accum_g, bg_accum_b, bg_accum_a;
 
  649         virtual void process_text(
const std::string& text);
 
  651         virtual void draw_text(
const std::string& text);
 
  654         virtual void destruct_render_objects();
 
  655         virtual void put_id(
void* handle, 
void* ptr) 
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;
 
  672         static void get_buffer_list(
frame_buffer_base& fbb, std::vector<int>& buffers, 
int offset = 0);
 
  680         virtual int frame_buffer_get_max_nr_color_attachments() 
const = 0;
 
  681         virtual int frame_buffer_get_max_nr_draw_buffers() 
const = 0;
 
  695         virtual int  get_uniform_location(
const shader_program_base& spb, 
const std::string& name) 
const = 0;
 
  698         virtual int  get_attribute_location(
const shader_program_base& spb, 
const std::string& name) 
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;
 
  714         virtual bool vertex_buffer_copy_back(
vertex_buffer_base& vbb, 
size_t offset, 
size_t size_in_bytes, 
void* array_ptr) 
const = 0;
 
  722         virtual void error(
const std::string& message, 
const render_component* rc = 0) 
const;
 
  726         virtual void init_render_pass();
 
  729         virtual void draw_textual_info();
 
  731         virtual void perform_screen_shot();
 
  733         virtual void finish_render_pass();
 
  743         unsigned get_render_pass_recursion_depth() 
const;
 
  749         virtual void* get_render_pass_user_data() 
const;
 
  755         virtual void render_pass(
RenderPass render_pass = RP_MAIN, 
 
  757                                                          void* user_data = 0);
 
  759         void set_debug_render_passes(
bool _debug);
 
  769         virtual bool recreate_context();
 
  795         virtual void resize(
unsigned int width, 
unsigned int height) = 0;
 
  815                 unsigned int x = 0, 
unsigned int y = 0, 
 
  819                 int w = -1, 
int h = -1) = 0;
 
  823         bool write_frame_buffer_to_image(
 
  824                 const std::string& file_name, 
 
  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;
 
  872         virtual float get_current_font_size() 
const;
 
  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);
 
  886         virtual 
void set_gamma(
float _gamma);
 
  888         float get_gamma()
 const { 
return gamma; }
 
  890         virtual void enable_sRGB_framebuffer(
bool do_enable = 
true);
 
  894         const rgba& get_color() 
const;
 
  896         virtual void set_color(
const rgba& clr);
 
  910         void set_current_view(
shader_program& prog, 
bool modelview_deps = 
true, 
bool projection_deps = 
true) 
const;
 
  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;
 
  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;
 
  939         bool remove_light_source(
void* handle);
 
  943         const light_source_status& get_light_source_status(
void* handle) 
const;
 
  947         void place_light_source(
void* handle);
 
  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);
 
  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);
 
  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;
 
 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;
 
 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;
 
 1012         void tesselate_unit_square(
bool flip_normals = 
false, 
bool edges = 
false);
 
 1014         void tesselate_unit_cube(
bool flip_normals = 
false, 
bool edges = 
false);
 
 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);
 
 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);
 
 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)); }
 
 1076         virtual void set_modelview_matrix(
const dmat4& MV);
 
 1078         virtual void mul_modelview_matrix(
const dmat4& MV);
 
 1086         void push_modelview_matrix();
 
 1088         void pop_modelview_matrix();
 
 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();
 
 1104         virtual void pop_window_transformation_array();
 
 1112         bool ensure_window_transformation_index(
int& array_index);
 
 1125         virtual void set_viewport(
const ivec4& viewport, 
int array_index = -1);
 
 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;
 
 1138         dmat4 get_window_matrix(
unsigned array_index = 0) 
const;
 
 1140         dmat4 get_modelview_projection_window_matrix(
unsigned array_index = 0) 
const;
 
 1147                 return get_model_point(x_window, y_window, get_window_z(x_window, y_window)); 
 
 1153                 return get_model_point(x_window, y_window, z_window, get_modelview_projection_window_matrix());
 
 1159                 return get_model_point(x_window, y_window, get_window_z(x_window, y_window), modelview_projection_window_matrix);
 
 1165                 return get_model_point(
dvec3(x_window+0.5, y_window+0.5, z_window), modelview_projection_window_matrix);
 
 1171                 return get_model_point(p_window, get_modelview_projection_window_matrix());
 
 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); }
 
 1203                 unsigned int w = 800, 
unsigned int h = 600, 
 
 1204                 const std::string& title = 
"", 
bool show = 
false);
 
 1206 typedef context* (*context_creation_function_type)(
RenderAPI api, 
unsigned int w, 
unsigned int h, 
const std::string& title, 
bool show);
 
 1211 struct CGV_API context_factory_registration
 
 1213         context_factory_registration(context_creation_function_type fp);
 
 1219 #include <cgv/config/lib_end.h> 
  
 
@ RP_SHADOW_MAP
rendering of second eye
Definition: context.h:70
 
RenderPassFlags default_render_flags
default render flags with which the main render pass is initialized
Definition: context.h:621
 
cgv::signal::callback_stream out_stream
use a callback stream to write text to the opengl context
Definition: context.h:633
 
Definition: attribute_array_binding.h:20
 
virtual void post_redraw()=0
the context will be redrawn when the system is idle again
 
base interface for all render components
Definition: context.h:246
 
virtual unsigned int get_width() const =0
return the width of the window
 
matrix of fixed size dimensions
Definition: fmat.h:23
 
@ CF_RGB
color format with two components R and G
Definition: component_format.h:29
 
compact type description of data that can be sent to the context; convertible to int
Definition: context.h:36
 
virtual void pop_pixel_coords()=0
pop previously changed transformation matrices
 
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
 
base class for attribute_array_bindings
Definition: context.h:338
 
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...
 
ContextIntegerConstant
integer constants that can be queried from context
Definition: context.h:414
 
MaterialSide
different sides of a material
Definition: context.h:113
 
ShaderType
different shader types
Definition: context.h:391
 
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,...
 
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
 
std::string last_error
a string that contains the last error
Definition: context.h:254
 
Definition: render_buffer.h:16
 
type_descriptor(cgv::type::info::TypeId _coordinate_type, unsigned _nr_entries, bool _normalize=false)
construct descriptor for vectors
Definition: context.h:49
 
bool show_error_on_console
default: true
Definition: context.h:497
 
@ RP_TRANSPARENT_SURFACES
opaque surface rendering using z-Buffer
Definition: context.h:73
 
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...
 
VertexBufferType
different vertex buffer types
Definition: context.h:349
 
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 ...
 
TypeId
ids for the different types and type constructs
Definition: type_id.h:12
 
float current_font_size
store current font size
Definition: context.h:635
 
VertexBufferUsage
different vertex buffer usages as defined in OpenGL
Definition: context.h:359
 
cgv::math::vec< float > vec_type
dimension independent type of vectors
Definition: context.h:537
 
virtual bool in_render_process() const =0
return whether the context is currently in process of rendering
 
int tab_size
size a tabs
Definition: context.h:639
 
@ 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
 
bool debug_render_passes
whether to debug render passes
Definition: context.h:560
 
connect to the write signal of the callback stream in order to process all text written to the stream
Definition: callback_stream.h:48
 
Definition: context.h:479
 
virtual RenderAPI get_render_api() const =0
return the used rendering API
 
Definition: vertex_buffer.h:13
 
@ RP_STEREO
the main rendering pass triggered by the redraw event
Definition: context.h:69
 
@ RP_SHADOW_VOLUME
construction of shadow map
Definition: context.h:71
 
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
 
bool forward_compatible
default: false
Definition: context.h:462
 
int x_offset
offset in x and y direction where text starts
Definition: context.h:641
 
int nr_identations
current number of indentations
Definition: context.h:643
 
type_descriptor(const type_descriptor &td, bool _is_array)
construct descriptor for an array
Definition: context.h:53
 
const cgv::media::illum::surface_material * current_material_ptr
store pointer to current material
Definition: context.h:608
 
std::stack< render_info > render_pass_stack
store the current render pass
Definition: context.h:619
 
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
 
Definition: data_view.h:211
 
virtual void attach_stencil_buffer(bool attach=true)=0
attach or detach (attach=false) stencil buffer to the current frame buffer if not present
 
int window_height
default: 480
Definition: context.h:487
 
base interface for a texture
Definition: context.h:269
 
bool multi_sample_buffer
default: false
Definition: context.h:447
 
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
 
A column vector class.
Definition: fvec.h:13
 
std::string to_string(TextureWrap wrap)
convert texture wrap to string
Definition: context.cxx:871
 
virtual unsigned int get_height() const =0
return the height of the window
 
cgv::math::mat< float > mat_type
dimension independent type of matrices
Definition: context.h:539
 
base interface for a vertex buffer
Definition: context.h:365
 
std::stack< std::vector< window_transformation > > window_transformation_stack
keep stack of window transformations
Definition: context.h:572
 
virtual void recover_from_external_viewport_change(const ivec4 &cgv_viewport_storage)=0
restore cgv viewport to the state before the external change
 
int version_minor
default: -1 ... minor version of maximum supported OpenGL version
Definition: context.h:460
 
VertexBufferUsage usage
usage defaults to VBU_STATIC_DRAW
Definition: context.h:370
 
cgv::math::mat< double > dmat_type
dimension independent type of matrices
Definition: context.h:543
 
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::math::vec< double > dvec_type
dimension independent type of vectors
Definition: context.h:541
 
int current_background
current back ground color index
Definition: context.h:629
 
class that extends obj_material with the management of textures
Definition: textured_material.h:13
 
cgv::data::ref_ptr< context_config > context_config_ptr
type of ref counted pointer to context creation configuration
Definition: context.h:475
 
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
 
int stencil_bits
default: -1
Definition: context.h:451
 
cgv::media::font::font_face_ptr current_font_face
store current font
Definition: context.h:637
 
bool current_material_is_textured
store flag to tell whether current material is textured
Definition: context.h:610
 
bool phong_shading
whether to use phong shading
Definition: context.h:627
 
virtual dmat4 get_modelview_matrix() const =0
return homogeneous 4x4 viewing matrix, which transforms from world to eye space
 
std::string get_render_pass_name(RenderPass rp)
convert render pass type into string
Definition: context.cxx:631
 
attribute array manager used to upload arrays to gpu
Definition: renderer.h:21
 
CompareFunction
different sampling strategies for rendering to textures that steer the computation of the tex_coord i...
Definition: context.h:206
 
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
 
bool double_buffer
default: true
Definition: context.h:437
 
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...
 
Definition: context.h:431
 
Definition: shader_program.h:25
 
bool auto_set_lights_in_current_shader_program
whether to automatically set lights in current shader program, defaults to true
Definition: context.h:550
 
TextureFilter
different texture filter
Definition: context.h:143
 
int depth_bits
default: -1
Definition: context.h:449
 
FrameBufferType
different frame buffer types which can be combined together with or
Definition: context.h:394
 
bool sRGB_framebuffer_enabled()
check whether sRGB framebuffer is enabled
Definition: context.h:892
 
std::vector< void * > enabled_light_source_handles
keep track of enabled light source handles
Definition: context.h:592
 
bool support_compatibility_mode
whether to support view and lighting management of compatibility mode, defaults to true
Definition: context.h:556
 
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
 
Definition: reflection_handler.h:63
 
vec3 get_model_point(const vec3 &p_window) const
compute model space 3D point from the given window space point
Definition: context.h:1170
 
int accumulation_bits
default: -1
Definition: context.h:453
 
RenderPassFlags
available flags that can be queried from the context and set for a new render pass
Definition: context.h:82
 
virtual void attach_stereo_buffer(bool attach=true)=0
attach or detach (attach=false) stereo buffer to the current frame buffer if not present
 
@ RP_USER_DEFINED
in picking pass a small rectangle around the mouse is rendered
Definition: context.h:75
 
Definition: data_view.h:155
 
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::media::illum::surface_material default_material
store a default material
Definition: context.h:606
 
virtual void set_color(const rgb &clr, float opacity=1.0f)
set the current color
Definition: context.h:898
 
virtual shader_program & ref_default_shader_program(bool texture_support=false)=0
return a reference to a shader program used to render without illumination
 
const context * ctx_ptr
keep pointer to my context
Definition: context.h:252
 
base interface for framebuffer
Definition: context.h:378
 
int window_width
default: 640
Definition: context.h:485
 
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
 
bool sRGB_framebuffer
whether to use opengl option to support sRGB framebuffer
Definition: context.h:566
 
float gamma
gamma value passed to shader programs that have gamma uniform
Definition: context.h:568
 
type_descriptor(int td=0)
construct from int
Definition: context.h:45
 
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
 
std::stack< shader_program_base * > shader_program_stack
stack of currently enabled shader programs
Definition: context.h:576
 
status information of light sources
Definition: context.h:585
 
type_descriptor(cgv::type::info::TypeId _coordinate_type, bool _normalize=false)
construct descriptor for values
Definition: context.h:47
 
context * create_context(RenderAPI api, unsigned int w, unsigned int h, const std::string &title, bool show)
Definition: context.cxx:2207
 
virtual bool make_current() const =0
make the current context current if possible
 
virtual unsigned get_max_window_transformation_array_size() const =0
query the maximum number of supported window transformations, which is at least 1
 
virtual bool is_stereo_buffer_supported() const =0
return whether the graphics card supports stereo buffer mode
 
virtual void force_redraw()=0
the context will be redrawn right now. This method cannot be called inside the following methods of a...
 
virtual void push_pixel_coords()=0
 
bool core_profile
default: false
Definition: context.h:466
 
VertexBufferType type
buffer type defaults to VBT_VERTICES
Definition: context.h:368
 
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
 
virtual void clear_current() const =0
clear the current context, typically used in multi-threaded rendering to allow usage of context in se...
 
std::stack< frame_buffer_base * > frame_buffer_stack
stack of currently enabled frame buffers
Definition: context.h:574
 
information necessary for a rendering pass
Definition: context.h:613
 
TextureWrap
different texture wrap modes
Definition: context.h:127
 
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
 
virtual bool is_created() const =0
return whether the context is created
 
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
 
int cursor_x
current cursor location for textual output
Definition: context.h:631
 
bool debug
default: false in release and true in debug version
Definition: context.h:464
 
bool at_line_begin
store whether we are at the beginning of the line
Definition: context.h:645
 
void register_context_factory(context_creation_function_type fp)
registration context creation functions
Definition: context.cxx:2194
 
float bg_r
current background color, depth, stencil and accum color
Definition: context.h:623
 
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
 
std::stack< attribute_array_binding_base * > attribute_array_binding_stack
stack of currently enabled attribute array binding
Definition: context.h:582
 
bool stereo_buffer
default: false
Definition: context.h:441
 
virtual dmat4 get_projection_matrix() const =0
return homogeneous 4x4 projection matrix, which transforms from eye to clip space
 
render_config_ptr get_render_config()
return a pointer to the current shader configuration
Definition: context.cxx:118
 
size_t light_source_handle
counter to construct light source handles
Definition: context.h:594
 
int version_major
default: -1 ... major version of maximum supported OpenGL version
Definition: context.h:458
 
int nr_multi_samples
default: -1
Definition: context.h:455
 
TextureSampling
different sampling strategies for rendering to textures that steer the computation of the tex_coord i...
Definition: context.h:199
 
std::stack< dmat4 > modelview_matrix_stack
keep two matrix stacks for model view and projection matrices
Definition: context.h:570
 
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
 
Definition: frame_buffer.h:17
 
TextAlignment
different text alignments
Definition: context.h:218
 
virtual void attach_accumulation_buffer(bool attach=true)=0
attach or detach (attach=false) accumulation buffer to the current frame buffer if not present
 
bool enable_vsynch
whether vsynch should be enabled
Definition: context.h:562
 
Definition: shader_code.h:54
 
@ RP_OPAQUE_SURFACES
construction of shadow map
Definition: context.h:72
 
bool accumulation_buffer
default: false
Definition: context.h:445
 
CullingMode
different culling modes
Definition: context.h:121
 
@ TI_UINT8
signed integer stored in 64 bits
Definition: type_id.h:23
 
base interface for shader programs
Definition: context.h:290
 
IlluminationMode
different illumination modes
Definition: context.h:116
 
const char * get_type_name(TypeId tid)
function that returns the name of a type specified through TypeId
Definition: type_id.cxx:117
 
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...
 
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
 
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
 
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::data::ref_ptr< render_config > render_config_ptr
type of ref counted pointer to render configuration
Definition: context.h:509
 
@ RP_PICK
transparent surface rendering using depth peeling
Definition: context.h:74
 
ComponentFormat
Definition: component_format.h:18
 
bool dialog_on_error
default: true (only in case a gui_driver, which supports this, is loaded)
Definition: context.h:495
 
TextureType
different texture types
Definition: context.h:155
 
RenderAPI
enumeration of rendering APIs which can be queried from the context
Definition: context.h:59
 
bool stencil_buffer
default: false
Definition: context.h:443
 
rgba current_color
current color value
Definition: context.h:564
 
virtual void attach_depth_buffer(bool attach=true)=0
attach or detach (attach=false) depth buffer to the current frame buffer if not present
 
bool get_debug_render_passes() const
check whether render passes are debugged
Definition: context.h:761
 
the cgv namespace
Definition: vr_calib.cxx:9
 
bool auto_set_material_in_current_shader_program
whether to automatically set material in current shader program, defaults to true
Definition: context.h:552
 
virtual shader_program & ref_surface_shader_program(bool texture_support=false)=0
return a reference to the default shader program used to render surfaces
 
RenderPass
enumeration of different render passes, which can be queried from the context and used to specify a n...
Definition: context.h:66
 
bool alpha_buffer
default: false
Definition: context.h:439
 
Definition: context.h:525
 
TextureCubeSides
the six different sides of a cube
Definition: context.h:167
 
PrimitiveType
different primitive types
Definition: context.h:177
 
virtual bool is_current() const =0
return whether the context is current
 
ElementType
different compond types for data elements
Definition: context.h:28
 
virtual void resize(unsigned int width, unsigned int height)=0
resize the context to the given dimensions
 
DEPRECATED("use get_model_point()") vec3 get_point_W(const vec3 &p_D
compute a the location in world space of a device point.