cgv
cgv::render::gl::gl_context Class Referenceabstract

#include <gl_context.h>

Inheritance diagram for cgv::render::gl::gl_context:
cgv::render::context cgv::render::context_config

Public Types

typedef cgv::math::vec< float > vec_type
 dimension independent type of vectors
 
typedef cgv::math::mat< float > mat_type
 dimension independent type of matrices
 
typedef cgv::math::vec< double > dvec_type
 dimension independent type of vectors
 
typedef cgv::math::mat< double > dmat_type
 dimension independent type of matrices
 
typedef cgv::media::color< float, cgv::media::RGB > rgb
 declare rgb color type
 
typedef cgv::media::color< float, cgv::media::RGB, cgv::media::OPACITY > rgba
 declare rgba color type
 
typedef cgv::media::color< cgv::type::uint8_type, cgv::media::RGB > rgb8
 declare rgb color type
 
typedef cgv::media::color< cgv::type::uint8_type, cgv::media::RGB, cgv::media::OPACITY > rgba8
 declare rgba color type
 
typedef cgv::math::fvec< float, 2 > vec2
 declare type of 2d vectors
 
typedef cgv::math::fvec< float, 3 > vec3
 declare type of 3d vectors
 
typedef cgv::math::fvec< float, 4 > vec4
 declare type of homogeneous vectors
 
typedef cgv::math::vec< float > vecn
 declare type of vector with varying dimension
 
typedef cgv::math::fmat< float, 2, 2 > mat2
 declare type of 2x2 matrices
 
typedef cgv::math::fmat< float, 3, 3 > mat3
 declare type of 3x3 matrices
 
typedef cgv::math::fmat< float, 4, 4 > mat4
 declare type of 4x4 matrices
 
typedef cgv::math::fmat< float, 3, 4 > mat34
 declare type of 3x4 matrices which are often used to store a pose
 
typedef cgv::math::mat< float > matn
 declare type of matrices of varying dimensions
 
typedef cgv::math::fvec< double, 2 > dvec2
 declare type of 2d vectors
 
typedef cgv::math::fvec< double, 3 > dvec3
 declare type of 3d vectors
 
typedef cgv::math::fvec< double, 4 > dvec4
 declare type of homogeneous vectors
 
typedef cgv::math::vec< double > dvecn
 declare type of vector with varying dimension
 
typedef cgv::math::fmat< double, 2, 2 > dmat2
 declare type of 2x2 matrices
 
typedef cgv::math::fmat< double, 3, 3 > dmat3
 declare type of 3x3 matrices
 
typedef cgv::math::fmat< double, 4, 4 > dmat4
 declare type of 4x4 matrices
 
typedef cgv::math::fmat< double, 3, 4 > dmat34
 declare type of 3x4 matrices which are often used to store a pose
 
typedef cgv::math::mat< double > dmatn
 declare type of matrices of varying dimensions
 
typedef cgv::media::axis_aligned_box< float, 2 > box2
 declare type of 2d boxes
 
typedef cgv::media::axis_aligned_box< float, 3 > box3
 declare type of 3d boxes
 
typedef cgv::media::axis_aligned_box< float, 4 > box4
 declare type of 4d boxes
 
typedef cgv::media::axis_aligned_box< double, 2 > dbox2
 declare type of 2d boxes
 
typedef cgv::media::axis_aligned_box< double, 3 > dbox3
 declare type of 3d boxes
 
typedef cgv::media::axis_aligned_box< double, 4 > dbox4
 declare type of 4d boxes
 
typedef cgv::math::quaternion< float > quat
 declare type of quaternion
 
typedef cgv::math::quaternion< double > dquat
 declare type of double quaternion
 
typedef cgv::math::fvec< int32_t, 2 > ivec2
 declare type of 2d integer vectors
 
typedef cgv::math::fvec< int32_t, 3 > ivec3
 declare type of 3d integer vectors
 
typedef cgv::math::fvec< int32_t, 4 > ivec4
 declare type of 4d integer vectors
 
typedef cgv::math::fvec< uint32_t, 2 > uvec2
 declare type of 2d unsigned integer vectors
 
typedef cgv::math::fvec< uint32_t, 3 > uvec3
 declare type of 3d unsigned integer vectors
 
typedef cgv::math::fvec< uint32_t, 4 > uvec4
 declare type of 4d unsigned integer vectors
 

Public Member Functions

 gl_context ()
 construct context and attach signals More...
 
bool configure_gl ()
 ensure that glew is initialized, define lighting mode, viewing pyramid and the rendering mode and return whether gl configuration was successful More...
 
float get_current_font_size () const
 overwrite function to return info font size in case no font is currently selected
 
media::font::font_face_ptr get_current_font_face () const
 overwrite function to return info font face in case no font is currently selected
 
RenderAPI get_render_api () const
 return the used rendering API
 
shader_program_baseget_current_program () const
 check for current program, prepare it for rendering and return pointer to it
 
