1#include <cgv/base/group.h>
4#include <cgv_gl/gl/wgl.h>
11#include <cgv/base/base.h>
12#include <cgv/base/action.h>
13#include <cgv/render/drawable.h>
14#include <cgv/render/shader_program.h>
15#include <cgv/render/attribute_array_binding.h>
16#include <cgv/render/vertex_buffer.h>
17#include <cgv/render/textured_material.h>
19#include <cgv/media/image/image_writer.h>
20#include <cgv/gui/event_handler.h>
21#include <cgv/math/ftransform.h>
22#include <cgv/math/geom.h>
23#include <cgv/math/inv.h>
24#include <cgv/type/standard_types.h>
25#include <cgv/os/clipboard.h>
31using namespace cgv::os;
32using namespace cgv::math;
34using namespace cgv::media::illum;
63 if (
cc.version_major < 1)
66 version = 10 *
cc.version_major + (
cc.version_minor >= 0 ?
cc.version_minor : 0);
67 if ((version > 30 &&
cc.forward_compatible) ||
cc.debug) {
73 if (
cc.version_major > 0) {
77 if (
cc.version_minor >= 0) {
175static const GLenum gl_depth_format_ids[] =
183static const GLenum gl_color_buffer_format_ids[] =
189static const char* depth_formats[] =
198static const char* color_buffer_formats[] =
271GLuint get_gl_id(
const void* handle)
273 return (
const GLuint&)handle - 1;
276void* get_handle(
GLuint id)
283void gl_context::put_id(
void* handle,
void* ptr)
const
285 *
static_cast<GLuint*
>(ptr) = get_gl_id(handle);
298 if (tex.internal_format)
299 return (
const GLuint&)tex.internal_format;
308 GLfloat v[4] = { c[0],c[1],c[2],c[3] * alpha };
317 unsigned side = map_to_gl(
ms);
371std::string get_source_tag_name(
GLenum tag)
373 static std::map<GLenum, const char*>
source_tags = {
386 static std::map<GLenum, const char*>
type_tags = {
400std::string get_severity_tag_name(
GLenum tag)
415 const gl_context* ctx =
reinterpret_cast<const gl_context*
>(
userParam);
417 msg = std::string(
"GLDebug Message[") +
cgv::utils::to_string(
id) +
"] from " + get_source_tag_name(source) +
" of type " + get_type_tag_name(type) +
" of severity " + get_severity_tag_name(
severity) +
"\n" +
msg;
425 error(
"gl_context::configure_gl could not initialize glew");
450 std::cerr <<
"WARNING: Ignoring that GL_CONTEXT_PROFILE_MASK yields compatibility profile for context created as core." << std::endl;
452 std::cerr <<
"WARNING: Ignoring that GL_CONTEXT_PROFILE_MASK does not yield compatibility profile for context created as such." << std::endl;
456 std::cerr <<
"WARNING: Ignoring that GL_CONTEXT_PROFILE_MASK yields zero." << std::endl;
467 gpu_vendor = GPU_VENDOR_NVIDIA;
469 gpu_vendor = GPU_VENDOR_INTEL;
471 gpu_vendor = GPU_VENDOR_AMD;
480 for(
unsigned i = 0;
i < 3; ++
i)
482 for(
unsigned i = 0;
i < 3; ++
i)
500 if (!check_gl_error(
"gl_context::configure() debug output"))
520 for (
unsigned i = 0;
i<
grp->get_nr_children(); ++
i)
529void gl_context::resize_gl()
589void gl_context::init_render_pass()
641 if (check_gl_error(
"gl_context::init_render_pass before init_frame"))
650 if (check_gl_error(
"gl_context::init_render_pass after init_frame"))
673void gl_context::finish_render_pass()
698void gl_context::draw_textual_info()
700 if (show_help || show_stats) {
712 if (
bg[0] +
bg[1] +
bg[2] < 1.5f)
720 if (
grp && show_stats) {
726 if(
bg[0] +
bg[1] +
bg[2] < 1.5f)
731 if (
grp && show_help) {
742void gl_context::perform_screen_shot()
748 std::string
ext(
"bmp");
764 for (
int i = 0;
i < count; ++
i) {
780 std::cout <<
i <<
" at " <<
loc <<
" = " <<
name_str <<
":" << type <<
"[" << size <<
"]" << std::endl;
789 for (
int i = 0;
i < count; ++
i) {
805 std::cout <<
i <<
" at " <<
loc <<
" = " <<
name_str <<
":" << type <<
"[" << size <<
"]" << std::endl;
819 if (!prog.does_context_set_color())
821 int clr_loc = prog.get_color_index();
831 unsigned side = map_to_gl(MS_FRONT_AND_BACK);
846 mat.enable_textures(*
this);
852 mat.disable_textures(*
this);
857void gl_context::destruct_render_objects()
859 for (
unsigned i = 0;
i < 4; ++
i)
860 progs[
i].destruct(*
this);
868 if (!progs[0].build_program(*
this,
"default.glpr")) {
869 error(
"could not build default shader program from default.glpr");
872 progs[0].specify_standard_uniforms(
true,
false,
false,
true);
873 progs[0].specify_standard_vertex_attribute_names(*
this,
true,
false,
false);
874 progs[0].allow_context_to_set_color(
true);
879 if (!progs[1].build_program(*
this,
"textured_default.glpr")) {
880 error(
"could not build default shader program with texture support from textured_default.glpr");
884 progs[1].specify_standard_uniforms(
true,
false,
false,
true);
885 progs[1].specify_standard_vertex_attribute_names(*
this,
true,
false,
true);
886 progs[1].allow_context_to_set_color(
true);
896 if (!progs[2].build_program(*
this,
"default_surface.glpr")) {
897 error(
"could not build surface shader program from default_surface.glpr");
900 progs[2].specify_standard_uniforms(
true,
true,
true,
true);
901 progs[2].specify_standard_vertex_attribute_names(*
this,
true,
true,
false);
902 progs[2].allow_context_to_set_color(
true);
907 if (!progs[3].build_program(*
this,
"textured_surface.glpr")) {
908 error(
"could not build surface shader program with texture support from textured_surface.glpr");
911 progs[3].specify_standard_uniforms(
true,
true,
true,
true);
912 progs[3].specify_standard_vertex_attribute_names(*
this,
true,
true,
true);
913 progs[3].allow_context_to_set_color(
true);
937 GLfloat pos[4] = { 0,0,0,
light.get_type() == cgv::media::illum::LT_DIRECTIONAL ? 0.0f : 1.0f };
940 if (
light.get_type() != cgv::media::illum::LT_DIRECTIONAL) {
950 if (
light.get_type() == cgv::media::illum::LT_SPOT) {
958 static float dir[3] = { 0,0,1 };
999 compute_rotation_axis_and_angle_from_vector_pair(vector, target, axis, angle);
1006 if ((start - end).length() < 1e-8) {
1007 error(
"ignored tesselate arrow called with start and end closer then 1e-8");
1021 switch (
l.get_type()) {
1022 case LT_DIRECTIONAL :
1028 cgv::math::translate4<double>(
l.get_position())*
1034 cgv::math::translate4<double>(
l.get_position())*
1039 float t = tan(
l.get_spot_cutoff()*(
float)M_PI/180);
1040 if (
l.get_spot_cutoff() > 45.0f)
1057 error(
"gl_context::announce_external_frame_buffer_change() called with empty frame buffer stack");
1077 error(
"gl_context::announce_external_viewport_change() called with empty window transformation stack");
1108 glOrtho(vp[0], vp[0]+vp[2], vp[1], vp[1]+vp[3], -1, 1);
1136 if (w < 1 || h < 1) {
1142 if (w < 1 || h < 1) {
1145 w = w < 1 ? vp[2] : w;
1146 h = h < 1 ? vp[3] : h;
1202void render_vertex(
int k,
const float* vertices,
const float* normals,
const float* tex_coords,
1203 const int* vertex_indices,
const int* normal_indices,
const int* tex_coord_indices,
bool flip_normals)
1205 if (normals && normal_indices) {
1207 float n[3] = { -normals[3*normal_indices[k]],-normals[3*normal_indices[k]+1],-normals[3*normal_indices[k]+2] };
1213 if (tex_coords && tex_coord_indices)
1218attribute_array_binding*& get_aab_ptr()
1220 static attribute_array_binding* aab_ptr = 0;
1224vertex_buffer*& get_vbo_ptr()
1226 static vertex_buffer* vbo_ptr = 0;
1233 if (!prog_ptr || prog_ptr->get_position_index() == -1)
1239 if (prog_ptr->get_normal_index() != -1 && normals && normal_indices)
1241 if (prog_ptr->get_texcoord_index() != -1 && tex_coords && tex_coord_indices)
1246 aab_ptr->
disable_array(*
this, prog_ptr->get_position_index());
1247 if (prog_ptr->get_normal_index() != -1 && normals && normal_indices)
1249 if (prog_ptr->get_texcoord_index() != -1 && tex_coords && tex_coord_indices)
1260 const float* vertices,
const float* normals,
const float* tex_coords,
1261 const int* vertex_indices,
const int* normal_indices,
const int* tex_coord_indices,
bool flip_normals)
const
1265 if (!prog_ptr || prog_ptr->get_position_index() == -1)
1267 P.resize(nr_vertices);
1268 for (
i = 0;
i < nr_vertices; ++
i)
1269 P[
i] = *
reinterpret_cast<const vec3*
>(vertices + 3 * vertex_indices[
i]);
1271 if (prog_ptr->get_normal_index() != -1 && normals && normal_indices) {
1272 N.resize(nr_vertices);
1273 for (
i = 0;
i < nr_vertices; ++
i) {
1274 N[
i] = *
reinterpret_cast<const vec3*
>(normals + 3 * normal_indices[
i]);
1279 if (prog_ptr->get_texcoord_index() != -1 && tex_coords && tex_coord_indices) {
1280 T.resize(nr_vertices);
1281 for (
i = 0;
i < nr_vertices; ++
i)
1282 T[
i] = *
reinterpret_cast<const vec2*
>(tex_coords + 2 * tex_coord_indices[
i]);
1291 attribute_array_binding::set_global_attribute_array<>(*
this, prog_ptr->get_position_index(),
P);
1293 if (prog_ptr->get_normal_index() != -1) {
1294 if (normals && normal_indices) {
1295 attribute_array_binding::set_global_attribute_array<>(*
this, prog_ptr->get_normal_index(), N);
1301 if (prog_ptr->get_texcoord_index() != -1) {
1302 if (tex_coords && tex_coord_indices) {
1303 attribute_array_binding::set_global_attribute_array<>(*
this, prog_ptr->get_texcoord_index(),
T);
1316 vbo_ptr->
create(*
this,
P.size() *
sizeof(
vec3) + N.size() *
sizeof(
vec3) +
T.size() *
sizeof(
vec2));
1329 aab_ptr->
enable_array(*
this, prog_ptr->get_position_index());
1330 if (prog_ptr->get_normal_index() != -1) {
1331 if (normals && normal_indices) {
1333 aab_ptr->
enable_array(*
this, prog_ptr->get_normal_index());
1336 aab_ptr->
disable_array(*
this, prog_ptr->get_normal_index());
1338 if (prog_ptr->get_texcoord_index() != -1) {
1339 if (tex_coords && tex_coord_indices) {
1342 aab_ptr->
enable_array(*
this, prog_ptr->get_texcoord_index());
1345 aab_ptr->
disable_array(*
this, prog_ptr->get_texcoord_index());
1354 const float* vertices,
const float* normals,
const float* tex_coords,
1355 const int* vertex_indices,
const int* normal_indices,
const int* tex_coord_indices,
1356 int nr_faces,
int face_degree,
bool flip_normals)
const
1360 for (
int i = 0;
i < nr_faces; ++
i) {
1362 for (
int j = 0;
j < face_degree; ++
j, ++k)
1363 render_vertex(k, vertices, normals, tex_coords, vertex_indices, normal_indices, tex_coord_indices,
flip_normals);
1368 unsigned nr_vertices = face_degree * nr_faces;
1369 std::vector<vec3>
P, N;
1370 std::vector<vec2>
T;
1371 if (!
prepare_attributes(
P, N,
T, nr_vertices, vertices, normals, tex_coords, vertex_indices, normal_indices, tex_coord_indices,
flip_normals))
1373 for (
int i = 0;
i < nr_faces; ++
i)
1381 ensure_configured();
1386 if (count > max_nr_indices)
1387 count =
size_t(max_nr_indices);
1393size_t max_nr_indices, max_nr_vertices;
1394void gl_context::ensure_configured()
const
1396 if (max_nr_indices != 0)
1404 const float* vertices,
const float* normals,
const float* tex_coords,
1405 const int* vertex_indices,
const int* normal_indices,
const int* tex_coord_indices,
1408 int s = face_degree - 2;
1410 std::vector<GLuint>
I;
1411 I.push_back(0);
I.push_back(1);
1412 for (
i = 0;
i < nr_faces; ++
i) {
1414 I.push_back(k - 1);
I.push_back(k);
1415 I.push_back(0);
I.push_back(k);
1419 I.push_back(k - 1);
I.push_back(k);
1420 I.push_back(k - 2);
I.push_back(k);
1423 I.push_back(k - 1);
I.push_back(k + 1);
1424 I.push_back(k - 2);
I.push_back(k);
1425 I.push_back(k);
I.push_back(k + 1);
1433 render_vertex(
j, vertices, normals, tex_coords, vertex_indices, normal_indices, tex_coord_indices,
flip_normals);
1437 unsigned nr_vertices = 2 + (face_degree - 2) * nr_faces;
1438 std::vector<vec3>
P, N;
1439 std::vector<vec2>
T;
1440 if (!
prepare_attributes(
P, N,
T, nr_vertices, vertices, normals, tex_coords, vertex_indices, normal_indices, tex_coord_indices,
flip_normals))
1447 const float* vertices,
const float* normals,
const float* tex_coords,
1448 const int* vertex_indices,
const int* normal_indices,
const int* tex_coord_indices,
1449 int nr_faces,
int face_degree,
bool flip_normals)
const
1453 if (face_degree < 5)
1455 for (
int i = 0;
i < nr_faces; ++
i) {
1456 if (face_degree >= 5)
1458 for (
int j = 0;
j < face_degree; ++
j, ++k)
1459 render_vertex(k, vertices, normals, tex_coords, vertex_indices, normal_indices, tex_coord_indices,
flip_normals);
1460 if (face_degree >= 5)
1463 if (face_degree < 5)
1467 unsigned nr_vertices = face_degree * nr_faces;
1468 std::vector<vec3>
P, N;
1469 std::vector<vec2>
T;
1470 if (!
prepare_attributes(
P, N,
T, nr_vertices, vertices, normals, tex_coords, vertex_indices, normal_indices, tex_coord_indices,
flip_normals))
1482 if (face_degree == 3)
1485 for (
int i = 0;
i < nr_faces; ++
i) {
1493 const float* vertices,
const float* normals,
const float* tex_coords,
1494 const int* vertex_indices,
const int* normal_indices,
const int* tex_coord_indices,
1497 int s = face_degree - 2;
1501 render_vertex(0, vertices, normals, tex_coords, vertex_indices, normal_indices, tex_coord_indices,
flip_normals);
1502 render_vertex(1, vertices, normals, tex_coords, vertex_indices, normal_indices, tex_coord_indices,
flip_normals);
1503 for (
int i = 0;
i < nr_faces; ++
i)
1504 for (
int j = 0;
j < s; ++
j, ++k)
1505 render_vertex(k, vertices, normals, tex_coords, vertex_indices, normal_indices, tex_coord_indices,
flip_normals);
1509 unsigned nr_vertices = 2 + (face_degree-2) * nr_faces;
1510 std::vector<vec3>
P, N;
1511 std::vector<vec2>
T;
1512 if (!
prepare_attributes(
P, N,
T, nr_vertices, vertices, normals, tex_coords, vertex_indices, normal_indices, tex_coord_indices,
flip_normals))
1543 switch(culling_mode) {
1607 map_to_gl(
mask.red_flag),
1608 map_to_gl(
mask.green_flag),
1609 map_to_gl(
mask.blue_flag),
1610 map_to_gl(
mask.alpha_flag)
1622 map_to_gl(flags[0]),
1623 map_to_gl(flags[1]),
1624 map_to_gl(flags[2]),
1651 if (projection_matrix_stack.empty())
1653 return projection_matrix_stack.top();
1659 update_window_transformation_array();
1662void gl_context::update_window_transformation_array()
1665 if (
wta.size() == 1) {
1666 const ivec4& viewport =
wta.front().viewport;
1667 const dvec2& depth_range =
wta.front().depth_range;
1685 GLint max_value = 1;
1697 update_window_transformation_array();
1716 update_window_transformation_array();
1726gl_context::dmat4 gl_context::get_device_matrix() const
1729 glGetIntegerv(GL_VIEWPORT, vp);
1731 D(0, 0) = 0.5*vp[2];
1732 D(0, 3) = 0.5*vp[2] + vp[0];
1733 D(1, 1) = -0.5*vp[3]; // flip y-coordinate
1734 D(1, 3) = get_height() - 0.5*vp[3] - vp[1];
1801 if (debug_texture_format_matching)
1802 std::cout <<
"Texture Format Search for '" <<
cf <<
"':" << std::endl;
1804 if (debug_texture_format_matching)
1805 std::cout <<
"found: '" <<
best_cf <<
"' = " << std::hex <<
gl_format << std::endl;
1809std::string gl_error_to_string(
GLenum eid) {
1820 return "undefined error (id: " + std::to_string(
eid) +
")";
1825std::string gl_error() {
1827 return gl_error_to_string(
eid);
1867 error(
where+
": compute shader need not supported OpenGL version 4.3",
rc);
1870 case ST_TESS_CONTROL:
1871 case ST_TESS_EVALUATION:
1875 error(
where+
": tessellation shader need not supported OpenGL version 4.0",
rc);
1882 error(
where +
": geometry shader need not supported OpenGL version 3.2",
rc);
1889 error(
where +
": shaders need not supported OpenGL version 2.0",
rc);
1898 error(
where +
": framebuffer objects not supported",
rc);
1904GLuint gl_context::texture_generate(texture_base&
tb)
const
1906 if (!check_texture_support(
tb.tt,
"gl_context::texture_generate", &
tb))
1907 return get_gl_id(0);
1908 GLuint tex_id = get_gl_id(0);
1911 error(
"gl_context::texture_generate: attempt to create texture inside glBegin-glEnd-block", &
tb);
1932 if (
tb.tt == TT_UNDEF)
1934 GLuint tex_id = texture_generate(
tb);
1935 if (tex_id == get_gl_id(0))
1940 unsigned int transfer_format = map_to_gl(df.get_standard_component_format(), df.get_integer_interpretation());
1942 error(
"could not determine transfer format", &
tb);
1957 case TT_MULTISAMPLE_2D:
1963 case TT_MULTISAMPLE_2D_ARRAY:
1986 if (check_gl_error(
"gl_context::texture_create", &
tb)) {
1993 tb.have_mipmaps =
false;
1994 tb.handle = get_handle(tex_id);
1998bool gl_context::texture_create(
2008 tb.tt = (
TextureType)data.get_format()->get_nr_dimensions();
2015 unsigned n_dims = data.get_format()->get_nr_dimensions();
2017 tb.tt = TT_1D_ARRAY;
2019 tb.tt = TT_2D_ARRAY;
2022 case TT_1D:
tb.tt = TT_1D_ARRAY;
break;
2023 case TT_2D:
tb.tt = TT_2D_ARRAY;
break;
2024 case TT_3D:
tb.tt = TT_2D_ARRAY;
break;
2032 if (
tb.is_created())
2033 tex_id = get_gl_id(
tb.handle);
2035 tex_id = texture_generate(
tb);
2036 if (tex_id == get_gl_id(0))
2038 tb.handle = get_handle(tex_id);
2046 bool result = !check_gl_error(
"gl_context::texture_create", &
tb);
2052bool gl_context::texture_create_from_buffer(
2055 int x,
int y,
int level)
const
2060 if (
tb.tt != TT_2D) {
2061 tb.last_error =
"texture creation from buffer only possible for 2d textures";
2065 if (
tb.is_created())
2066 tex_id = get_gl_id(
tb.handle);
2068 tex_id = texture_generate(
tb);
2069 if (tex_id == get_gl_id(0))
2071 tb.handle = get_handle(tex_id);
2081 bool result =
false;
2082 std::string
error_string(
"gl_context::texture_create_from_buffer: ");
2091 error_string +=
"level was less than zero or greater than log sub 2(max), where max is the returned value of GL_MAX_TEXTURE_SIZE.\n"
2092 "or border was not zero or 1.\n"
2093 "or width was less than zero, greater than 2 + GL_MAX_TEXTURE_SIZE; or width cannot be represented as 2n + 2 * border for some integer n.";
2096 error_string +=
"glCopyTexImage2D was called between a call to glBegin and the corresponding call to glEnd.";
2107 result = texture_generate_mipmaps(
tb,
tb.tt == TT_CUBEMAP ? 2 : (
int)
tb.tt);
2112bool gl_context::texture_replace(
2114 int x,
int y,
int z,
2116 int level,
const std::vector<cgv::data::data_view>*
palettes)
const
2118 if (!
tb.is_created()) {
2119 error(
"gl_context::texture_replace: attempt to replace in not created texture", &
tb);
2123 unsigned int dim = 1;
2130 if (
tb.tt == TT_CUBEMAP) {
2132 error(
"gl_context::texture_replace: replace on cubemap without the side defined", &
tb);
2136 error(
"gl_context::texture_replace: replace on cubemap with invalid side specification", &
tb);
2142 error(
"gl_context::texture_replace: replace on texture with invalid position specification", &
tb);
2150 bool result = !check_gl_error(
"gl_context::texture_replace", &
tb);
2155bool gl_context::texture_replace_from_buffer(
2157 int x,
int y,
int z,
2159 unsigned int width,
unsigned int height,
2162 if (!
tb.is_created()) {
2163 error(
"gl_context::texture_replace_from_buffer: attempt to replace in not created texture", &
tb);
2167 unsigned int dim = 2;
2172 if (
tb.tt == TT_CUBEMAP) {
2174 error(
"gl_context::texture_replace_from_buffer: replace on cubemap without the side defined", &
tb);
2178 error(
"gl_context::texture_replace_from_buffer: replace on cubemap without invalid side specification", &
tb);
2184 tb.last_error =
"replace on texture with invalid position specification";
2201 bool result = !check_gl_error(
"gl_context::texture_replace_from_buffer", &
tb);
2205 result = texture_generate_mipmaps(
tb,
tb.tt == TT_CUBEMAP ? 2 : (
int)
tb.tt);
2212 if(!
tb.is_created()) {
2213 error(
"gl_context::texture_copy_back: attempt to copy from not created texture", &
tb);
2220 bool result = !check_gl_error(
"gl_context::texture_copy_back", &
tb);
2231 unsigned int transfer_format = map_to_gl(df.get_standard_component_format(), df.get_integer_interpretation());
2234 error(
"could not determine transfer format", &
tb);
2239 uvec3 size(
unsigned(df.get_width()),
unsigned(df.get_height()),
unsigned(df.get_depth()));
2241 unsigned max_size = cgv::math::max_value(size);
2248 for(
unsigned level = 1; level <
num_levels; ++level) {
2261 for(
unsigned level = 1; level <
num_levels; ++level) {
2268 error(
"create mipmaps not implemented for 1D array textures", &
tb);
2272 for(
unsigned level = 1; level <
num_levels; ++level) {
2277 case TT_MULTISAMPLE_2D:
2279 error(
"create mipmaps not implemented for 2D multisample textures", &
tb);
2284 error(
"create mipmaps not implemented for 2D array textures", &
tb);
2287 case TT_MULTISAMPLE_2D_ARRAY:
2289 error(
"create mipmaps not implemented for 2D multisample array textures", &
tb);
2293 for(
unsigned level = 1; level <
num_levels; ++level) {
2312 error(
"create mipmaps not implemented for cubemap textures", &
tb);
2318 if(check_gl_error(
"gl_context::texture_create_mipmaps", &
tb))
2322 tb.have_mipmaps =
true;
2328bool gl_context::texture_generate_mipmaps(texture_base&
tb,
unsigned int dim)
const
2332 bool is_array =
tb.tt == TT_1D_ARRAY ||
tb.tt == TT_2D_ARRAY;
2337 tb.have_mipmaps =
true;
2345bool gl_context::texture_destruct(texture_base&
tb)
const
2347 if (!
tb.is_created()) {
2348 error(
"gl_context::texture_destruct: attempt to destruct not created texture", &
tb);
2351 GLuint tex_id = get_gl_id(
tb.handle);
2353 bool result = !check_gl_error(
"gl_context::texture_destruct", &
tb);
2359bool gl_context::texture_set_state(
const texture_base&
tb)
const
2361 if (
tb.tt == TT_UNDEF) {
2362 error(
"gl_context::texture_set_state: attempt to set state on texture without type", &
tb);
2367 error(
"gl_context::texture_set_state: attempt of setting texture state of not created texture", &
tb);
2372 if (
tb.tt != TT_MULTISAMPLE_2D &&
tb.tt != TT_MULTISAMPLE_2D_ARRAY) {
2375 if (
tb.min_filter == TF_ANISOTROP)
2392 bool result = !check_gl_error(
"gl_context::texture_set_state", &
tb);
2397bool gl_context::texture_enable(texture_base&
tb,
int tex_unit,
unsigned int dim)
const
2400 error(
"gl_context::texture_enable: invalid texture dimension", &
tb);
2405 error(
"gl_context::texture_enable: texture not created", &
tb);
2408 if (tex_unit >= 0) {
2410 error(
"gl_context::texture_enable: multi texturing not supported", &
tb);
2422 bool result = !check_gl_error(
"gl_context::texture_enable", &
tb);
2428bool gl_context::texture_disable(
2430 int tex_unit,
unsigned int dim)
const
2433 error(
"gl_context::texture_disable: invalid texture dimension", &
tb);
2436 if (tex_unit == -2) {
2437 error(
"gl_context::texture_disable: invalid texture unit", &
tb);
2447 bool result = !check_gl_error(
"gl_context::texture_disable", &
tb);
2458 error(
"gl_context::texture_enable: texture not created", &
tb);
2463 error(
"gl_context::texture_bind_as_image: image textures not supported", &
tb);
2470 bool result = !check_gl_error(
"gl_context::texture_bind_as_image", &
tb);
2477 error(
"gl_context::render_buffer_create: frame buffer objects not supported", &
rb);
2501 if (
rb.nr_multi_samples == 0)
2506 if (check_gl_error(
"gl_context::render_buffer_create", &
rb))
2508 rb.handle = get_handle(
rb_id);
2512bool gl_context::render_buffer_destruct(render_buffer_base&
rc)
const
2515 error(
"gl_context::render_buffer_destruct: frame buffer objects not supported", &
rc);
2520 if (check_gl_error(
"gl_context::render_buffer_destruct", &
rc))
2527bool gl_context::frame_buffer_create(frame_buffer_base&
fbb)
const
2529 if (!check_fbo_support(
"gl_context::frame_buffer_create", &
fbb))
2532 if (!context::frame_buffer_create(
fbb))
2539 error(
"gl_context::frame_buffer_create: could not allocate framebuffer object", &
fbb);
2542 fbb.handle = get_handle(fbo_id);
2546bool gl_context::frame_buffer_enable(frame_buffer_base&
fbb)
2548 if (!context::frame_buffer_enable(
fbb))
2550 std::vector<int> buffers;
2555 if (buffers.size() == 1)
2557 else if (buffers.size() > 1) {
2564 error(
"gl_context::frame_buffer_enable: no attached draw buffer selected!!", &
fbb);
2573 if (!context::frame_buffer_disable(
fbb))
2576 error(
"gl_context::frame_buffer_disable called with empty frame buffer stack!!", &
fbb);
2586 if (!context::frame_buffer_destruct(
fbb))
2595void complete_rect_from_vp(
ivec4& D,
GLint vp[4])
2602 D(2) = vp[0] + vp[2];
2604 D(3) = vp[1] + vp[3];
2607void gl_context::frame_buffer_blit(
2623 if ((
src_fbb_ptr == 0 && (S(0) == -1 || S(1) == -1 || S(2) == -1 || S(3) == -1)) ||
2624 (
dst_fbb_ptr == 0 && (D(0) == -1 || D(1) == -1 || D(2) == -1 || D(3) == -1))) {
2628 complete_rect_from_vp(S, vp);
2630 complete_rect_from_vp(D, vp);
2648bool gl_context::frame_buffer_attach(frame_buffer_base&
fbb,
const render_buffer_base&
rb,
bool is_depth,
int i)
const
2658 get_gl_id(
rb.handle));
2680 if (t.tt == TT_CUBEMAP) {
2691 bool result = !check_gl_error(
"gl_context::frame_buffer_attach", &
fbb);
2699 if (
fbb.handle == 0) {
2700 error(
"gl_context::frame_buffer_is_complete: attempt to check completeness on frame buffer that is not created", &
fbb);
2712 fbb.last_error =
"undefined framebuffer";
2715 fbb.last_error =
"incomplete attachment";
2718 fbb.last_error =
"incomplete or missing attachment";
2721 fbb.last_error =
"incomplete multisample";
2724 fbb.last_error =
"incomplete layer targets";
2727 fbb.last_error =
"incomplete draw buffer";
2730 fbb.last_error =
"incomplete read buffer";
2733 fbb.last_error =
"framebuffer objects unsupported";
2736 fbb.last_error =
"unknown error";
2740int gl_context::frame_buffer_get_max_nr_color_attachments()
const
2742 if (!check_fbo_support(
"gl_context::frame_buffer_get_max_nr_color_attachments"))
2750int gl_context::frame_buffer_get_max_nr_draw_buffers()
const
2752 if (!check_fbo_support(
"gl_context::frame_buffer_get_max_nr_draw_buffers"))
2765void gl_context::shader_code_destruct(render_component&
sc)
const
2767 if (
sc.handle == 0) {
2768 error(
"gl_context::shader_code_destruct: shader not created", &
sc);
2774 check_gl_error(
"gl_context::shader_code_destruct", &
sc);
2777bool gl_context::shader_code_create(render_component&
sc,
ShaderType st,
const std::string& source)
const
2779 if (!check_shader_support(st,
"gl_context::shader_code_create", &
sc))
2784 error(std::string(
"gl_context::shader_code_create: ")+gl_error(), &
sc);
2787 sc.handle = get_handle(
s_id);
2789 const char* s = source.c_str();
2791 if (check_gl_error(
"gl_context::shader_code_create", &
sc))
2797bool gl_context::shader_code_compile(render_component&
sc)
const
2799 if (
sc.handle == 0) {
2800 error(
"gl_context::shader_code_compile: shader not created", &
sc);
2809 sc.last_error = std::string();
2821bool gl_context::shader_program_create(shader_program_base&
spb)
const
2823 if (!check_shader_support(ST_VERTEX,
"gl_context::shader_program_create", &
spb))
2829void gl_context::shader_program_attach(shader_program_base&
spb,
const render_component&
sc)
const
2831 if (
spb.handle == 0) {
2832 error(
"gl_context::shader_program_attach: shader program not created", &
spb);
2838void gl_context::shader_program_detach(shader_program_base&
spb,
const render_component&
sc)
const
2840 if (
spb.handle == 0) {
2841 error(
"gl_context::shader_program_detach: shader program not created", &
spb);
2847bool gl_context::shader_program_link(shader_program_base&
spb)
const
2849 if (
spb.handle == 0) {
2850 error(
"gl_context::shader_program_link: shader program not created", &
spb);
2858 return context::shader_program_link(
spb);
2866 error(
"gl_context::shader_program_link\n" +
spb.last_error, &
spb);
2872bool gl_context::shader_program_set_state(shader_program_base&
spb)
const
2874 if (
spb.handle == 0) {
2875 error(
"gl_context::shader_program_set_state: shader program not created", &
spb);
2885bool gl_context::shader_program_enable(shader_program_base&
spb)
2887 if (!context::shader_program_enable(
spb))
2890 shader_program& prog =
static_cast<shader_program&
>(
spb);
2899 if (prog.does_context_set_color() && prog.get_color_index() >= 0)
2900 prog.set_attribute(*
this, prog.get_color_index(),
current_color);
2904bool gl_context::shader_program_disable(shader_program_base&
spb)
2906 if (!context::shader_program_disable(
spb))
2915bool gl_context::shader_program_destruct(shader_program_base&
spb)
const
2917 if (!context::shader_program_destruct(
spb))
2925bool gl_context::shader_program_get_active_uniforms(shader_program_base&
spb, std::vector<std::string>&
names)
const
2927 if (
spb.handle == 0)
2937 std::vector<GLchar> buffer(256);
2939 GLint array_size = 0;
2944 std::string name(
static_cast<char*
>(buffer.data()),
actual_length);
2947 if(array_size > 1) {
2955 names.push_back(name);
2957 for(
GLint i = 0;
i < array_size; ++
i)
2958 names.push_back(name +
"[" + std::to_string(
i) +
"]");
2962 names.push_back(name);
2970 program_variable_info
V;
2971 V.name = std::string(
static_cast<const char*
>(buffer.data()),
actual_length);
2973 if (array_size > 1) {
2978 if (!
V.name.empty())
2979 V.array_size = array_size;
3027void gl_context::shader_program_inspect_variables(shader_program_base&
spb,
ProgramVariableKind kind, std::vector<program_variable_info>&
Vs,
bool get_location,
bool get_value)
const
3032 std::vector<GLchar> buffer(256);
3033 GLint array_size = 0;
3041 if (kind == cgv::render::PVK_ATTRIBUTE) {
3053 size_t cnt = 1, s, S;
3055 V.compute_sizes(cnt, s, S);
3056 V.current_value.resize(S);
3061 if (kind == cgv::render::PVK_ATTRIBUTE && cnt != 4)
3063 for (
unsigned j = 0;
j <
V.array_size; ++
j) {
3066 if (
V.array_size > 1)
3073 if (kind == cgv::render::PVK_ATTRIBUTE &&
V.program_location == 0) {
3074 V.current_value.clear();
3080 void* value_ptr =
V.current_value.data() +
j * s;
3083 switch (
V.type_descr.coordinate_type) {
3086 if (kind == cgv::render::PVK_UNIFORM)
3092 if (kind == cgv::render::PVK_UNIFORM)
3098 if (kind == cgv::render::PVK_UNIFORM)
3104 if (kind == cgv::render::PVK_UNIFORM)
3112 std::copy((
const char*)
read_ptr, (
const char*)
read_ptr + s, (
char*)value_ptr);
3123int gl_context::get_uniform_location(
const shader_program_base&
spb,
const std::string& name)
const
3128std::string value_type_index_to_string(type_descriptor
td)
3131 switch (
td.element_type) {
3137 if (
td.is_row_major)
3147bool gl_context::set_uniform_void(shader_program_base&
spb,
int loc, type_descriptor value_type,
const void* value_ptr)
const
3149 if (value_type.is_array) {
3150 error(std::string(
"gl_context::set_uniform_void(") + value_type_index_to_string(value_type) +
") array type not supported, please use set_uniform_array instead.", &
spb);
3154 error(
"gl_context::set_uniform_void() called on not created program", &
spb);
3161 switch (value_type.element_type) {
3163 switch (value_type.coordinate_type) {
3174 error(std::string(
"gl_context::set_uniform_void(") + value_type_index_to_string(value_type) +
") unsupported coordinate type.", &
spb);
3179 switch (value_type.nr_rows) {
3181 switch (value_type.coordinate_type) {
3192 error(std::string(
"gl_context::set_uniform_void(") + value_type_index_to_string(value_type) +
") unsupported coordinate type.", &
spb);
3197 switch (value_type.coordinate_type) {
3208 error(std::string(
"gl_context::set_uniform_void(") + value_type_index_to_string(value_type) +
") unsupported coordinate type.", &
spb);
3213 switch (value_type.coordinate_type) {
3224 error(std::string(
"gl_context::set_uniform_void(") + value_type_index_to_string(value_type) +
") unsupported coordinate type.", &
spb);
3231 switch (value_type.coordinate_type) {
3233 switch (value_type.nr_rows) {
3235 switch (value_type.nr_columns) {
3240 error(std::string(
"gl_context::set_uniform_void(") + value_type_index_to_string(value_type) +
") matrix number of columns outside [2,..,4].", &
spb);
3245 switch (value_type.nr_columns) {
3250 error(std::string(
"gl_context::set_uniform_void(") + value_type_index_to_string(value_type) +
") matrix number of columns outside [2,..,4].", &
spb);
3255 switch (value_type.nr_columns) {
3260 error(std::string(
"gl_context::set_uniform_void(") + value_type_index_to_string(value_type) +
") matrix number of columns outside [2,..,4].", &
spb);
3265 error(std::string(
"gl_context::set_uniform_void(") + value_type_index_to_string(value_type) +
") matrix number of rows outside [2,..,4].", &
spb);
3270 switch (value_type.nr_rows) {
3272 switch (value_type.nr_columns) {
3277 error(std::string(
"gl_context::set_uniform_void(") + value_type_index_to_string(value_type) +
") matrix number of columns outside [2,..,4].", &
spb);
3282 switch (value_type.nr_columns) {
3287 error(std::string(
"gl_context::set_uniform_void(") + value_type_index_to_string(value_type) +
") matrix number of columns outside [2,..,4].", &
spb);
3292 switch (value_type.nr_columns) {
3297 error(std::string(
"gl_context::set_uniform_void(") + value_type_index_to_string(value_type) +
") matrix number of columns outside [2,..,4].", &
spb);
3302 error(std::string(
"gl_context::set_uniform_void(") + value_type_index_to_string(value_type) +
") matrix number of rows outside [2,..,4].", &
spb);
3307 error(std::string(
"gl_context::set_uniform_void(") + value_type_index_to_string(value_type) +
") non float coordinate type not supported.", &
spb);
3315 if (check_gl_error(
"gl_context::set_uniform_void()", &
spb))
3320bool gl_context::set_uniform_array_void(shader_program_base&
spb,
int loc, type_descriptor value_type,
const void* value_ptr,
size_t nr_elements)
const
3322 if (!value_type.is_array) {
3323 error(std::string(
"gl_context::set_uniform_array_void(") + value_type_index_to_string(value_type) +
") non array type not allowed.", &
spb);
3327 error(
"gl_context::set_uniform_array_void() called on not created program", &
spb);
3334 switch (value_type.coordinate_type) {
3336 switch (value_type.element_type) {
3341 switch (value_type.nr_rows) {
3346 error(std::string(
"gl_context::set_uniform_array_void(") + value_type_index_to_string(value_type) +
") vector dimension outside [2,..4].", &
spb);
3352 error(std::string(
"gl_context::set_uniform_array_void(") + value_type_index_to_string(value_type) +
") type not supported.", &
spb);
3358 switch (value_type.element_type) {
3363 switch (value_type.nr_rows) {
3368 error(std::string(
"gl_context::set_uniform_array_void(") + value_type_index_to_string(value_type) +
") vector dimension outside [2,..4].", &
spb);
3374 error(std::string(
"gl_context::set_uniform_array_void(") + value_type_index_to_string(value_type) +
") type not supported.", &
spb);
3380 switch (value_type.element_type) {
3385 switch (value_type.nr_rows) {
3390 error(std::string(
"gl_context::set_uniform_array_void(") + value_type_index_to_string(value_type) +
") vector dimension outside [2,..4].", &
spb);
3396 switch (value_type.nr_rows) {
3398 switch (value_type.nr_columns) {
3403 error(std::string(
"gl_context::set_uniform_array_void(") + value_type_index_to_string(value_type) +
") matrix number of columns outside [2,..4].", &
spb);
3409 switch (value_type.nr_columns) {
3414 error(std::string(
"gl_context::set_uniform_array_void(") + value_type_index_to_string(value_type) +
") matrix number of columns outside [2,..4].", &
spb);
3420 switch (value_type.nr_columns) {
3425 error(std::string(
"gl_context::set_uniform_array_void(") + value_type_index_to_string(value_type) +
") matrix number of columns outside [2,..4].", &
spb);
3431 error(std::string(
"gl_context::set_uniform_array_void(") + value_type_index_to_string(value_type) +
") matrix number of rows outside [2,..4].", &
spb);
3439 error(std::string(
"gl_context::set_uniform_array_void(") + value_type_index_to_string(value_type) +
") unsupported coordinate type (only int32, uint32, and flt32 supported).", &
spb);
3443 if (check_gl_error(
"gl_context::set_uniform_array_void()", &
spb))
3452int gl_context::get_uniform_block_index(
const shader_program_base&
spb,
const std::string& name)
const
3457bool gl_context::set_uniform_block_binding(shader_program_base&
spb,
int index,
int binding)
const
3460 error(
"gl_context::set_uniform_block_binding() called on not created program", &
spb);
3464 return check_gl_error(
"gl_context::set_uniform_block_binding()", &
spb);
3467int gl_context::get_attribute_location(
const shader_program_base&
spb,
const std::string& name)
const
3472bool gl_context::set_attribute_void(shader_program_base&
spb,
int loc, type_descriptor value_type,
const void* value_ptr)
const
3475 error(
"gl_context::set_attribute_void() called on not created program", &
spb);
3482 switch (value_type.element_type) {
3484 switch (value_type.coordinate_type) {
3495 error(std::string(
"gl_context::set_attribute_void(") + value_type_index_to_string(value_type) +
") type not supported!", &
spb);
3501 switch (value_type.nr_rows) {
3503 switch (value_type.coordinate_type) {
3514 error(std::string(
"gl_context::set_attribute_void(") + value_type_index_to_string(value_type) +
") unsupported coordinate type.", &
spb);
3520 switch (value_type.coordinate_type) {
3531 error(std::string(
"gl_context::set_attribute_void(") + value_type_index_to_string(value_type) +
") unsupported coordinate type.", &
spb);
3536 switch (value_type.coordinate_type) {
3547 error(std::string(
"gl_context::set_attribute_void(") + value_type_index_to_string(value_type) +
") unsupported coordinate type.", &
spb);
3553 error(std::string(
"gl_context::set_attribute_void(") + value_type_index_to_string(value_type) +
") vector dimension outside [2..4]", &
spb);
3559 error(std::string(
"gl_context::set_attribute_void(") + value_type_index_to_string(value_type) +
") matrix type not supported!", &
spb);
3566 if (check_gl_error(
"gl_context::set_uniform_array_void()", &
spb))
3571bool gl_context::attribute_array_binding_create(attribute_array_binding_base& aab)
const
3574 error(
"gl_context::attribute_array_binding_create() array attribute bindings not supported", &aab);
3580 error(std::string(
"gl_context::attribute_array_binding_create(): ") + gl_error(), &aab);
3584 aab.handle = get_handle(
a_id);
3588bool gl_context::attribute_array_binding_destruct(attribute_array_binding_base& aab)
3592 if (!context::attribute_array_binding_destruct(aab))
3595 error(
"gl_context::attribute_array_binding_destruct(): called on not created attribute array binding", &aab);
3602 return !check_gl_error(
"gl_context::attribute_array_binding_destruct");
3605bool gl_context::attribute_array_binding_enable(attribute_array_binding_base& aab)
3607 if (!context::attribute_array_binding_enable(aab))
3610 return !check_gl_error(
"gl_context::attribute_array_binding_enable");
3613bool gl_context::attribute_array_binding_disable(attribute_array_binding_base& aab)
3615 if (!context::attribute_array_binding_disable(aab))
3624bool gl_context::set_element_array(attribute_array_binding_base* aab,
const vertex_buffer_base*
vbb)
const
3627 error(
"gl_context::set_element_array(): called without a vertex buffer object", aab);
3631 error(
"gl_context::set_element_array(): called with not created vertex buffer object",
vbb);
3635 std::cout <<
"gl_context::set_element_array() : called on vertex buffer object that is not of type VBT_INDICES" << std::endl;
3641 error(
"gl_context::set_element_array(): called on not created attribute array binding", aab);
3656 return !check_gl_error(
"gl_context::set_element_array_void()", aab);
3660bool gl_context::set_attribute_array_void(attribute_array_binding_base* aab,
int loc, type_descriptor value_type,
const vertex_buffer_base*
vbb,
const void* ptr,
size_t nr_elements,
unsigned stride)
const
3662 if (value_type == ET_MATRIX) {
3663 error(
"gl_context::set_attribute_array_void(): called with matrix elements not supported", aab);
3668 error(
"gl_context::set_attribute_array_void(): called with not created vertex buffer object",
vbb);
3674 error(
"gl_context::set_attribute_array_void(): called on not created attribute array binding", aab);
3687 unsigned n = value_type.element_type == ET_VALUE ? 1 : value_type.nr_rows;
3688 switch (value_type.coordinate_type) {
3700 error(
"gl_context::set_attribute_array_void(): called with coordinates of type double only supported starting with OpenGL 4.1", aab);
3705 error(
"gl_context::set_attribute_array_void(): called with unsupported coordinate type", aab);
3719 return res && !check_gl_error(
"gl_context::set_attribute_array_void()", aab);
3722bool gl_context::enable_attribute_array(attribute_array_binding_base* aab,
int loc,
bool do_enable)
const
3727 error(
"gl_context::enable_attribute_array(): called on not created attribute array binding", aab);
3742 return !check_gl_error(
"gl_context::enable_attribute_array()");
3745bool gl_context::is_attribute_array_enabled(
const attribute_array_binding_base* aab,
int loc)
const
3750 error(
"gl_context::is_attribute_array_enabled(): called on not created attribute array binding", aab);
3799 if (
_idx ==
unsigned(-1))
3803 return !check_gl_error(
"gl_context::vertex_buffer_bind", &
vbb);
3807 if(
_idx ==
unsigned(-1))
3811 return !check_gl_error(
"gl_context::vertex_buffer_unbind", &
vbb);
3814bool gl_context::vertex_buffer_create(vertex_buffer_base&
vbb,
const void*
array_ptr,
size_t size_in_bytes)
const
3817 error(
"gl_context::vertex_buffer_create() vertex buffer objects not supported", &
vbb);
3823 error(std::string(
"gl_context::vertex_buffer_create(): ") + gl_error(), &
vbb);
3826 vbb.handle = get_handle(
b_id);
3830 return !check_gl_error(
"gl_context::vertex_buffer_create", &
vbb);
3833bool gl_context::vertex_buffer_resize(vertex_buffer_base&
vbb,
const void*
array_ptr,
size_t size_in_bytes)
const {
3835 error(
"gl_context::vertex_buffer_resize() vertex buffer object must be created before", &
vbb);
3842 return !check_gl_error(
"gl_context::vertex_buffer_resize", &
vbb);
3845bool gl_context::vertex_buffer_clear(vertex_buffer_base&
vbb,
size_t offset,
size_t size_in_bytes)
const
3848 error(
"gl_context::vertex_buffer_clear() vertex buffer object must be created before", &
vbb);
3855 return !check_gl_error(
"gl_context::vertex_buffer_clear", &
vbb);
3858bool gl_context::vertex_buffer_replace(vertex_buffer_base&
vbb,
size_t offset,
size_t size_in_bytes,
const void*
array_ptr)
const
3861 error(
"gl_context::vertex_buffer_replace() vertex buffer object must be created before", &
vbb);
3868 return !check_gl_error(
"gl_context::vertex_buffer_replace", &
vbb);
3871bool gl_context::vertex_buffer_copy(
const vertex_buffer_base&
src,
size_t src_offset, vertex_buffer_base& target,
size_t target_offset,
size_t size_in_bytes)
const
3873 if (!
src.handle || !target.handle) {
3874 error(
"gl_context::vertex_buffer_copy() source and destination vertex buffer objects must have been created before", &
src);
3883 return !check_gl_error(
"gl_context::vertex_buffer_copy", &
src);
3887bool gl_context::vertex_buffer_copy_back(
const vertex_buffer_base&
vbb,
size_t offset,
size_t size_in_bytes,
void*
array_ptr)
const
3890 error(
"gl_context::vertex_buffer_copy_back() vertex buffer object must be created", &
vbb);
3908 return !check_gl_error(
"gl_context::vertex_buffer_copy_back", &
vbb);
3911bool gl_context::vertex_buffer_destruct(vertex_buffer_base&
vbb)
const
3918 return !check_gl_error(
"gl_context::vertex_buffer_destruct");
3921 error(
"gl_context::vertex_buffer_destruct(): called on not created vertex buffer", &
vbb);
virtual void stream_stats(std::ostream &)
overload to show the content of this object
The group class is a node with children.
complete implementation of method actions that only call one method when entering a node
interface of a handler for traverse callbacks
class used to traverse a tree structure
bool traverse(base_ptr start, traverse_callback_handler *tch=0)
traverse a tree starting at given node according to set strategy, order and dest and previously comin...
The const_data_view has the functionality of the data_view but uses a const pointer and therefore doe...
void manage_format(bool enable=true)
whether to manage the data format pointer
const data_format * get_format() const
return the component format
cgv::type::func::transfer_const< P, S * >::type get_ptr() const
return a data pointer to type S
the data view gives access to a data array of one, two, three or four dimensions.
~data_view()
destruct view and delete data pointer if it is owned by the view
void reflect_horizontally()
reflect 2D data view at horizontal axis
unsigned int get_component_alignment() const
return the component alignment in bits in the packed case and in bytes in the unpacked case
bool empty() const
check if pointer is not yet set
virtual void stream_help(std::ostream &os)=0
overload to stream help information to the given output stream
matrix of fixed size dimensions
A matrix type (full column major storage) The matrix can be loaded directly into OpenGL without need ...
the attribute_array_binding allows to define vertex attributes (i.e.
bool enable(context &ctx)
enable whole the attribute array binding object
static bool enable_global_array(const context &ctx, int loc)
enable attribute array of given location
bool create(const context &ctx)
create the attribute array binding object
bool disable(context &ctx)
disable whole attribute array binding object
static bool disable_global_array(const context &ctx, int loc)
disable attribute array of given location
bool enable_array(const context &ctx, int loc)
enable array for vertex attribute at location loc
bool disable_array(const context &ctx, int loc)
disable array for attribute at location loc
bool set_attribute_array(const context &ctx, int loc, const T &array)
set vertex attribute location to given array and enable array
virtual void set_blend_func(BlendFunction src_factor, BlendFunction dst_factor)
set the blend function
virtual std::ostream & output_stream()
returns an output stream whose output is printed at the current cursor location, which is managed by ...
virtual void mul_modelview_matrix(const dmat4 &MV)
multiply given matrix from right to current modelview matrix
virtual 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
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
shader_program_base * get_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
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
float current_font_size
store current font size
bool enable_vsync
whether vsync should be enabled
virtual void set_buffer_mask(BufferMask mask)
set the buffer mask for depth and color buffers
virtual bool is_current() const =0
return whether the context is current
bool auto_set_lights_in_current_shader_program
whether to automatically set lights in current shader program, defaults to true
virtual void set_blend_func_separate(BlendFunction src_color_factor, BlendFunction dst_color_factor, BlendFunction src_alpha_factor, BlendFunction dst_alpha_factor)
set the blend function separately for color and alpha
virtual void on_lights_changed()
helper function to send light update events
void push_depth_test_state()
push a copy of the current depth test state onto the stack saved attributes: depth test enablement,...
std::stack< shader_program_base * > shader_program_stack
stack of currently enabled shader programs
bool is_light_source_enabled(void *handle)
check whether light source is enabled
virtual void disable_depth_test()
disable the depth test
int get_bg_stencil() const
return the current stencil value for clearing the background
virtual unsigned int get_width() const =0
return the width of the window
bool disable_light_source(void *handle)
disable a given light source and return whether there existed a light source with given handle
void pop_depth_test_state()
pop the top of the current depth test state from the stack
void tesselate_unit_sphere(int resolution=25, bool flip_normals=false, bool edges=false)
tesselate a sphere of radius 1
virtual RenderPassFlags get_render_pass_flags() const
return the current render pass flags
void tesselate_unit_cylinder(int resolution=25, bool flip_normals=false, bool edges=false)
tesselate a cylinder of radius 1
virtual void set_bg_color(vec4 rgba)
set a user defined background color
virtual void set_depth_test_state(DepthTestState state)
set the depth test state
size_t get_nr_enabled_light_sources() const
return the number of light sources
virtual unsigned int get_height() const =0
return the height of the window
virtual void disable_blending()
disable blending
BufferMask get_buffer_mask() const
return the current buffer mask
void push_cull_state()
push a copy of the current culling state onto the stack saved attributes: cull face enablement,...
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
std::stack< dmat4 > modelview_matrix_stack
keep two matrix stacks for model view and projection matrices
virtual void pop_window_transformation_array()
restore previous viewport and depth range arrays defining the window transformations
virtual void set_color_mask(bvec4 flags)
set the color buffer mask
virtual void set_material(const cgv::media::illum::surface_material &mat)
set the current material
DepthTestState get_depth_test_state() const
return the current depth test state
bool auto_set_material_in_current_shader_program
whether to automatically set material in current shader program, defaults to true
void set_current_lights(shader_program &prog) const
set the shader program lights to the currently enabled lights
bool enable_light_source(void *handle)
enable a given light source and return whether there existed a light source with given handle
void tesselate_unit_disk(int resolution=25, bool flip_normals=false, bool edges=false)
tesselate a circular disk of radius 1
virtual void enable_depth_test()
enable the depth test
bool support_compatibility_mode
whether to support view and lighting management of compatibility mode, defaults to true
void set_current_gamma(shader_program &prog) const
set the shader program gamma values
vec4 get_bg_color() const
return the current color value for clearing the background
void pop_projection_matrix()
see push_P for an explanation
std::stack< attribute_array_binding_base * > attribute_array_binding_stack
stack of currently enabled attribute array binding
BlendState get_blend_state() const
return the current blend state
virtual void set_cull_state(CullingMode culling_mode)
set the culling state
virtual void set_depth_func(CompareFunction func)
set the depth test function
void set_light_source(void *handle, const cgv::media::illum::light_source &light, bool place_now=true)
set light source newly
void push_projection_matrix()
same as push_V but for the projection matrix - a different matrix stack is used.
bool current_material_is_textured
store flag to tell whether current material is textured
virtual void set_projection_matrix(const dmat4 &P)
set the current projection matrix, which transforms from eye to clip space
rgba current_color
current color value
static const unsigned nr_default_light_sources
number of default light sources
cgv::media::illum::light_source default_light_source[nr_default_light_sources]
default light sources
virtual void set_cursor(int x, int y)
flush the output_stream and set a new cursor position given in opengl coordinates with (0,...
virtual void set_bg_stencil(int s)
set a user defined background stencil value
virtual void set_bg_accum_color(vec4 rgba)
set a user defined background color for the accumulation buffer
cgv::media::illum::surface_material default_material
store a default material
float get_bg_depth() const
return the current depth value for clearing the background
virtual void set_textured_material(const textured_material &mat)
set the current material
std::stack< std::vector< window_transformation > > window_transformation_stack
keep stack of window transformations
vec4 get_bg_accum_color() const
return the current color value for clearing the accumulation buffer
const cgv::media::illum::light_source & get_light_source(void *handle) const
read access to light source
virtual bool make_current() const =0
make the current context current if possible
bool draw_in_compatibility_mode
whether to do all drawing in compatibility mode, only possible if support_compatibility_mode is true,...
virtual void set_blend_state(BlendState state)
set the complete blend state
bool sRGB_framebuffer
whether to use opengl option to support sRGB framebuffer
virtual RenderPassFlags get_default_render_pass_flags() const
return the default render pass flags
virtual void set_bg_depth(float d)
set a user defined background depth value
virtual void enable_blending()
enable blending
void set_current_material(shader_program &prog) const
set the shader program material to the currently enabled material
void pop_cull_state()
pop the top of the current culling state from the stack
void pop_modelview_matrix()
see push_V for an explanation
void * default_light_source_handles[nr_default_light_sources]
handles of default light sources
void push_modelview_matrix()
push the current viewing matrix onto a matrix stack for viewing matrices.
std::stack< frame_buffer_base * > frame_buffer_stack
stack of currently enabled frame buffers
bool auto_set_view_in_current_shader_program
whether to automatically set viewing matrixes in current shader program, defaults to true
void tesselate_unit_cone(int resolution=25, bool flip_normals=false, bool edges=false)
tesselate a cone of radius 1
CullingMode get_cull_state() const
return the current culling state
virtual void set_viewport(const ivec4 &viewport, int array_index=-1)
set the current viewport or one of the viewports in the window transformation array
const cgv::media::illum::surface_material * current_material_ptr
store pointer to current material
virtual void set_modelview_matrix(const dmat4 &MV)
set the current modelview matrix, which transforms from world to eye space
void * get_enabled_light_source_handle(size_t i) const
access to handle of i-th light source
cgv::media::font::font_face_ptr current_font_face
store current font
virtual void set_depth_mask(bool flag)
set the depth buffer mask
bool auto_set_gamma_in_current_shader_program
whether to automatically set gamma in current shader program, defaults to true
virtual void init_frame(context &)
this method is called in one pass over all drawables before the draw method
virtual void resize(unsigned int w, unsigned int h)
callback to announce resizing of the output window
virtual bool init(context &)
this method is called after creation or recreation of the context, return whether all necessary funct...
base interface for framebuffer
implementation of the context API for the OpenGL API excluding methods for font selection,...
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 all render components
a shader program combines several shader code fragments to a complete definition of the shading pipel...
bool set_uniform(const context &ctx, const std::string &name, const T &value, bool generate_error=false)
Set the value of a uniform by name, where the type can be any of int, unsigned, float,...
bool set_attribute(const context &ctx, const std::string &name, const T &value)
set constant default value of a vertex attribute by attribute name, if name does not specify an attri...
base interface for a texture
the texture class encapsulates all functionality independent of the rendering api.
void set_component_format(const component_format &cf)
change component format and clear internal format
class that extends obj_material with the management of textures
a vertex buffer is an unstructured memory block on the GPU.
bool create(const context &ctx, size_t size_in_bytes)
create empty vertex buffer of size size given in bytes
void destruct(const context &ctx)
destruct the render buffer
bool replace(const context &ctx, size_t buffer_offset_in_bytes, const T *array_ptr, size_t nr_elements)
replace part (starting at byte offset buffer_offset_in_bytes) or whole vertex buffer content from nr_...
the base namespace holds the base hierarchy, support for plugin registration and signals
data::ref_ptr< group, true > group_ptr
ref counted pointer to a node
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
@ CF_D
color format with components B, G, R and A
unsigned find_best_match(const component_format &fmt, const char **format_descriptions, const component_format *fmt0, bool(*fmt1_better_match)(const component_format &fmt, const component_format &fmt1, const component_format &fmt2), bool show_debug_info)
find the best matching format in a list of formats described by strings and return index of best matc...
namespace that holds the abstract gui interface
void message(const std::string &_message)
tell the user something with a message box
bool load_texture(const cgv::data::const_data_view &data, unsigned gl_tex_format, unsigned level, unsigned cube_side, int num_array_layers, const std::vector< data_view > *palettes)
load data to a texture with the glTexImage commands and generate mipmaps if the level parameter is -1...
void read_texture(cgv::data::data_view &data, unsigned level)
read back a texture into a data view with the glGetTexImage command
void gl_set_material(const cgv::media::illum::phong_material &mat, MaterialSide ms, float alpha)
enable a material without textures
bool replace_texture(const cgv::data::const_data_view &data, int level, int x, int y, int z, const std::vector< cgv::data::data_view > *palettes)
replace part or complete data of currently bound texture with the data in the given data view
bool ensure_glew_initialized()
initialize glew in the first call to this function and always return whether this was successful
unsigned find_best_texture_format(const cgv::data::component_format &_cf, cgv::data::component_format *best_cf, const std::vector< data_view > *palettes, bool show_debug_info)
map the given component format to the best matching available gl component format
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...
bool generate_mipmaps(unsigned int dim, bool is_cubemap, bool is_array, std::string *last_error)
generate mipmaps for the currently bound texture, which has the given texture dimension; optionally p...
unsigned get_gl_cube_map_target(unsigned side)
return one of the six cube map sides gl enums
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,...
RenderAPI
enumeration of rendering APIs which can be queried from the context
CullingMode
different culling modes
BlendFunction
different blend functions
AccessType
different access types
TextureFilter
different texture filter
TextureWrap
different texture wrap modes
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
VertexBufferUsage
Provides vertex buffer usage hints as defined in OpenGL.
ShaderType
different shader types
PrimitiveType
different primitive types
VertexBufferType
Provides vertex buffer types to allow implicit binding.
@ VBT_VERTICES
The buffer contains vertices and will be bound to GL_ARRAY_BUFFER.
@ VBT_TEXTURE
The buffer contains texture data and will be bound to GL_TEXTURE_BUFFER.
@ VBT_INDICES
The buffer contains indices and will be bound to GL_ELEMENT_ARRAY_BUFFER.
@ VBT_ATOMIC_COUNTER
The buffer contains atomic counter and will be bound to GL_ATOMIC_COUNTER_BUFFER.
@ VBT_STORAGE
The buffer contains arbitrary data and will be bound to GL_SHADER_STORAGE_BUFFER.
@ VBT_UNIFORM
The buffer contains uniforms and will be bound to GL_UNIFORM_BUFFER.
@ VBT_INDIRECT
The buffer contains indirect draw commands and will be bound to GL_DRAW_INDIRECT_BUFFER.
@ VBT_FEEDBACK
The buffer is used for transform&feedback and will be bound to GL_TRANSFORM_FEEDBACK_BUFFER.
BufferTypeBits
Bits for the selection of different buffer types.
TextureType
different texture types
RenderPassFlags
available flags that can be queried from the context and set for a new render pass
@ RPF_CLEAR_ACCUM
whether to clear the accumulation buffer
@ RPF_SET_MODELVIEW
whether to set default modelview matrix
@ RPF_SET_MATERIAL
whether to define default material
@ RPF_SET_CLEAR_DEPTH
whether to set the clear color
@ RPF_SET_LIGHTS
whether to define default lights
@ RPF_CLEAR_COLOR
whether to clear the color buffer
@ RPF_CLEAR_STENCIL
whether to clear the depth buffer
@ RPF_SET_CLEAR_STENCIL
whether to set the clear color
@ RPF_ENABLE_MATERIAL
whether to enable material
@ RPF_DRAWABLES_INIT_FRAME
whether to call the init_frame method of the drawables
@ RPF_CLEAR_DEPTH
whether to clear the depth buffer
@ RPF_SET_STATE_FLAGS
whether to set depth buffer and culling flags
@ RPF_SET_PROJECTION
whether to set default projection matrix
@ RPF_SET_CLEAR_ACCUM
whether to set the accumulation buffer clear color
@ RPF_SET_CLEAR_COLOR
whether to set the clear color
@ RPF_SET_LIGHTS_ON
whether to turn on default lights
CompareFunction
different comparison functions used for depth testing or texture comparisons
namespace for templates that provide type information
const char * get_type_name(TypeId tid)
function that returns the name of a type specified through TypeId
TypeId
ids for the different types and type constructs
@ TI_INT16
signed integer stored in 8 bits
@ TI_INT32
signed integer stored in 16 bits
@ TI_FLT32
floating point type stored in 16 bits
@ TI_UINT32
unsigned integer stored in 16 bits
@ TI_UINT8
signed integer stored in 64 bits
@ TI_UINT16
unsigned integer stored in 8 bits
@ TI_FLT64
floating point type stored in 32 bits
namespace for compile time type information
std::string to_string(const std::string &v, unsigned int w, unsigned int p, bool)
specialization of conversion from string to strings
char to_upper(char c)
convert char to upper case
bool is_element(char c, const std::string &s)
check if char c arises in string s
this header is dependency free
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< uint32_t, 3 > uvec3
declare type of 3d 32 bit unsigned integer 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< float, 3 > vec3
declare type of 3d single precision floating point vectors
Helper functions to process strings.
Represents a blend state used to configure fragment blending.
bool enabled
whether blending is enabled
BlendFunction dst_color
the destination color (rgb) factor
BlendFunction dst_alpha
the destination alpha factor
BlendFunction src_alpha
the source alpha factor
BlendFunction src_color
the source color (rgb) factor
Represents a buffer mask used to mask depth and color buffer outputs.
Represents a depth test state used to configure depth testing.
bool enabled
whether the depth test is enabled
CompareFunction test_func
the function used to compare depth values
configuration object used to define context parameters that need to be set already at creation time
int version_minor
default: -1 ... minor version of maximum supported OpenGL version
int version_major
default: -1 ... major version of maximum supported OpenGL version
bool debug
default: false in release and true in debug version
bool forward_compatible
default: false
bool core_profile
default: true
bool depth_buffer
default: true
int max_compute_shared_memory_size
the total number of output values (a component, in GLSL terms, is a component of a vector....
ivec3 max_compute_work_group_count
the number of invocations in a single local work group (i.e., the product of the three dimensions) th...
int max_compute_work_group_invocations
total available storage size in bytes for all shared variables in a compute shader
int max_geometry_shader_total_output_component_count
the maximum number of components of outputs (out variables) written by a geometry shader
int max_geometry_shader_output_vertex_count
the maximum supported size for renderbuffers in any dimension
ivec3 max_compute_work_group_size
the maximum number of work groups that may be dispatched to a compute shader; dimension index 0,...
int max_geometry_shader_output_component_count
the maximum number that can be provided to the max_vertices output layout qualifier in a geometry sha...
structure to store information on a shader program variable, i.e.
compact type description of data that can be sent to the context; convertible to int