4#include <cgv/render/context.h>
5#include <cgv/render/shader_program.h>
6#include <cgv_gl/gl/gl.h>
20extern CGV_API
void set_gl_format(texture& tex, GLuint gl_format,
const std::string& component_format_description);
31extern CGV_API GLboolean map_to_gl(
bool flag);
33extern CGV_API GLuint get_gl_id(
const void* handle);
35extern CGV_API
void* get_handle(GLuint
id);
46 GLuint texture_bind(
TextureType tt, GLuint tex_id)
const;
47 void texture_unbind(
TextureType tt, GLuint tmp_id)
const;
56 shader_program progs[4];
58 bool debug_texture_format_matching =
false;
59 void ensure_configured()
const;
60 void destruct_render_objects()
override;
61 void put_id(
void* handle,
void* ptr)
const override;
62 void draw_elements_void(GLenum mode,
size_t count, GLenum
type,
size_t type_size,
const void* indices)
const;
64 void draw_elements(GLenum mode,
size_t count,
const T* indices)
const {
65 if (!gl_traits<T>::valid_index)
66 error(
"called draw_elements with invalid index type");
68 draw_elements_void(mode, count, gl_traits<T>::type,
sizeof(T), indices);
76 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 override;
79 bool texture_generate_mipmaps(
texture_base& tb,
unsigned int dim)
const override;
81 bool texture_set_state(
const texture_base& tb)
const override;
82 bool texture_enable(
texture_base& tb,
int tex_unit,
unsigned int nr_dims)
const override;
83 bool texture_disable(
texture_base& tb,
int tex_unit,
unsigned int nr_dims)
const override;
84 bool texture_bind_as_image(
texture_base& tb,
int tex_unit,
int level,
bool bind_array,
int layer,
AccessType access)
const override;
97 int frame_buffer_get_max_nr_color_attachments()
const override;
98 int frame_buffer_get_max_nr_draw_buffers()
const override;
100 bool shader_code_create(render_component& sc,
ShaderType st,
const std::string& source)
const override;
101 bool shader_code_compile(render_component& sc)
const override;
102 void shader_code_destruct(render_component& sc)
const override;
104 bool shader_program_create(shader_program_base& spb)
const override;
105 void shader_program_attach(shader_program_base& spb,
const render_component& sc)
const override;
106 bool shader_program_link(shader_program_base& spb)
const override;
107 bool shader_program_set_state(shader_program_base& spb)
const override;
108 bool shader_program_enable(shader_program_base& spb)
override;
109 bool shader_program_disable(shader_program_base& spb)
override;
110 void shader_program_detach(shader_program_base& spb,
const render_component& sc)
const override;
111 bool shader_program_destruct(shader_program_base& spb)
const override;
112 bool shader_program_get_active_uniforms(shader_program_base& spb, std::vector<std::string>& names)
const override;
113 void shader_program_inspect_variables(shader_program_base& spb,
ProgramVariableKind kind, std::vector<program_variable_info>& Vs,
bool get_location,
bool get_value)
const override;
115 int get_uniform_location(
const shader_program_base& spb,
const std::string& name)
const override;
116 bool set_uniform_void(shader_program_base& spb,
int loc,
type_descriptor value_type,
const void* value_ptr)
const override;
117 bool set_uniform_array_void(shader_program_base& spb,
int loc,
type_descriptor value_type,
const void* value_ptr,
size_t nr_elements)
const override;
118 int get_uniform_block_index(
const shader_program_base& spb,
const std::string& name)
const override;
119 bool set_uniform_block_binding(shader_program_base& spb,
int index,
int binding)
const override;
120 int get_attribute_location(
const shader_program_base& spb,
const std::string& name)
const override;
121 bool set_attribute_void(shader_program_base& spb,
int loc,
type_descriptor value_type,
const void* value_ptr)
const override;
134 bool vertex_buffer_create(
vertex_buffer_base& vbb,
const void* array_ptr,
size_t size_in_bytes)
const override;
135 bool vertex_buffer_resize(
vertex_buffer_base& vbb,
const void* array_ptr,
size_t size_in_bytes)
const override;
136 bool vertex_buffer_clear(
vertex_buffer_base& vbb,
size_t offset,
size_t size_in_bytes)
const override;
137 bool vertex_buffer_replace(
vertex_buffer_base& vbb,
size_t offset,
size_t size_in_bytes,
const void* array_ptr)
const override;
139 bool vertex_buffer_copy_back(
const vertex_buffer_base& vbb,
size_t offset,
size_t size_in_bytes,
void* array_ptr)
const override;
151 void draw_textual_info()
override;
173 void clear_background(
bool color_flag,
bool depth_flag,
bool stencil_flag =
false,
bool accum_flag =
false)
override;
184 void perform_screen_shot()
override;
188 void init_render_pass()
override;
190 void finish_render_pass()
override;
206 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 override;
208 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 override;
212 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)
override;
214 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)
override;
236 unsigned int x = 0,
unsigned int y = 0,
240 int w = -1,
int h = -1)
override;
246 bool prepare_attributes(std::vector<vec3>& P, std::vector<vec3>& N, std::vector<vec2>& T,
unsigned nr_vertices,
247 const float* vertices,
const float* normals,
const float* tex_coords,
248 const int* vertex_indices,
const int* normal_indices,
const int* tex_coord_indices,
bool flip_normals)
const;
250 bool release_attributes(
const float* normals,
const float* tex_coords,
const int* normal_indices,
const int* tex_coord_indices)
const;
253 const float* vertices,
const float* normals,
const float* tex_coords,
254 const int* vertex_indices,
const int* normal_indices,
const int* tex_coord_indices,
255 int nr_faces,
int face_degree,
bool flip_normals =
false)
const override;
258 const float* vertices,
const float* normals,
const float* tex_coords,
259 const int* vertex_indices,
const int* normal_indices,
const int* tex_coord_indices,
260 int nr_faces,
int face_degree,
bool is_fan,
bool flip_normals =
false)
const override;
263 const float* vertices,
const float* normals,
const float* tex_coords,
264 const int* vertex_indices,
const int* normal_indices,
const int* tex_coord_indices,
265 int nr_faces,
int face_degree,
bool flip_normals)
const override;
268 const float* vertices,
const float* normals,
const float* tex_coords,
269 const int* vertex_indices,
const int* normal_indices,
const int* tex_coord_indices,
270 int nr_faces,
int face_degree,
bool is_fan,
bool flip_normals)
const override;
326 void update_window_transformation_array();
336 double get_window_z(
int x_window,
int y_window)
const override;
344#include <cgv/config/lib_end.h>
The const_data_view has the functionality of the data_view but uses a const pointer and therefore doe...
the data view gives access to a data array of one, two, three or four dimensions.
base class for attribute_array_bindings
base class for all drawables, which is independent of the used rendering API.
virtual void error(const std::string &message, const render_component *rc=0) const
error handling
base interface for framebuffer
media::font::font_face_ptr get_current_font_face() const override
overwrite function to return info font face in case no font is currently selected
void set_depth_func(CompareFunction func) override
set the depth test function
void push_pixel_coords() override
use this to push transformation matrices on the stack such that x and y coordinates correspond to win...
void set_depth_mask(bool flag) override
set the depth buffer mask
RenderAPI get_render_api() const override
return the used rendering API
bool frame_buffer_disable(frame_buffer_base &fbb) override
disable the framebuffer object
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) override
tesselate an arrow from the origin in z-direction
void set_color(const rgba &clr) override
set the current color
void set_buffer_mask(BufferMask mask) override
set the buffer mask for depth and color buffers
float info_font_size
font size to draw textual info
bool frame_buffer_is_complete(const frame_buffer_base &fbb) const override
check for completeness, if not complete, get the reason in last_error
void set_bg_color(vec4 rgba) override
set a user defined background color
void draw_light_source(const cgv::media::illum::light_source &l, float intensity_scale, float light_scale) override
draw a light source with an emissive material
void announce_external_viewport_change(ivec4 &cgv_viewport_storage) override
announce an external viewport change performed with rendering API to the cgv framework providing spac...
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 override
get list of program attributes
void enable_depth_test() override
enable the depth test
void pop_window_transformation_array() override
restore previous viewport and depth range arrays defining the window transformations
shader_program & ref_default_shader_program(bool texture_support=false) override
return a reference to a shader program used to render without illumination
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
gl_context()
construct context and attach signals
cgv::media::font::font_face_ptr get_info_font_face() const
return info font face and ensure that it is created
void set_color_mask(bvec4 flags) override
set the color buffer mask
void recover_from_external_frame_buffer_change(void *cgv_fbo_storage) override
restore cgv frame buffer to the state before the external change
dmat4 get_modelview_matrix() const override
return homogeneous 4x4 viewing matrix, which transforms from world to eye space
void set_material(const cgv::media::illum::surface_material &mat) override
set the current material
void enable_blending() override
enable blending
void set_bg_stencil(int s) override
set a user defined background stencil value
void recover_from_external_viewport_change(const ivec4 &cgv_viewport_storage) override
restore cgv viewport to the state before the external change
void set_modelview_matrix(const dmat4 &V) override
set the current modelview matrix, which transforms from world to eye space
double get_window_z(int x_window, int y_window) const override
read the device z-coordinate from the z-buffer for the given device x- and y-coordinates
dmat4 get_projection_matrix() const override
return homogeneous 4x4 projection matrix, which transforms from eye to clip space
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 override
get list of program uniforms
virtual bool read_frame_buffer(data::data_view &dv, unsigned int x=0, unsigned int y=0, FrameBufferType buffer_type=FB_BACK, cgv::type::info::TypeId type=type::info::TI_UINT8, data::ComponentFormat cf=data::CF_RGB, int w=-1, int h=-1) override
implement according to specification in context class
void enable_material(textured_material &mat) override
enable a material with textures
float get_info_font_size() const
return info font size
void set_bg_depth(float d) override
set a user defined background depth value
cgv::media::font::font_face_ptr info_font_face
font used to draw textual info
void clear_background(bool color_flag, bool depth_flag, bool stencil_flag=false, bool accum_flag=false) override
clear the buffer contents of the flagged buffers to the set background colors
shader_program & ref_surface_shader_program(bool texture_support=false) override
return a reference to the default shader program used to render surfaces
void set_depth_range(const dvec2 &depth_range=dvec2(0, 1), int array_index=-1) override
set the current depth range or one of the depth ranges in the window transformation array
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 override
tesselate with one face strip
void set_blend_state(BlendState state) override
set the complete blend state
bool configure_gl()
ensure that glew is initialized, define lighting mode, viewing pyramid and the rendering mode and ret...
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
float get_current_font_size() const override
overwrite function to return info font size in case no font is currently selected
void set_cull_state(CullingMode culling_mode) override
set the culling state
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 override
pass geometry of given faces to current shader program and generate draw calls to render lines for th...
void set_projection_matrix(const dmat4 &P) override
set the current projection matrix, which transforms from eye to clip space
unsigned get_max_window_transformation_array_size() const override
query the maximum number of supported window transformations, which is at least 1
void set_bg_accum_color(vec4 rgba) override
set a user defined background color for the accumulation buffer
void disable_blending() override
disable blending
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 targe...
void set_blend_func(BlendFunction src_factor, BlendFunction dst_factor) override
set the blend function
void set_viewport(const ivec4 &viewport, int array_index=-1) override
set the current viewport or one of the viewports in the window transformation array
void pop_pixel_coords() override
pop previously changed transformation matrices
void disable_material(textured_material &mat) override
disable a material with textures
void on_lights_changed() override
helper function to send light update events
void disable_depth_test() override
disable the depth test
void set_blend_func_separate(BlendFunction src_color_factor, BlendFunction dst_color_factor, BlendFunction src_alpha_factor, BlendFunction dst_alpha_factor) override
set the blend function separately for color and alpha
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 override
tesselate with independent faces
void set_depth_test_state(DepthTestState state) override
set the depth test state
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 override
pass geometry of given strip or fan to current shader program and generate draw calls to render lines...
void announce_external_frame_buffer_change(void *&cgv_fbo_storage) override
announce an external frame buffer change performed with rendering API to the cgv framework providing ...
base interface for a render_buffer
base interface for all render components
base interface for a texture
class that extends obj_material with the management of textures
base interface for a vertex buffer
namespace for data management components
ComponentFormat
define standard formats, which should be used to avoid wrong assignment of component names
@ CF_RGB
color format with two components R and G
namespace for opengl specific GPU programming
CGV_API void set_material(const cgv::media::illum::phong_material &mat, MaterialSide ms, float alpha)
set material in opengl state to given material
void set_gl_format(texture &tex, GLuint gl_format, const std::string &component_format_description)
set a very specific texture format. This should be called after the texture is constructed and before...
std::vector< int > get_context_creation_attrib_list(cgv::render::context_config &cc)
construct a 0 terminated list of context creation attribute definitions
GLuint get_gl_format(const texture &tex)
return the texture format used for a given texture. If called before texture has been created,...
namespace for api independent GPU programming
RenderAPI
enumeration of rendering APIs which can be queried from the context
CullingMode
different culling modes
BlendFunction
different blend functions
AccessType
different access types
FrameBufferType
different frame buffer types which can be combined together with or
MaterialSide
different sides of a material
ProgramVariableKind
enumerates different kinds of shader program variables
ShaderType
different shader types
PrimitiveType
different primitive types
VertexBufferType
Provides vertex buffer types to allow implicit binding.
BufferTypeBits
Bits for the selection of different buffer types.
TextureType
different texture types
CompareFunction
different comparison functions used for depth testing or texture comparisons
TypeId
ids for the different types and type constructs
@ TI_UINT8
signed integer stored in 64 bits
namespace for compile time type information
unsigned long long uint64_type
this type provides an 64 bit unsigned integer type
this header is dependency free
cgv::math::fvec< float, 4 > vec4
declare type of 4d single precision floating point vectors (used for homogeneous coordinates)
cgv::media::color< float, cgv::media::RGB, cgv::media::OPACITY > rgba
declare rgba color type with 32 bit components
cgv::math::fvec< double, 3 > dvec3
declare type of 3d double precision floating point vectors
cgv::math::fvec< int32_t, 4 > ivec4
declare type of 4d 32 bit integer vectors
cgv::math::fmat< double, 4, 4 > dmat4
declare type of 4x4 matrices
cgv::math::fvec< bool, 4 > bvec4
declare type of 4d boolean vectors
cgv::math::fvec< double, 2 > dvec2
declare type of 2d double precision floating point vectors
Represents a blend state used to configure fragment blending.
Represents a buffer mask used to mask depth and color buffer outputs.
Represents a depth test state used to configure depth testing.
compact type description of data that can be sent to the context; convertible to int