virtual void error (const std::string &message, const render_component *rc=0) const
 error handling
 
lights
 DEPRECATED ("deprecated, use add_light_source instead.") void *enable_light(const cgv
 
 DEPRECATED ("deprecated, use enable_light_source instead.") void disable_light(void *handle)
 
 DEPRECATED ("deprecated, use get_max_nr_enabled_light_sources instead.") unsigned get_max_nr_lights() const
 
size_t get_nr_light_sources () const
 return the number of light sources
 
void * add_light_source (const cgv::media::illum::light_source &light, bool enabled=true, bool place_now=false)
 add a new light source, enable it if enable is true and place it relative to current model view transformation if place_now is true; return handle to light source
 
bool remove_light_source (void *handle)
 remove a light source by handle and whether it existed
 
const cgv::media::illum::light_sourceget_light_source (void *handle) const
 read access to light source
 
const light_source_statusget_light_source_status (void *handle) const
 read access to light source status
 
void set_light_source (void *handle, const cgv::media::illum::light_source &light, bool place_now=true)
 set light source newly
 
void place_light_source (void *handle)
 place the given light source relative to current model viel transformation
 
virtual unsigned get_max_nr_enabled_light_sources () const
 return maximum number of light sources, that can be enabled in parallel
 
size_t get_nr_enabled_light_sources () const
 return the number of light sources
 
void * get_enabled_light_source_handle (size_t i) const
 access to handle of i-th light source
 
bool enable_light_source (void *handle)
 enable a given light source and return whether there existed a light source with given handle
 
bool disable_light_source (void *handle)
 disable a given light source and return whether there existed a light source with given handle
 
text output
virtual std::ostream & output_stream ()
 returns an output stream whose output is printed at the current cursor location More...
 
virtual void set_cursor (int x, int y)
 set a new cursor position, which is only valid between calls of push_pixel_coords and pop_pixel_coords More...
 
virtual void get_cursor (int &x, int &y) const
 return current cursor location in mouse coordinates More...
 
virtual void put_cursor_coords (const vec_type &p, int &x, int &y) const
 transform point p into cursor coordinates and put x and y coordinates into the passed variables More...
 
virtual void set_cursor (const vec_type &pos, const std::string &text="", TextAlignment ta=TA_BOTTOM_LEFT, int x_offset=0, int y_offset=0)
 sets the current text ouput position More...
 
light and materials management
void set_color (const rgba &clr)
 set the current color
 
void set_material (const cgv::media::illum::surface_material &mat)
 set the current material
 
void enable_material (textured_material &mat)
 enable a material with textures
 
void disable_material (textured_material &mat)
 disable a material with textures
 
shader_programref_default_shader_program (bool texture_support=false)
 return a reference to a shader program used to render without illumination
 
shader_programref_surface_shader_program (bool texture_support=false)
 return a reference to the default shader program used to render surfaces More...
 
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
 get list of program uniforms
 
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
 get list of program attributes More...
 
void on_lights_changed ()
 helper function to send light update events
 
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)
 tesselate an arrow from the origin in z-direction More...
 
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)
 define length and direction from start and end point and draw an arrow
 
void draw_light_source (const cgv::media::illum::light_source &l, float intensity_scale, float light_scale)
 draw a light source with an emissive material More...
 
void announce_external_viewport_change (ivec4 &cgv_viewport_storage)
 announce an external viewport change performed with rendering API to the cgv framework providing space to temporarily store viewport of cgv framework
 
void recover_from_external_viewport_change (const ivec4 &cgv_viewport_storage)
 restore cgv viewport to the state before the external change
 
void announce_external_frame_buffer_change (void *&cgv_fbo_storage)
 announce an external frame buffer change performed with rendering API to the cgv framework providing space to temporarily store frame buffer of cgv framework
 
void recover_from_external_frame_buffer_change (void *cgv_fbo_storage)
 restore cgv frame buffer to the state before the external change
 
text output
void push_pixel_coords ()
 use this to push transformation matrices on the stack such that x and y coordinates correspond to window coordinates
 
void pop_pixel_coords ()
 pop previously changed transformation matrices
 
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)
 implement according to specification in context class
 
tesselation
bool prepare_attributes (std::vector< vec3 > &P, std::vector< vec3 > &N, std::vector< vec2 > &T, unsigned nr_vertices, const float *vertices, const float *normals, const float *tex_coords, const int *vertex_indices, const int *normal_indices, const int *tex_coord_indices, bool flip_normals) const
 helper function to prepare attribute arrays
 
bool release_attributes (const float *normals, const float *tex_coords, const int *normal_indices, const int *tex_coord_indices) const
 helper function to disable attribute arrays
 
void draw_edges_of_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
 pass geometry of given faces to current shader program and generate draw calls to render lines for the edges
 
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
 pass geometry of given strip or fan to current shader program and generate draw calls to render lines for the edges
 
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) const
 tesselate with independent faces
 
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) const
 tesselate with one face strip
 
render process
virtual void configure_new_child (cgv::base::base_ptr child)
 helper method to integrate a new child
 
unsigned get_render_pass_recursion_depth () const
 return current render pass recursion depth More...
 
virtual RenderPass get_render_pass () const
 return the current render pass
 
virtual RenderPassFlags get_render_pass_flags () const
 return the current render pass flags
 
virtual void * get_render_pass_user_data () const
 return the current render pass user data
 
virtual RenderPassFlags get_default_render_pass_flags () const
 return the default render pass flags
 
virtual void set_default_render_pass_flags (RenderPassFlags)
 return the default render pass flags
 
virtual void render_pass (RenderPass render_pass=RP_MAIN, RenderPassFlags render_pass_flags=RPF_ALL, void *user_data=0)
 perform the given render task
 
void set_debug_render_passes (bool _debug)
 set flag whether to debug render passes
 
bool get_debug_render_passes () const
 check whether render passes are debugged
 
virtual bool in_render_process () const =0
 return whether the context is currently in process of rendering
 
virtual bool is_created () const =0
 return whether the context is created
 
virtual bool is_current () const =0
 return whether the context is current
 
virtual bool recreate_context ()
 recreate context based on current context config settings
 
virtual bool make_current () const =0
 make the current context current if possible
 
virtual void clear_current () const =0
 clear the current context, typically used in multi-threaded rendering to allow usage of context in several threads
 
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 void attach_depth_buffer (bool attach=true)=0
 attach or detach (attach=false) depth buffer to the current frame buffer if not present
 
virtual void attach_stencil_buffer (bool attach=true)=0
 attach or detach (attach=false) stencil buffer to the current frame buffer if not present
 
virtual bool is_stereo_buffer_supported () const =0
 return whether the graphics card supports stereo buffer mode
 
virtual void attach_stereo_buffer (bool attach=true)=0
 attach or detach (attach=false) stereo buffer to the current frame buffer if not present
 
virtual void attach_accumulation_buffer (bool attach=true)=0
 attach or detach (attach=false) accumulation buffer to the current frame buffer if not present
 
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 unsigned int get_width () const =0
 return the width of the window
 
virtual unsigned int get_height () const =0
 return the height of the window
 
virtual void resize (unsigned int width, unsigned int height)=0
 resize the context to the given dimensions
 
bool write_frame_buffer_to_image (const std::string &file_name, data::ComponentFormat cf=data::CF_RGB, FrameBufferType buffer_type=FB_BACK, unsigned int x=0, unsigned int y=0, int w=-1, int h=-1, float depth_offset=0.9f, float depth_scale=10.0f)
 write the content of a buffer to an image file More...
 
virtual void set_bg_color (float r, float g, float b, float a)
 set a user defined background color
 
virtual void set_bg_alpha (float a)
 set a user defined background alpha value
 
virtual void set_bg_depth (float d)
 set a user defined background depth value More...
 
virtual void set_bg_stencil (int s)
 set a user defined background stencil value More...
 
virtual void set_bg_accum_color (float r, float g, float b, float a)
 set a user defined background color for the accumulation buffer More...
 
virtual void set_bg_accum_alpha (float a)
 set a user defined background alpha value for the accumulation buffer More...
 
virtual void set_bg_clr_idx (unsigned int idx)
 set an indexed background color More...
 
unsigned int get_bg_clr_idx () const
 return the current index of the background color
 
void put_bg_color (float *rgba) const
 copy the current back ground rgba color into the given float array
 
float get_bg_alpha () const
 return the current alpha value for clearing the background
 
void put_bg_accum_color (float *rgba) const
 copy the current back ground rgba color of the accumulation buffer into the given float array
 
float get_bg_accum_alpha () const
 return the current alpha value for clearing the accumulation buffer
 
float get_bg_depth () const
 return the current depth value for clearing the background
 
int get_bg_stencil () const
 return the current stencil value for clearing the background
 
virtual void post_redraw ()=0
 the context will be redrawn when the system is idle again
 
virtual void force_redraw ()=0
 the context will be redrawn right now. This method cannot be called inside the following methods of a drawable: init, init_frame, draw, finish_draw
 
font selection and measure
virtual void enable_font_face (media::font::font_face_ptr font_face, float font_size)
 enable the given font face with the given size in pixels
 
lights
 DEPRECATED ("deprecated, use add_light_source instead.") void *enable_light(const cgv
 
 DEPRECATED ("deprecated, use enable_light_source instead.") void disable_light(void *handle)
 
 DEPRECATED ("deprecated, use get_max_nr_enabled_light_sources instead.") unsigned get_max_nr_lights() const
 
size_t get_nr_light_sources () const
 return the number of light sources
 
void * add_light_source (const cgv::media::illum::light_source &light, bool enabled=true, bool place_now=false)
 add a new light source, enable it if enable is true and place it relative to current model view transformation if place_now is true; return handle to light source
 
bool remove_light_source (void *handle)
 remove a light source by handle and whether it existed
 
const cgv::media::illum::light_sourceget_light_source (void *handle) const
 read access to light source
 
const light_source_statusget_light_source_status (void *handle) const
 read access to light source status
 
void set_light_source (void *handle, const cgv::media::illum::light_source &light, bool place_now=true)
 set light source newly
 
void place_light_source (void *handle)
 place the given light source relative to current model viel transformation
 
virtual unsigned get_max_nr_enabled_light_sources () const
 return maximum number of light sources, that can be enabled in parallel
 
size_t get_nr_enabled_light_sources () const
 return the number of light sources
 
void * get_enabled_light_source_handle (size_t i) const
 access to handle of i-th light source
 
bool enable_light_source (void *handle)
 enable a given light source and return whether there existed a light source with given handle
 
bool disable_light_source (void *handle)
 disable a given light source and return whether there existed a light source with given handle
 
text output
virtual std::ostream & output_stream ()
 returns an output stream whose output is printed at the current cursor location More...
 
virtual void set_cursor (int x, int y)
 set a new cursor position, which is only valid between calls of push_pixel_coords and pop_pixel_coords More...
 
virtual void set_cursor (const vec_type &pos, const std::string &text="", TextAlignment ta=TA_BOTTOM_LEFT, int x_offset=0, int y_offset=0)
 sets the current text ouput position More...
 
virtual void get_cursor (int &x, int &y) const
 return current cursor location in mouse coordinates More...
 
virtual void put_cursor_coords (const vec_type &p, int &x, int &y) const
 transform point p into cursor coordinates and put x and y coordinates into the passed variables More...
 
drawing
void tesselate_unit_square (bool flip_normals=false, bool edges=false)
 tesselate a unit square in the xy-plane with texture coordinates More...
 
void tesselate_unit_cube (bool flip_normals=false, bool edges=false)
 tesselate a unit cube with extent from [-1,-1,-1] to [1,1,1] with face normals that can be flipped
 
virtual void tesselate_box (const cgv::media::axis_aligned_box< double, 3 > &B, bool flip_normals, bool edges=false) const
 tesselate an axis aligned box More...
 
void tesselate_unit_prism (bool flip_normals=false, bool edges=false)
 tesselate a prism
 
void tesselate_unit_disk (int resolution=25, bool flip_normals=false, bool edges=false)
 tesselate a circular disk of radius 1
 
void tesselate_unit_cone (int resolution=25, bool flip_normals=false, bool edges=false)
 tesselate a cone of radius 1
 
void tesselate_unit_cylinder (int resolution=25, bool flip_normals=false, bool edges=false)
 tesselate a cylinder of radius 1
 
void tesselate_unit_sphere (int resolution=25, bool flip_normals=false, bool edges=false)
 tesselate a sphere of radius 1
 
void tesselate_unit_tetrahedron (bool flip_normals=false, bool edges=false)
 tesselate a tetrahedron
 
void tesselate_unit_octahedron (bool flip_normals=false, bool edges=false)
 tesselate a octahedron
 
void tesselate_unit_dodecahedron (bool flip_normals=false, bool edges=false)
 tesselate a dodecahedron
 
void tesselate_unit_icosahedron (bool flip_normals=false, bool edges=false)
 tesselate an icosahedron
 
void tesselate_unit_torus (float minor_radius=0.2f, int resolution=25, bool flip_normals=false, bool edges=false)
 tesselate a torus with major radius of one and given minor radius
 

Protected Member Functions

bool frame_buffer_attach (frame_buffer_base &fbb, const texture_base &t, bool is_depth, int level, int i, int z) const
 attach 2d texture to depth buffer if it is a depth texture, to stencil if it is a stencil texture or to the i-th color attachment if it is a color texture
 
bool frame_buffer_is_complete (const frame_buffer_base &fbb) const
 check for completeness, if not complete, get the reason in last_error
 
bool frame_buffer_disable (frame_buffer_base &fbb)
 disable the framebuffer object
 
void rotate_vector_to_target (const dvec3 &vector, const dvec3 &target)
 helper function that multiplies a rotation to modelview matrix such that vector is rotated onto target
 
virtual void process_text (const std::string &text)
 callback method for processing of text from the output stream
 
virtual void draw_text (const std::string &text)
 draw some text at cursor position and update cursor position
 

Protected Attributes

cgv::media::font::font_face_ptr info_font_face
 font used to draw textual info
 
float info_font_size
 font size to draw textual info
 
bool auto_set_view_in_current_shader_program
 whether to automatically set viewing matrixes in current shader program, defaults to true
 
bool auto_set_lights_in_current_shader_program
 whether to automatically set lights in current shader program, defaults to true
 
bool auto_set_material_in_current_shader_program
 whether to automatically set material in current shader program, defaults to true
 
bool auto_set_gamma_in_current_shader_program
 whether to automatically set gamma in current shader program, defaults to true
 
bool support_compatibility_mode
 whether to support view and lighting management of compatibility mode, defaults to true
 
bool draw_in_compatibility_mode
 whether to do all drawing in compatibility mode, only possible if support_compatibility_mode is true, , defaults to false
 
bool debug_render_passes
 whether to debug render passes
 
bool enable_vsynch
 whether vsynch should be enabled
 
rgba current_color
 current color value
 
bool sRGB_framebuffer
 whether to use opengl option to support sRGB framebuffer
 
float gamma
 gamma value passed to shader programs that have gamma uniform
 
std::stack< dmat4modelview_matrix_stack
 keep two matrix stacks for model view and projection matrices
 
std::stack< std::vector< window_transformation > > window_transformation_stack
 keep stack of window transformations
 
std::stack< frame_buffer_base * > frame_buffer_stack
 stack of currently enabled frame buffers
 
std::stack< shader_program_base * > shader_program_stack
 stack of currently enabled shader programs
 
std::stack< attribute_array_binding_base * > attribute_array_binding_stack
 stack of currently enabled attribute array binding
 
std::vector< void * > enabled_light_source_handles
 keep track of enabled light source handles
 
size_t light_source_handle
 counter to construct light source handles
 
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
 
cgv::media::illum::light_source default_light_source [nr_default_light_sources]
 default light sources
 
void * default_light_source_handles [nr_default_light_sources]
 handles of default light sources
 
cgv::media::illum::surface_material default_material
 store a default material
 
const cgv::media::illum::surface_materialcurrent_material_ptr
 store pointer to current material
 
bool current_material_is_textured
 store flag to tell whether current material is textured
 
std::stack< render_inforender_pass_stack
 store the current render pass
 
RenderPassFlags default_render_flags
 default render flags with which the main render pass is initialized
 
float bg_r
 current background color, depth, stencil and accum color
 
bool phong_shading
 whether to use phong shading
 
int current_background
 current back ground color index
 
int cursor_x
 current cursor location for textual output
 
cgv::signal::callback_stream out_stream
 use a callback stream to write text to the opengl context
 
float current_font_size
 store current font size
 
cgv::media::font::font_face_ptr current_font_face
 store current font
 
int tab_size
 size a tabs
 
int x_offset
 offset in x and y direction where text starts
 
int nr_identations
 current number of indentations
 
bool at_line_begin
 store whether we are at the beginning of the line
 

Static Protected Attributes

static const unsigned nr_default_light_sources = 2
 number of default light sources
 

context creation parameters

bool self_reflect (cgv::reflect::reflection_handler &srh)
 reflect the shader_path member
 
bool depth_buffer
 default: true
 
bool double_buffer
 default: true
 
bool alpha_buffer
 default: false
 
bool stereo_buffer
 default: false
 
bool stencil_buffer
 default: false
 
bool accumulation_buffer
 default: false
 
bool multi_sample_buffer
 default: false
 
int depth_bits
 default: -1
 
int stencil_bits
 default: -1
 
int accumulation_bits
 default: -1
 
int nr_multi_samples
 default: -1
 
int version_major
 default: -1 ... major version of maximum supported OpenGL version
 
int version_minor
 default: -1 ... minor version of maximum supported OpenGL version
 
bool forward_compatible
 default: false
 
bool debug
 default: false in release and true in debug version
 
bool core_profile
 default: false
 

surface rendering and material management

 DEPRECATED ("deprecated and ignored.") virtual void enable_phong_shading()
 
 DEPRECATED ("deprecated and ignored.") virtual void disable_phong_shading()
 
virtual void set_gamma (float _gamma)
 set the current gamma values
 
float get_gamma () const
 query current gamma
 
virtual void enable_sRGB_framebuffer (bool do_enable=true)
 enable or disable sRGB framebuffer
 
bool sRGB_framebuffer_enabled ()
 check whether sRGB framebuffer is enabled
 
const rgbaget_color () const
 return current color
 
virtual void set_color (const rgb &clr, float opacity=1.0f)
 set the current color
 
const cgv::media::illum::surface_materialget_current_material () const
 return pointer to current material or nullptr if no current material is available
 
virtual void set_textured_material (const textured_material &mat)
 set the current material
 
void set_current_view (shader_program &prog, bool modelview_deps=true, bool projection_deps=true) const
 set the shader program view matrices to the currently enabled view matrices
 
void set_current_material (shader_program &prog) const
 set the shader program material to the currently enabled material
 
void set_current_lights (shader_program &prog) const
 set the shader program lights to the currently enabled lights
 
vec3 get_light_eye_position (const cgv::media::illum::light_source &light, bool place_now) const
 helper function to place lights
 
vec3 get_light_eye_spot_direction (const cgv::media::illum::light_source &light, bool place_now) const
 helper function to place spot lights More...
 
DEPRECATED("deprecated, use set_material instead.") virtual void enable_material(const cgv DEPRECATED("deprecated and ignored.") virtual void disable_material(const cgv MaterialSide ms = MS_FRONT_AND_BACK
 
DEPRECATED("deprecated, use set_material instead.") virtual void enable_material(const cgv DEPRECATED("deprecated and ignored.") virtual void disable_material(const cgv MaterialSide float alpha = 1)
 

transformations

bool ensure_window_transformation_index (int &array_index)
 
 DEPRECATED ("deprecated: use get_modelview_matrix() instead.") dmat_type get_V() const
 
 DEPRECATED ("deprecated: use set_modelview_matrix() instead.") void set_V(const dmat_type &V) const
 
 DEPRECATED ("deprecated: use push_modelview_matrix() instead.") void push_V()
 
 DEPRECATED ("deprecated: use pop_modelview_matrix() instead.") void pop_V()
 
 DEPRECATED ("deprecated: use get_projection_matrix() instead.") dmat_type get_P() const
 
 DEPRECATED ("deprecated: use set_projection_matrix() instead.") void set_P(const dmat_type &P) const
 
 DEPRECATED ("deprecated: use push_projection_matrix() instead.") void push_P()
 
 DEPRECATED ("deprecated: use pop_projection_matrix() instead.") void pop_P()
 
 DEPRECATED ("deprecated: use get_device_matrix() instead.") dmat_type get_D() const
 
 DEPRECATED ("deprecated: use get_modelview_projection_device_matrix() instead.") mat_type get_DPV() const
 
 DEPRECATED ("use get_window_matrix() instead.") dmat4 get_device_matrix() const
 return homogeneous 4x4 projection matrix, which transforms from clip to device space
 
 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, projection and device matrix in reversed order (device_matrix*projection_matrix*modelview_matrix)
 
 DEPRECATED ("use get_window_z()") double get_z_D(int x_D
 read the window z-coordinate from the z-buffer for the given device x- and y-coordinates
 
 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 with the device z-coordinate currently stored in the displayed depth buffer.
 
 DEPRECATED ("use get_model_point()") vec3 get_point_W(int x_D
 compute the location in world space of a device x/y-location by inversion of the given transformation from world to device space. For this the device point is extended with the device z-coordinate currently stored in the displayed depth buffer.
 
 DEPRECATED ("use get_model_point()") vec3 get_point_W(int x_D
 compute the location in world space of a device point. For this the current world to device transformation is inverted.
 
 DEPRECATED ("use get_model_point()") vec3 get_point_W(int x_D
 compute the location in world space of a device point by inversion of the given world to device transformation.
 
 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.
 
 DEPRECATED ("use get_model_point()") vec3 get_point_W(const vec3 &p_D
 compute a the location in world space of a device point.
 
virtual void mul_modelview_matrix (const dmat4 &MV)
 multiply given matrix from right to current modelview matrix
 
void push_modelview_matrix ()
 push the current viewing matrix onto a matrix stack for viewing matrices. More...
 
void pop_modelview_matrix ()
 see push_V for an explanation
 
virtual void mul_projection_matrix (const dmat4 &P)
 multiply given matrix from right to current projection matrix
 
void push_projection_matrix ()
 same as push_V but for the projection matrix - a different matrix stack is used.
 
void pop_projection_matrix ()
 see push_P for an explanation
 
void push_window_transformation_array ()
 push a copy of the current viewport and depth range arrays defining the window transformations
 
const std::vector< window_transformation > & get_window_transformation_array () const
 return the current window transformation array
 
dmat4 get_window_matrix (unsigned array_index=0) const
 return a homogeneous 4x4 matrix to transform clip to window coordinates More...
 
dmat4 get_modelview_projection_window_matrix (unsigned array_index=0) const
 return a homogeneous 4x4 matrix to transfrom from model to window coordinates, i.e. the product of modelview, projection and device matrix in reversed order (window_matrix*projection_matrix*modelview_matrix)
 
vec3 get_model_point (int x_window, int y_window) const
 compute model space 3D point from the given window location More...
 
vec3 get_model_point (int x_window, int y_window, double z_window) const
 compute model space 3D point from the given window coordinates More...
 
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 More...
 
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_window matrix More...
 
vec3 get_model_point (const vec3 &p_window) const
 compute model space 3D point from the given window space point More...
 
vec3 get_model_point (const dvec3 &p_window, const dmat4 &modelview_projection_window_matrix) const
 compute model space 3D point from the given window space point and the given modelview_projection_window matrix More...
 
int y_D const { return get_window_z(x_D, y_D)
 
int const dmat4 &MPD const { return get_model_point(x_D, y_D, MPD)
 
int double z_D const { return get_model_point(x_D, y_D, z_D)
 
int double const dmat4 &MPD const { return get_model_point(x_D, y_D, z_D, MPD)
 
const dmat4 &MPD const { return get_model_point(p_D, MPD)
 
int y_D
 
int double z_D
 

transformations

void update_window_transformation_array ()
 
dmat4 get_modelview_matrix () const
 return homogeneous 4x4 viewing matrix, which transforms from world to eye space
 
void set_modelview_matrix (const dmat4 &V)
 set the current modelview matrix, which transforms from world to eye space
 
dmat4 get_projection_matrix () const
 return homogeneous 4x4 projection matrix, which transforms from eye to clip space
 
void set_projection_matrix (const dmat4 &P)
 set the current projection matrix, which transforms from eye to clip space
 
void pop_window_transformation_array ()
 restore previous viewport and depth range arrays defining the window transformations
 
unsigned get_max_window_transformation_array_size () const
 query the maximum number of supported window transformations, which is at least 1
 
void set_viewport (const ivec4 &viewport, int array_index=-1)
 set the current viewport or one of the viewports in the window transformation array
 
void set_depth_range (const dvec2 &depth_range=dvec2(0, 1), int array_index=-1)
 set the current depth range or one of the depth ranges in the window transformation array
 
double get_window_z (int x_window, int y_window) const
 read the device z-coordinate from the z-buffer for the given device x- and y-coordinates
 

Detailed Description

implementation of the context API for the OpenGL API excluding methods for font selection, redraw and initiation of render passes.

Constructor & Destructor Documentation

◆ gl_context()

cgv::render::gl::gl_context::gl_context ( )

construct context and attach signals

construct gl_context and attach signals

Member Function Documentation

◆ configure_gl()

bool cgv::render::gl::gl_context::configure_gl ( )

ensure that glew is initialized, define lighting mode, viewing pyramid and the rendering mode and return whether gl configuration was successful

define lighting mode, viewing pyramid and the rendering mode

◆ draw_light_source()

void cgv::render::gl::gl_context::draw_light_source ( const cgv::media::illum::light_source l,
float  intensity_scale,
float  light_scale 
)
virtual

draw a light source with an emissive material

Parameters
[in]lto be rendered light source
[in]intensity_scaleused to multiply with the light source values

Reimplemented from cgv::render::context.

◆ enumerate_program_attributes()

void cgv::render::gl::gl_context::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
virtual

get list of program attributes

get list of program uniforms

Implements cgv::render::context.

◆ get_cursor()

void cgv::render::context::get_cursor ( int &  x,
int &  y 
) const
virtualinherited

return current cursor location in mouse coordinates

store the current cursor location in the passed references to x and y coordinate

◆ get_light_eye_spot_direction()

context::vec3 cgv::render::context::get_light_eye_spot_direction ( const cgv::media::illum::light_source light,
bool  place_now 
) const
inherited

helper function to place spot lights

helper function to place lights

◆ get_model_point() [1/6]

context::vec3 cgv::render::context::get_model_point ( const dvec3 p_window,
const dmat4 modelview_projection_window_matrix 
) const
inherited

compute model space 3D point from the given window space point and the given modelview_projection_window matrix

the function inversely transforms the window space point with the given modelview_projection_window matrix

◆ get_model_point() [2/6]

vec3 cgv::render::context::get_model_point ( const vec3 p_window) const
inlineinherited

compute model space 3D point from the given window space point

the function inversely transforms the window space 3D point with the current modelview_projection_window matrix

◆ get_model_point() [3/6]

vec3 cgv::render::context::get_model_point ( int  x_window,
int  y_window 
) const
inlineinherited

compute model space 3D point from the given window location

the function queries the window z coordinate from the depth buffer and inversely transforms the window space 3D point with the current modelview_projection_window matrix

◆ get_model_point() [4/6]

vec3 cgv::render::context::get_model_point ( int  x_window,
int  y_window,
const dmat4 modelview_projection_window_matrix 
) const
inlineinherited

compute model space 3D point from the given window location and modelview_projection_window matrix

the function queries the window z coordinate from the depth buffer and inversely transforms the window space 3D point with the given modelview_projection_window matrix

◆ get_model_point() [5/6]

vec3 cgv::render::context::get_model_point ( int  x_window,
int  y_window,
double  z_window 
) const
inlineinherited

compute model space 3D point from the given window coordinates

the function inversely transforms the window space 3D point with the current modelview_projection_window matrix

◆ get_model_point() [6/6]

vec3 cgv::render::context::get_model_point ( int  x_window,
int  y_window,
double  z_window,
const dmat4 modelview_projection_window_matrix 
) const
inlineinherited

compute model space 3D point from the given window coordinates with the given modelview_projection_window matrix

the function inversely transforms the window space 3D point with the given modelview_projection_window matrix

◆ get_render_pass_recursion_depth()

unsigned cgv::render::context::get_render_pass_recursion_depth ( ) const
inherited

return current render pass recursion depth

return the current render pass

◆ get_window_matrix()

context::dmat4 cgv::render::context::get_window_matrix ( unsigned  array_index = 0) const
inherited

return a homogeneous 4x4 matrix to transform clip to window coordinates

return a homogeneous 4x4 matrix to transform clip to window coordinates, optionally specify for the case of multiple viewports/depth ranges

In window coordinates x- and y-coordinates correspond to mouse pixel coordinates and z to depth value stored in the depth buffer. This is a different convention as in OpenGL where the y-coordinates point from bottom to top instead from top to bottom. Optionally one can specify a window transformation index with the parameter array_index for the case when an array of window transformations is used.

◆ output_stream()

std::ostream & cgv::render::context::output_stream ( )
virtualinherited

returns an output stream whose output is printed at the current cursor location

returns an output stream whose output is printed at the current cursor location, which is managed by the context. The coordinate system of the cursor location corresponds to window / mouse coordinates. The cursor position is updated during text drawing also by special characters like tab or new line and can be read back with the get_cursor method. Use the flush method of the output_stream to ensure that text has been drawn to the context.

◆ push_modelview_matrix()

void cgv::render::context::push_modelview_matrix ( )
inherited

push the current viewing matrix onto a matrix stack for viewing matrices.

A software implementation is used for the matrix stack as some hardware stacks - i.e. in opengl - have strong limitations on their maximum size. The push_V method does not change the current viewing matrix similarly to the glPushMatrix function. Use pop_V() to restore the pushed viewing matrix into the current viewing matrix. Don't intermix these methods with the correspondong opengl or directx functions.

◆ put_cursor_coords()

void cgv::render::context::put_cursor_coords ( const vec_type p,
int &  x,
int &  y 
) const
virtualinherited

transform point p into cursor coordinates and put x and y coordinates into the passed variables

transform point p in current world coordinates into cursor coordinates and put x and y coordinates into the passed variables

◆ ref_surface_shader_program()

shader_program & cgv::render::gl::gl_context::ref_surface_shader_program ( bool  texture_support = false)
virtual

return a reference to the default shader program used to render surfaces

return a reference to the default shader program used to render surfaces without textures

Implements cgv::render::context.

◆ set_bg_accum_alpha()

void cgv::render::context::set_bg_accum_alpha ( float  a)
virtualinherited

set a user defined background alpha value for the accumulation buffer

set a user defined background alpha value

◆ set_bg_accum_color()

void cgv::render::context::set_bg_accum_color ( float  r,
float  g,
float  b,
float  a 
)
virtualinherited

set a user defined background color for the accumulation buffer

set a user defined background color

◆ set_bg_clr_idx()

void cgv::render::context::set_bg_clr_idx ( unsigned int  idx)
virtualinherited

set an indexed background color

set a user defined background color

◆ set_bg_depth()

void cgv::render::context::set_bg_depth ( float  d)
virtualinherited

set a user defined background depth value

set a user defined background depth

◆ set_bg_stencil()

void cgv::render::context::set_bg_stencil ( int  s)
virtualinherited

set a user defined background stencil value

set a user defined background color

◆ set_cursor() [1/2]

void cgv::render::context::set_cursor ( const vec_type pos,
const std::string &  text = "",
TextAlignment  ta = TA_BOTTOM_LEFT,
int  x_offset = 0,
int  y_offset = 0 
)
virtualinherited

sets the current text ouput position

flush output_stream and set the current text position from a 3D or 4D location in current world coordinates. These are transformed to mouse coordinates with the put_cursor_coords method. If the optional parameters are given, update the cursor location such that the given text alignment is achieved.

◆ set_cursor() [2/2]

void cgv::render::context::set_cursor ( int  x,
int  y 
)
virtualinherited

set a new cursor position, which is only valid between calls of push_pixel_coords and pop_pixel_coords

flush the output_stream and set a new cursor position given in window/mouse coordinates

◆ tesselate_arrow()

void cgv::render::gl::gl_context::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 
)
virtual

tesselate an arrow from the origin in z-direction

An arrow of length L is composed of a cylinder of radius R and a cone of radius r. The parameters are

Parameters
[in]lengththe total length of the radius
[in]aspectis defined as R/L
[in]rel_tip_radiusis defined as r/R
[in]tip_aspectis defined as r/l

Reimplemented from cgv::render::context.

◆ tesselate_box()

void cgv::render::context::tesselate_box ( const cgv::media::axis_aligned_box< double, 3 > &  B,
bool  flip_normals,
bool  edges = false 
) const
virtualinherited

tesselate an axis aligned box

tesselate an axis aligned box in single precision

◆ tesselate_unit_square()

void cgv::render::context::tesselate_unit_square ( bool  flip_normals = false,
bool  edges = false 
)
inherited

tesselate a unit square in the xy-plane with texture coordinates

tesselate a unit square

◆ write_frame_buffer_to_image()

bool cgv::render::context::write_frame_buffer_to_image ( const std::string &  file_name,
data::ComponentFormat  cf = data::CF_RGB,
FrameBufferType  buffer_type = FB_BACK,
unsigned int  x = 0,
unsigned int  y = 0,
int  w = -1,
int  h = -1,
float  depth_offset = 0.9f,
float  depth_scale = 10.0f 
)
inherited

write the content of a buffer to an image file

write the content of the frame buffer to an image file. In case of writing a depth buffer a the depth offset is subtracted from the value and scaled by the depth scale before conversion to an unsigned int of bit depth 8 is performed.


The documentation for this class was generated from the following files: