2#include <cgv/base/group.h>
3#include <cgv/media/image/image_writer.h>
4#include <cgv/math/ftransform.h>
5#include <cgv/base/traverser.h>
6#include <cgv/render/drawable.h>
7#include <cgv/render/shader_program.h>
8#include <cgv/render/attribute_array_binding.h>
13#define SAFE_STACK_POP(STACK, WHERE) \
14if(STACK.size() == 1) error("context::" WHERE "() ... attempt to completely empty stack avoided."); \
21const int nr_backgrounds = 5;
22float background_colors[] = {
33 switch (
td.coordinate_type) {
40 switch (
td.element_type) {
41 case cgv::render::ElementType::ET_VALUE:
44 case cgv::render::ElementType::ET_VECTOR:
49 case cgv::render::ElementType::ET_MATRIX: type =
"mat";
break;
53 if (
td.nr_columns !=
td.nr_rows) {
65 if (
type_descr.element_type == cgv::render::ET_VECTOR)
67 if (
type_descr.element_type == cgv::render::ET_MATRIX)
79 os <<
V.type_descr <<
" " <<
V.name;
81 os <<
"[" <<
V.array_size <<
"]";
82 if (
V.program_location != -1)
83 os <<
" @" <<
V.program_location;
84 if (
V.current_value.empty())
89 V.compute_sizes(cnt, s, S);
92 for (
size_t j = 0;
j <
V.array_size; ++
j) {
97 for (
size_t k = 0; k < cnt; ++k) {
100 const void* value_ptr =
V.current_value.data() +
j * s;
101 switch (
V.type_descr.coordinate_type) {
112 if (
V.array_size > 1)
159 srh.reflect_member(
"debug",
debug) &&
193 return "render_config";
220 gpu_vendor = GPU_VENDOR_UNKNOWN;
254 projection_matrix_stack.push(cgv::math::identity4<double>());
257 wt.viewport =
ivec4(0, 0, 640, 480);
279 do_screen_shot =
false;
310 rc->last_error = message;
312 std::cerr << message << std::endl;
324 return gpu_capabilities;
331 attribute_array_binding_destruct(*
dummy_aab);
337void context::init_render_pass()
342void context::draw_textual_info()
347void context::perform_screen_shot()
351void context::destruct_render_objects()
357void context::finish_render_pass()
375 error(
child->get_type_name()+
"::init(context&) failed");
508 error(
"context::enable_phong_shading() deprecated");
511void context::disable_phong_shading()
514 error(
"context::disable_phong_shading() deprecated");
519 error(
"context::enable_material(phong_material) deprecated");
524 error(
"context::disable_material(phong_material) deprecated");
526void context::enable_material(
const textured_material& mat,
MaterialSide ms,
float alpha)
528 error(
"context::enable_material(textured_material) deprecated");
576 dvec4 hL(
Le,
light.get_type() == cgv::media::illum::LT_DIRECTIONAL ? 0.0f : 1.0f);
579 if (
light.get_type() != cgv::media::illum::LT_DIRECTIONAL)
616 light_sources[handle] = std::pair<cgv::media::illum::light_source, light_source_status>(
632 if (iter->second.second.enabled) {
648 return iter->second.first;
655 return iter->second.second;
663 iter->second.first =
light;
667 if (iter->second.second.enabled)
678 prog.
set_uniform(*
this,
"inverse_modelview_matrix", cgv::math::inverse(
V));
691 NM = cgv::math::inverse(
NM);
697 prog.
set_uniform(*
this,
"inverse_projection_matrix", cgv::math::inverse(
P));
723 prog.
set_uniform(*
this,
prefix +
".spot_direction", iter->second.second.eye_spot_direction);
738 if (!prog.does_use_lights())
751 if (iter->second.second.enabled)
778 return iter->second.second.enabled;
787 if (iter->second.second.enabled)
789 iter->second.second.enabled =
true;
802 if (!iter->second.second.enabled)
804 iter->second.second.enabled =
false;
808 iter->second.second.light_source_index = -1;
833 "RP_OPAQUE_SURFACES",
834 "RP_TRANSPARENT_SURFACES",
895 if (
ri.pass_index != -1)
896 std::cout <<
":" <<
ri.pass_index;
897 std::cout <<
"> " << info << std::endl;
911 ri.user_data = user_data;
946 perform_screen_shot();
947 do_screen_shot =
false;
950 finish_render_pass();
958 unsigned int i,
j = 0;
959 for (
i = 0;
i<text.size(); ++
i) {
1005 float y = (
float)cursor_y;
1008 cursor_y =
int(y + 0.5f);
1021 font_face->enable(
this, font_size);
1054 unsigned char*
dst =
dv1.get_ptr<
unsigned char>();
1055 for (
size_t i=0;
i<n; ++
i, ++
dst, ++
src)
1067 unsigned char*
dst = dv.
get_ptr<
unsigned char>();
1069 for (
size_t i=0;
i<n; ++
i, ++
dst)
1083 "repeat",
"clamp",
"clamp_to_edge",
"clamp_to_border",
"mirror_clamp",
1084 "mirror_clamp_to_edge",
"mirror_clamp_to_border"
1094 "undefined",
"Texture1D",
"Texture2D",
"Texture3D",
"CubeTexture"
1103 "x+",
"x-",
"y+",
"y-",
"z+",
"z-"
1112 "undef",
"points",
"lines",
"lines_adjacency",
"line_strip",
"line_strip_adjacency",
"line_loop",
1113 "triangles",
"triangles_adjacency",
"triangle_strip",
"triangle_strip_adjacency",
"triangle_fan",
1114 "quads",
"quad_strip",
"polygon",
"patches"
1125 "nearest_mipmap_nearest",
1126 "linear_mipmap_nearest",
1127 "nearest_mipmap_linear",
1128 "linear_mipmap_linear",
1134void compute_face_normals(
const float* vertices,
float* normals,
const int* vertex_indices,
int* normal_indices,
int nr_faces,
int face_degree)
1136 for (
int i = 0;
i < nr_faces; ++
i) {
1137 vec3& normal =
reinterpret_cast<vec3&
>(normals[3 *
i]);
1139 vec3 reference_pnt = *
reinterpret_cast<const vec3*
>(vertices + 3 * vertex_indices[face_degree*
i + face_degree - 1]);
1142 for (
int j = 0;
j < face_degree; ++
j) {
1148 for (
int j = 0;
j<face_degree; ++
j)
1149 normal_indices[face_degree*
i+
j] =
i;
1156 static float V[8*3] = {
1166 static float N[6*3] = {
1171 static const float ot =
float(1.0 / 3);
1172 static const float tt =
float(2.0 / 3);
1173 static float T[14*2] = {
1175 0.25f,0 , 0.25f,ot ,
1176 0.25f,tt , 0.25f,1 ,
1179 0.75f,ot , 0.75f,tt ,
1182 static int F[6*4] = {
1190 static int FN[6*4] = {
1195 static int FT[6*4] = {
1196 3,4,1,0 ,7,10,11,8 ,
1198 12,13,11,10 ,3,7,8,4
1209 static float N[6 * 3] = {
1214 static int F[6 * 4] = {
1222 static int FN[6 * 4] = {
1223 0, 0, 0, 0, 1, 1, 1, 1,
1224 2, 2, 2, 2, 3, 3, 3, 3,
1225 4, 4, 4, 4, 5, 5, 5, 5
1229 for (
unsigned i = 0;
i < 8; ++
i) {
1243 static const float V[6*3] = {
1251 static float a = 1.0f/
sqrt(5.0f);
1252 static float b = 2*a;
1253 static const float N[5*3] = {
1260 static const int FT[2*3] = { 0,1,2, 5,4,3 };
1261 static const int FQ[8] = { 4,1, 3,0, 5,2, 4,1};
1262 static const int FTN[2*3] = { 0,0,0, 1,1,1 };
1263 static const int FQN[8] = { 2,2, 2,2, 3,3, 4,4, };
1278 std::vector<float>
V;
V.reserve(3*(resolution+1));
1279 std::vector<float> N; N.reserve(3*(resolution+1));
1280 std::vector<float>
T;
T.reserve(2*(resolution+1));
1282 std::vector<int> F; F.resize(resolution+1);
1284 for (
i = 0;
i <= resolution; ++
i)
1287 float step =
float(2*M_PI/resolution);
1289 for (
i = 0;
i <= resolution; ++
i, phi += step) {
1290 float cp =
cos(phi);
1291 float sp =
sin(phi);
1295 T.push_back((
float)
i/resolution);
1310 std::vector<float>
V;
V.reserve(6*(resolution+1));
1311 std::vector<float> N; N.reserve(6*(resolution+1));
1312 std::vector<float>
T;
T.reserve(4*(resolution+1));
1314 std::vector<int> F; F.resize(2*resolution+2);
1316 for (
i = 0;
i <= 2*resolution+1; ++
i)
1319 static float a = 1.0f/
sqrt(5.0f);
1320 static float b = 2*a;
1321 float step =
float(2*M_PI/resolution);
1325 for (
int i = 0;
i <= resolution; ++
i, u +=
duv, phi += step) {
1326 float cp =
cos(phi);
1327 float sp =
sin(phi);
1354 std::vector<float>
V;
V.reserve(6*(resolution+1));
1355 std::vector<float> N; N.reserve(6*(resolution+1));
1356 std::vector<float>
T;
T.reserve(4*(resolution+1));
1358 std::vector<int> F; F.resize(2*(resolution+1));
1360 for (
i = 0;
i <= 2*resolution+1; ++
i)
1363 float step =
float(2*M_PI/resolution);
1367 for (
int i = 0;
i <= resolution; ++
i, u +=
duv, phi += step) {
1368 float cp =
cos(phi);
1369 float sp =
sin(phi);
1396 std::vector<float>
V;
V.resize(6*(resolution+1));
1397 std::vector<float> N; N.resize(6*(resolution+1));
1398 std::vector<float>
T;
T.resize(4*(resolution+1));
1399 std::vector<int> F; F.resize(2*(resolution+1));
1401 for (
int i = 0;
i <= resolution; ++
i) {
1405 float step =
float(2*M_PI/resolution);
1410 for (
i = 0;
i < resolution; ++
i, u +=
duv) {
1418 for (
int j = 0;
j <= resolution; ++
j,
theta += step, v +=
duv) {
1446 std::vector<float>
V;
V.resize(6*(resolution+1));
1447 std::vector<float> N; N.resize(6*(resolution+1));
1448 std::vector<float>
T;
T.resize(4*(resolution+1));
1449 std::vector<int> F; F.resize(2*(resolution+1));
1451 for (
int i = 0;
i <= resolution; ++
i) {
1455 float step =
float(M_PI/resolution);
1460 for (
i = 0;
i < resolution; ++
i, u +=
duv) {
1468 for (
int j = 0;
j <= resolution; ++
j,
theta += step, v +=
duv) {
1497 static const float a =
float(1.0/(2*
sqrt(3.0)));
1498 static const float b =
float(1.0/(3*
sqrt(3.0/2)));
1499 static const float V[4*3] = {
1505 static const int F[4*3] = {
1506 0,2,1,3,2,0,3,0,1,3,1,2
1509 static float N[4*3];
1512 compute_face_normals(
V, N, F,
FN, 4, 3);
1525 static float N[1*3] = {
1528 static float V[4*3] = {
1532 static float T[4*2] = {
1536 static int FN[1*4] = {
1539 static int F[1*4] = {
1552 static float N[8*3] = {
1553 -1,-1,+1, +1,-1,+1, -1,+1,+1, +1,+1,+1,
1554 -1,-1,-1, +1,-1,-1, -1,+1,-1, +1,+1,-1
1556 static float V[6*3] = {
1561 static int FN[8*3] = {
1571 static int F[8*3] = {
1590 static const float h = 0.4472135956f;
1591 static const float r = 0.8944271912f;
1592 static const float s =
float(M_PI/2.5);
1593 static const float o =
float(M_PI/5);
1594 static const float V[13*3] = {
1596 r*
sin(1*s),r*
cos(1*s),-h,
1597 r*
sin(2*s),r*
cos(2*s),-h,
1598 r*
sin(3*s),r*
cos(3*s),-h,
1599 r*
sin(4*s),r*
cos(4*s),-h,
1600 r*
sin(5*s),r*
cos(5*s),-h,
1601 r*
sin(1*s+o),r*
cos(1*s+o),h,
1602 r*
sin(2*s+o),r*
cos(2*s+o),h,
1603 r*
sin(3*s+o),r*
cos(3*s+o),h,
1604 r*
sin(4*s+o),r*
cos(4*s+o),h,
1605 r*
sin(5*s+o),r*
cos(5*s+o),h,
1609 static int F[20*3] = {
1610 0,1,2, 0,2,3, 0,3,4, 0,4,5, 0,5,1,
1611 6,2,1, 2,6,7, 7,3,2, 3,7,8, 8,4,3, 4,8,9, 9,5,4, 5,9,10, 10,1,5, 6,1,10,
1612 11,6,10, 11,10,9, 11,9,8, 11,8,7, 11,7,6
1614 static int DF[12*5] = {
1628 static float N[20*3];
1629 static int FN[20*3];
1630 static int DFN[12*5] = {
1647 compute_face_normals(
V, N, F,
FN, 20, 3);
1700 if (prog.does_use_gamma())
1716 attribute_array_binding_create(*
dummy_aab);
1718 attribute_array_binding_enable(*
dummy_aab);
1726 error(
"call to end_attribute_less_rendering() without call to begin_attribute_less_rendering()");
1728 error(
"call to end_attribute_less_rendering() with empty attribute array binding stack");
1730 error(
"call to end_attribute_less_rendering() after another attribute array was bound");
1732 attribute_array_binding_disable(*
dummy_aab);
1748 if (!prog.does_context_set_color())
1750 int clr_loc = prog.get_color_index();
1769 if (!prog.does_use_material())
1788 if (!prog.does_use_material())
1921 mask.red_flag = flags[0];
1922 mask.green_flag = flags[1];
1923 mask.blue_flag = flags[2];
1924 mask.alpha_flag = flags[3];
1952 SAFE_STACK_POP(projection_matrix_stack,
"pop_projection_matrix");
1973 if (!prog.does_use_view())
1981 projection_matrix_stack.top() =
P;
1990 if (!prog.does_use_view())
2005bool context::ensure_window_transformation_index(
int&
array_index)
2015 std::string message(
"context::ensure_window_transformation_index() ... attempt to resize window transformation array larger than maximum allowed size of ");
2028 if (!ensure_window_transformation_index(
array_index))
2035 if (!ensure_window_transformation_index(
array_index))
2049 std::string message(
"context::get_window_matrix() ... attempt to query window matrix with array index ");
2051 message +=
" out of range [0,";
2055 return cgv::math::identity4<double>();
2058 dmat4 M = cgv::math::identity4<double>();
2059 M(0, 0) = 0.5*
wt.viewport[2];
2060 M(0, 3) =
M(0, 0) +
wt.viewport[0];
2061 M(1, 1) = 0.5*
wt.viewport[3];
2062 M(1, 3) =
M(1, 1) +
wt.viewport[1];
2063 M(2, 2) = 0.5*(
wt.depth_range[1] -
wt.depth_range[0]);
2064 M(2, 3) =
M(2, 2) +
wt.depth_range[0];
2098 for (
unsigned int c = 0; c < p.
size(); ++c)
2105 error(
"context::put_cursor_coords() deprecated");
2115 static_cast<int>(
p4.x() /
p4.w()),
2116 static_cast<int>(
p4.y() /
p4.w())
2123 int x_offset,
int y_offset)
2131 case 0 : x -= (
int)(floor(w)*0.5f);
break;
2132 case 2 : x -= (
int)floor(w);
break;
2136 case 0 : y -= (
int)(floor(h)*0.3f);
break;
2137 case 4 : y -= (
int)(floor(h)*0.6f);
break;
2156 case 0:
cursor.x() -=
static_cast<int>(std::floor(w) * 0.5f);
break;
2157 case 2:
cursor.x() -=
static_cast<int>(std::floor(w));
break;
2161 case 0:
cursor.y() -=
static_cast<int>(std::floor(h) * 0.3f);
break;
2162 case 4:
cursor.y() -=
static_cast<int>(std::floor(h) * 0.6f);
break;
2185 std::cout <<
"tesselate_arrow not implemented in cgv::render::context" << std::endl;
2190 std::cout <<
"tesselate_arrow not implemented in cgv::render::context" << std::endl;
2195 std::cout <<
"draw_light_source not implemented in cgv::render::context" << std::endl;
2201 internal_format = 0;
2216 std::cerr <<
"no context set when render_component::put_id_void was called" << std::endl;
2222render_buffer_base::render_buffer_base()
2229 mag_filter = TF_LINEAR;
2230 min_filter = TF_LINEAR_MIPMAP_LINEAR;
2231 wrap_s = TW_CLAMP_TO_EDGE;
2232 wrap_t = TW_CLAMP_TO_EDGE;
2233 wrap_r = TW_CLAMP_TO_EDGE;
2236 border_color[0] = 1;
2237 border_color[1] = 1;
2238 border_color[2] = 1;
2239 border_color[3] = 1;
2241 compare_function = CF_LEQUAL;
2242 use_compare_function =
false;
2243 have_mipmaps =
false;
2246void shader_program_base::allow_context_to_set_color(
bool allow)
2248 context_sets_color =
allow;
2254 geometry_shader_input_type = PT_POINTS;
2255 geometry_shader_output_type = PT_POINTS;
2256 geometry_shader_output_count = 1;
2258 auto_detect_uniforms =
true;
2259 auto_detect_vertex_attributes =
true;
2262 uses_material =
false;
2263 uses_lights =
false;
2266 position_index = -1;
2269 context_sets_color =
true;
2270 texcoord_index = -1;
2274void shader_program_base::specify_standard_uniforms(
bool view,
bool material,
bool lights,
bool gamma)
2276 auto_detect_uniforms =
false;
2278 uses_material = material;
2283void shader_program_base::specify_standard_vertex_attribute_names(context& ctx,
bool color,
bool normal,
bool texcoord)
2285 auto_detect_vertex_attributes =
false;
2286 position_index = ctx.get_attribute_location(*
this,
"position");
2287 color_index =
color ? ctx.get_attribute_location(*
this,
"color") : -1;
2288 normal_index = normal ? ctx.get_attribute_location(*
this,
"normal") : -1;
2289 texcoord_index = texcoord ? ctx.get_attribute_location(*
this,
"texcoord") : -1;
2292void shader_program_base::specify_vertex_attribute_names(context& ctx,
const std::string& position,
const std::string&
color,
const std::string& normal,
const std::string& texcoord)
2294 auto_detect_vertex_attributes =
false;
2295 position_index = position.empty() ? -1 : ctx.get_attribute_location(*
this, position);
2296 color_index =
color.empty() ? -1 : ctx.get_attribute_location(*
this,
color);
2297 normal_index = normal.empty() ? -1 : ctx.get_attribute_location(*
this, normal);
2298 texcoord_index = texcoord.empty() ? -1 : ctx.get_attribute_location(*
this, texcoord);
2300bool context::shader_program_link(shader_program_base&
spb)
const
2302 if (
spb.handle == 0)
2304 if (
spb.auto_detect_vertex_attributes) {
2305 spb.position_index = get_attribute_location(
spb,
"position");
2306 spb.color_index = get_attribute_location(
spb,
"color");
2307 spb.normal_index = get_attribute_location(
spb,
"normal");
2308 spb.texcoord_index = get_attribute_location(
spb,
"texcoord");
2309 spb.auto_detect_vertex_attributes =
false;
2311 if (
spb.auto_detect_uniforms) {
2312 spb.uses_lights = get_uniform_location(
spb,
"light_sources[0].light_source_type") != -1;
2313 spb.uses_material = get_uniform_location(
spb,
"material.brdf_type") != -1;
2315 get_uniform_location(
spb,
"modelview_matrix") != -1 ||
2316 get_uniform_location(
spb,
"projection_matrix") != -1 ||
2317 get_uniform_location(
spb,
"inverse_projection_matrix") != -1 ||
2318 get_uniform_location(
spb,
"normal_matrix") != -1 ||
2319 get_uniform_location(
spb,
"inverse_modelview_matrix") != -1 ||
2320 get_uniform_location(
spb,
"inverse_normal_matrix") != -1;
2321 spb.uses_gamma = get_uniform_location(
spb,
"gamma3") != -1 || get_uniform_location(
spb,
"gamma") != -1;
2322 spb.auto_detect_uniforms =
false;
2327bool context::shader_program_enable(shader_program_base&
spb)
2329 if (
spb.is_enabled) {
2331 error(
"context::shader_program_enable() called with program that is currently active", &
spb);
2334 error(
"context::shader_program_enable() called with program that is recursively reactivated", &
spb);
2338 spb.is_enabled =
true;
2342bool context::shader_program_disable(shader_program_base&
spb)
2345 error(
"context::shader_program_disable() called with empty stack", &
spb);
2348 if (!
spb.is_enabled) {
2349 error(
"context::shader_program_disable() called with disabled program", &
spb);
2353 error(
"context::shader_program_disable() called with program that was not on top of shader program stack", &
spb);
2357 spb.is_enabled =
false;
2361bool context::shader_program_destruct(shader_program_base&
spb)
const
2363 if (
spb.is_enabled) {
2364 error(
"context::shader_program_destruct() on shader program that was still enabled", &
spb);
2388void context::shader_program_set_uniform_locations(shader_program_base&
spb)
const
2390 spb.uniform_locations.clear();
2409 if (aab.is_enabled) {
2410 error(
"context::attribute_array_binding_destruct() on array binding that was still enabled", &aab);
2435bool context::attribute_array_binding_enable(attribute_array_binding_base& aab)
2438 error(
"context::attribute_array_binding_enable() called in not created attribute array binding.", &aab);
2441 if (aab.is_enabled) {
2443 error(
"context::attribute_array_binding_enable() called with array binding that is currently active", &aab);
2446 error(
"context::attribute_array_binding_enable() called with array binding that is recursively reactivated", &aab);
2450 aab.is_enabled =
true;
2454bool context::attribute_array_binding_disable(attribute_array_binding_base& aab)
2457 error(
"context::attribute_array_binding_disable() called with empty stack", &aab);
2460 if (!aab.is_enabled) {
2461 error(
"context::attribute_array_binding_disable() called with disabled array binding", &aab);
2465 error(
"context::attribute_array_binding_disable() called with array binding that was not on top of array binding stack", &aab);
2469 aab.is_enabled =
false;
2486 depth_attached =
false;
2487 std::fill(attached, attached+16,
false);
2490void context::get_buffer_list(
frame_buffer_base&
fbb,
bool& depth_buffer, std::vector<int>& buffers,
int offset)
2492 if (
fbb.enabled_color_attachments.size() == 0) {
2493 for (
int i = 0;
i < 16; ++
i)
2494 if (
fbb.attached[
i])
2495 buffers.push_back(
i + offset);
2498 for (
int i = 0;
i < (
int)
fbb.enabled_color_attachments.size(); ++
i)
2499 if (
fbb.attached[
fbb.enabled_color_attachments[
i]])
2500 buffers.push_back(
fbb.enabled_color_attachments[
i]+offset);
2505bool context::frame_buffer_create(frame_buffer_base&
fbb)
const
2507 if (
fbb.width == -1)
2509 if (
fbb.height == -1)
2514bool context::frame_buffer_attach(frame_buffer_base&
fbb,
const render_buffer_base&
rb,
bool is_depth,
int i)
const
2516 if (
fbb.handle == 0) {
2517 error(
"gl_context::frame_buffer_attach: attempt to attach to frame buffer that is not created", &
fbb);
2520 if (
rb.handle == 0) {
2521 error(
"gl_context::frame_buffer_attach: attempt to attach empty render buffer", &
fbb);
2525 fbb.depth_attached =
true;
2527 fbb.attached[
i] =
true;
2532bool context::frame_buffer_attach(frame_buffer_base&
fbb,
const texture_base& t,
bool is_depth,
int level,
int i,
int z_or_cube_side)
const
2534 if (
fbb.handle == 0) {
2535 error(
"context::frame_buffer_attach: attempt to attach to frame buffer that is not created", &
fbb);
2538 if (t.handle == 0) {
2539 error(
"context::frame_buffer_attach: attempt to attach texture that is not created", &
fbb);
2543 fbb.depth_attached =
true;
2545 fbb.attached[
i] =
true;
2550bool context::frame_buffer_enable(frame_buffer_base&
fbb)
2552 if (
fbb.handle == 0) {
2553 error(
"context::frame_buffer_enable: attempt to enable not created frame buffer", &
fbb);
2556 if (
fbb.is_enabled) {
2558 error(
"context::frame_buffer_enable() called with frame buffer that is currently active", &
fbb);
2561 error(
"context::frame_buffer_enable() called with frame buffer that is recursively reactivated", &
fbb);
2565 fbb.is_enabled =
true;
2569bool context::frame_buffer_disable(frame_buffer_base&
fbb)
2572 error(
"gl_context::frame_buffer_disable called with empty stack", &
fbb);
2576 error(
"gl_context::frame_buffer_disable called with different frame buffer enabled", &
fbb);
2580 fbb.is_enabled =
false;
2584bool context::frame_buffer_destruct(frame_buffer_base&
fbb)
const
2586 if (
fbb.handle == 0) {
2587 error(
"context::frame_buffer_destruct: attempt to destruct not created frame buffer", &
fbb);
2590 if (
fbb.is_enabled) {
2591 error(
"context::frame_buffer_destruct() on frame buffer that was still enabled", &
fbb);
2597std::vector<context_creation_function_type>& ref_context_creation_functions()
2599 static std::vector<context_creation_function_type>
ccfs;
2606 ref_context_creation_functions().push_back(fp);
2609context_factory_registration::context_factory_registration(context_creation_function_type fp)
2618 unsigned int w,
unsigned int h,
2619 const std::string& title,
bool show)
2621 std::vector<context_creation_function_type>&
ccfs = ref_context_creation_functions();
2622 for (
unsigned i=0;
i<
ccfs.size(); ++
i) {
2629 std::cerr <<
"could not create context for given parameters" << std::endl;
2637#include <cgv/base/register.h>
2649#undef SAFE_STACK_POP
The group class is a node with children.
complete implementation of method actions that only call one method when entering a node
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...
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.
reference counted pointer, which can work together with types that are derived from ref_counted,...
bool empty() const
check if pointer is not yet set
matrix of fixed size dimensions
T normalize()
normalize the vector using the L2-Norm and return the length
T & w()
return fourth component
unsigned size() const
number of elements
the self reflection handler is passed to the virtual self_reflect() method of cgv::base::base.
base class for attribute_array_bindings
attribute_array_binding_base()
nothing to be done heremembers
the attribute_array_binding allows to define vertex attributes (i.e.
base class for all drawables, which is independent of the used rendering API.
void push_window_transformation_array()
push a copy of the current viewport and depth range arrays defining the window transformations
void tesselate_unit_prism(bool flip_normals=false, bool edges=false)
tesselate a prism
void * add_light_source(const cgv::media::illum::light_source &light, bool enabled=true, bool place_now=false)
add a new light source, enable it if enable is true and place it relative to current model view trans...
virtual void set_blend_func(BlendFunction src_factor, BlendFunction dst_factor)
set the blend function
void enable_shader_file_cache()
enable the usage of the shader file caches
virtual std::ostream & output_stream()
returns an output stream whose output is printed at the current cursor location, which is managed by ...
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=cgv::type::info::TI_UINT8, data::ComponentFormat cf=data::CF_RGB, int w=-1, int h=-1)=0
read the current frame buffer or a rectangular region of it into the given data view.
void set_blend_func_back_to_front()
set the default blend function for back to front blending (source = BF_SRC_ALPHA, destination = BF_ON...
virtual void mul_modelview_matrix(const dmat4 &MV)
multiply given matrix from right to current modelview matrix
void pop_bg_color()
pop the top of the current background color from the stack
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
vec3 gamma3
per color channel gamma value passed to shader programs that have gamma uniform
virtual bool in_render_process() const =0
return whether the context is currently in process of rendering
virtual void process_text(const std::string &text)
callback method for processing of text from the output stream
virtual void set_color(const rgba &clr)
set the current color
virtual void draw_light_source(const cgv::media::illum::light_source &l, float intensity_scale, float light_scale)
draw a light source with an emissive material
virtual bool is_created() const =0
return whether the context is created
virtual void set_gamma3(const vec3 &_gamma3)
set the current per channel gamma values to single value
virtual void enable_sRGB_framebuffer(bool do_enable=true)
enable or disable sRGB framebuffer
virtual 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 =0
pass geometry of given faces to current shader program and generate draw calls to render lines for th...
RenderPassFlags default_render_flags
default render flags with which the main render pass is initialized
void pop_buffer_mask()
pop the top of the current buffer mask from the stack
vec3 get_model_point(int x_window, int y_window) const
compute model space 3D point from the given opengl pixel location (window location)
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
std::stack< render_info > render_pass_stack
store the current render pass
virtual void draw_edges_of_strip_or_fan(const float *vertices, const float *normals, const float *tex_coords, const int *vertex_indices, const int *normal_indices, const int *tex_coord_indices, int nr_faces, int face_degree, bool is_fan, bool flip_normals=false) const =0
pass geometry of given strip or fan to current shader program and generate draw calls to render lines...
virtual GPUVendorID get_gpu_vendor_id() const
device information
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
const light_source_status & get_light_source_status(void *handle) const
read access to light source status
void place_light_source(void *handle)
place the given light source relative to current model viel transformation
void tesselate_unit_cube(bool flip_normals=false, bool edges=false)
tesselate a unit cube with extent from [-1,-1,-1] to [1,1,1] with face normals that can be flipped
virtual void get_cursor(int &x, int &y) const
return current cursor location in opengl coordinates with (0,0) in lower left corner
std::stack< BufferMask > buffer_mask_stack
stack of buffer masks
void set_bg_clr_idx(unsigned int idx)
set an indexed background color
virtual void set_buffer_mask(BufferMask mask)
set the buffer mask for depth and color buffers
virtual void draw_strip_or_fan(const float *vertices, const float *normals, const float *tex_coords, const int *vertex_indices, const int *normal_indices, const int *tex_coord_indices, int nr_faces, int face_degree, bool is_fan, bool flip_normals=false) const =0
pass geometry of given strip or fan to current shader program and generate draw calls to render trian...
bool auto_set_lights_in_current_shader_program
whether to automatically set lights in current shader program, defaults to true
float get_bg_accum_alpha() const
return the current alpha value for clearing the accumulation buffer
void set_bg_alpha(float a)
set a user defined background alpha value
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
size_t light_source_handle
counter to construct light source handles
virtual void on_lights_changed()
helper function to send light update events
context()
init the cursor position to (0,0)
void push_depth_test_state()
push a copy of the current depth test state onto the stack saved attributes: depth test enablement,...
virtual void tesselate_arrow(double length=1, double aspect=0.1, double rel_tip_radius=2.0, double tip_aspect=0.3, int res=25, bool edges=false)
tesselate an arrow from the origin in z-direction
void put_bg_color(float *rgba) const
copy the current background rgba color into the given float array
std::stack< shader_program_base * > shader_program_stack
stack of currently enabled shader programs
virtual ivec2 get_cursor_coords(const vec3 &p) const
transform point p in current world coordinates into opengl coordinates with (0,0) in lower left corne...
void push_blend_state()
push a copy of the current blend state onto the stack saved attributes: blend enablement,...
bool is_light_source_enabled(void *handle)
check whether light source is enabled
virtual void disable_depth_test()
disable the depth test
void pop_bg_depth()
pop the top of the current background depth value from the stack
int get_bg_stencil() const
return the current stencil value for clearing the background
virtual float get_current_font_size() const
return the size in pixels of the currently enabled font face
void pop_blend_state()
pop the top of the current culling state from the stack
virtual unsigned int get_width() const =0
return the width of the window
const cgv::media::illum::surface_material * get_current_material() const
return pointer to current material or nullptr if no current material is available
void set_bg_accum_alpha(float a)
set a user defined background alpha value for the accumulation buffer
float get_gamma() const
query current gamma computed as average over gamma3 per channel values
bool disable_light_source(void *handle)
disable a given light source and return whether there existed a light source with given handle
int current_background
current back ground color index
void set_blend_func_front_to_back()
set the default blend function for front to back blending (source = BF_ONE_MINUS_DST_ALPHA,...
virtual RenderPass get_render_pass() const
return the current render pass
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
float get_bg_alpha() const
return the current alpha value for clearing the background
bool write_frame_buffer_to_image(const std::string &file_name, data::ComponentFormat cf=data::CF_RGB, FrameBufferType buffer_type=FB_BACK, unsigned int x=0, unsigned int y=0, int w=-1, int h=-1, float depth_offset=0.9f, float depth_scale=10.0f)
write the content of the frame buffer to an image file.
unsigned int get_bg_clr_idx() const
return the current index of the background color
void tesselate_unit_tetrahedron(bool flip_normals=false, bool edges=false)
tesselate a tetrahedron
virtual bool recreate_context()
recreate context based on current context config settings
virtual void configure_new_child(cgv::base::base_ptr child)
helper method to integrate a new child
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
void render_pass_debug_output(const render_info &ri, const std::string &info="")
write out render pass debug info, if activated
void tesselate_unit_octahedron(bool flip_normals=false, bool edges=false)
tesselate a octahedron
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
vec3 get_gamma3() const
query current per color channel gamma
void set_default_light_source(size_t i, const cgv::media::illum::light_source &ls)
set i-th default light source
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
dmat4 get_modelview_projection_window_matrix(unsigned array_index=0) const
return a homogeneous 4x4 matrix to transfrom from model to window coordinates, i.e....
dmat4 get_window_matrix(unsigned array_index=0) const
return a homogeneous 4x4 matrix to transform clip to window coordinates
void pop_bg_stencil()
pop the top of the current background stencil value from the stack
virtual void draw_faces(const float *vertices, const float *normals, const float *tex_coords, const int *vertex_indices, const int *normal_indices, const int *tex_coord_indices, int nr_faces, int face_degree, bool flip_normals=false) const =0
pass geometry of given faces to current shader program and generate draw calls to render triangles
std::stack< dmat4 > modelview_matrix_stack
keep two matrix stacks for model view and projection matrices
vec3 get_light_eye_position(const cgv::media::illum::light_source &light, bool place_now) const
helper function to place lights
void push_bg_stencil()
push a copy of the current background stencil value onto the stack
virtual unsigned get_max_nr_enabled_light_sources() const
return maximum number of light sources, that can be enabled in parallel
virtual void pop_window_transformation_array()
restore previous viewport and depth range arrays defining the window transformations
const cgv::media::illum::light_source & get_default_light_source(size_t i) const
return i-th default light source
bool use_shader_file_cache
whether to use the caching facilities of shader_program and shader_code to store loaded shader file c...
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
int nr_identations
current number of indentations
void tesselate_unit_dodecahedron(bool flip_normals=false, bool edges=false)
tesselate a dodecahedron
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
virtual void tesselate_box(const cgv::media::axis_aligned_box< double, 3 > &B, bool flip_normals, bool edges=false) const
tesselate an axis aligned box
bool enable_light_source(void *handle)
enable a given light source and return whether there existed a light source with given handle
virtual void * get_render_pass_user_data() const
return the current render pass user data
void tesselate_unit_disk(int resolution=25, bool flip_normals=false, bool edges=false)
tesselate a circular disk of radius 1
std::stack< float > bg_depth_stack
stack of background depth values
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
void tesselate_unit_torus(float minor_radius=0.2f, int resolution=25, bool flip_normals=false, bool edges=false)
tesselate a torus with major radius of one and given minor radius
vec4 get_bg_color() const
return the current color value for clearing the background
void pop_projection_matrix()
see push_P for an explanation
attribute_array_binding_base * dummy_aab
allocate a dummy attribute array binding used to support attribute-less rendering
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
void tesselate_unit_icosahedron(bool flip_normals=false, bool edges=false)
tesselate an icosahedron
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
std::stack< DepthTestState > depth_test_state_stack
stack of depth test states
std::stack< CullingMode > cull_state_stack
stack of culling mode states
void push_bg_depth()
push a copy of the current background depth value onto the stack
bool get_depth_mask() const
get the depth buffer mask
void disable_shader_file_cache()
disable the usage of the shader file caches
bool phong_shading
whether to use phong shading
virtual void push_pixel_coords()=0
use this to push new modelview and new projection matrices onto the transformation stacks such that x...
void end_attribute_less_rendering()
unbind dummy attribute array after attribute-less rendering
void push_projection_matrix()
same as push_V but for the projection matrix - a different matrix stack is used.
bvec4 get_color_mask() const
get the color buffer mask
const rgba & get_color() const
return current color
bool is_shader_file_cache_enabled() const
whether the shader file caches are enabled
bool current_material_is_textured
store flag to tell whether current material is textured
void push_bg_accum_color()
push a copy of the current background accumulation color onto the stack
virtual media::font::font_face_ptr get_current_font_face() const
return the currently enabled font face
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
std::stack< int > bg_stencil_stack
stack of background stencil values
virtual dmat4 get_projection_matrix() const =0
return homogeneous 4x4 projection matrix, which transforms from eye to clip space
void begin_attribute_less_rendering()
this function ensures that in core profile a dummy attribute array is bound, what is essential for at...
dmat4 get_modelview_projection_device_matrix() const
return matrix to transfrom from model to device coordinates, i.e. the product of modelview,...
std::stack< vec4 > bg_accum_color_stack
stack of background accumulation colors
virtual void set_cursor(int x, int y)
flush the output_stream and set a new cursor position given in opengl coordinates with (0,...
void pop_bg_accum_color()
pop the top of the current background accumulation color from the stack
virtual void set_bg_stencil(int s)
set a user defined background stencil value
virtual void put_cursor_coords(const vecn &p, int &x, int &y) const
transform point p in current world coordinates into opengl coordinates with (0,0) in lower left corne...
virtual void set_bg_accum_color(vec4 rgba)
set a user defined background color for the accumulation buffer
virtual void set_default_render_pass_flags(RenderPassFlags)
return the default render pass flags
float get_bg_depth() const
return the current depth value for clearing the background
const std::vector< window_transformation > & get_window_transformation_array() const
return the current window transformation array
virtual unsigned get_max_window_transformation_array_size() const =0
query the maximum number of supported window transformations, which is at least 1
int x_offset
offset in x and y direction where text starts
void put_bg_accum_color(float *rgba) const
copy the current accumulation background rgba color into the given float array
std::map< void *, std::pair< cgv::media::illum::light_source, light_source_status > > light_sources
map handle to light source and light source status information
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
int cursor_x
current cursor location for textual output
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
virtual void render_pass(RenderPass render_pass=RP_MAIN, RenderPassFlags render_pass_flags=RPF_ALL, void *user_data=0, int rp_idx=-1)
perform the given render task
bool remove_light_source(void *handle)
remove a light source by handle and whether it existed
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
void set_gamma(float _gamma)
set the current per channel gamma values to single value
virtual void enable_blending()
enable blending
virtual dmat4 get_modelview_matrix() const =0
return homogeneous 4x4 viewing matrix, which transforms from world to eye space
vec3 get_light_eye_spot_direction(const cgv::media::illum::light_source &light, bool place_now) const
helper function to place spot lights
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
virtual void draw_text(const std::string &text)
draw some text at cursor position and update cursor position
void pop_modelview_matrix()
see push_V for an explanation
virtual ~context()
virtual destructor
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
virtual void pop_pixel_coords()=0
pop previously pushed transformation matrices from modelview and projection stacks
bool at_line_begin
store whether we are at the beginning of the line
size_t get_nr_light_sources() const
return the number of light sources
void tesselate_unit_square(bool flip_normals=false, bool edges=false)
tesselate a unit square in the xy-plane with texture coordinates
bool auto_set_view_in_current_shader_program
whether to automatically set viewing matrixes in current shader program, defaults to true
bool debug_render_passes
whether to debug render passes
std::vector< void * > enabled_light_source_handles
keep track of enabled light source handles
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 mul_projection_matrix(const dmat4 &P)
multiply given matrix from right to current projection matrix
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
virtual void post_redraw()=0
the context will be redrawn when the system is idle again
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 push_bg_color()
push a copy of the current background color onto the stack
void * get_enabled_light_source_handle(size_t i) const
access to handle of i-th light source
void push_buffer_mask()
push a copy of the current buffer mask onto the stack saved attributes: depth mask,...
virtual void enable_phong_shading()
enable phong shading with the help of a shader (enabled by default)
void set_debug_render_passes(bool _debug)
set flag whether to debug render passes
cgv::media::font::font_face_ptr current_font_face
store current font
cgv::signal::callback_stream out_stream
use a callback stream to write text to the opengl context
std::stack< vec4 > bg_color_stack
stack of background colors
unsigned get_render_pass_recursion_depth() const
return current render pass recursion depth
std::stack< BlendState > blend_state_stack
stack of blend states
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
void set_context(context *_ctx)
set the current focus context, this should only be called by the context itself
virtual void finish_draw(context &)
this method is called when the current drawable is left in a tree traversal that calls the draw metho...
virtual void draw(context &)
overload to draw the content of this drawable
virtual void after_finish(context &)
this method is called in one pass over all drawables after finish frame
virtual void finish_frame(context &)
this method is called in one pass over all drawables after drawing
virtual bool init(context &)
this method is called after creation or recreation of the context, return whether all necessary funct...
base interface for framebuffer
frame_buffer_base()
initialize members
base interface for all render components
virtual bool is_created() const
return whether component has been created
const context * ctx_ptr
keep pointer to my context
render_component()
initialize members
void put_id_void(void *ptr) const
copy the rendering api specific id the component to the memory location of the given pointer.
base interface for shader programs
shader_program_base()
initializes members
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...
bool set_textured_material_uniform(const context &ctx, const std::string &name, const textured_material &material, bool generate_error=false)
set a uniform of type textured_material
bool set_light_uniform(const context &ctx, const std::string &name, const cgv::media::illum::light_source &light, bool generate_error=false)
set a uniform of type light source
int get_uniform_location(const context &ctx, const std::string &name) const
query location index of an uniform
bool set_material_uniform(const context &ctx, const std::string &name, const cgv::media::illum::surface_material &material, bool generate_error=false)
set a uniform of type material
texture_base(TextureType _tt=TT_UNDEF)
initialize members
class that extends obj_material with the management of textures
vertex_buffer_base()
initialize members
VertexBufferType type
buffer type defaults to VBT_VERTICES
VertexBufferUsage usage
usage defaults to VBU_STATIC_DRAW
defines a symmetric view with the following quantities:
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
void register_object(base_ptr object, const std::string &options)
register an object and send event to all current registration ref_listeners()
ComponentFormat
define standard formats, which should be used to avoid wrong assignment of component names
@ CF_D
color format with components B, G, R and A
RenderAPI
enumeration of rendering APIs which can be queried from the context
CullingMode
different culling modes
void register_context_factory(context_creation_function_type fp)
registration context creation functions
BlendFunction
different blend functions
std::ostream & operator<<(std::ostream &os, const type_descriptor &td)
operator to write textual description to stream
TextAlignment
different text alignments
std::string get_render_pass_name(RenderPass rp)
convert render pass type into string
TextureFilter
different texture filter
render_config_ptr get_render_config()
return a pointer to the current shader configuration
TextureWrap
different texture wrap modes
FrameBufferType
different frame buffer types which can be combined together with or
MaterialSide
different sides of a material
context * create_context(RenderAPI api, unsigned int w, unsigned int h, const std::string &title, bool show)
construct a context of the given size.
@ VBU_STATIC_DRAW
Modified once and used many times; Modified by the application, and used as the source for GL drawing...
TextureCubeSides
the six different sides of a cube
void tesselate_unit_dodecahedron_or_icosahedron(context &c, bool dual, bool flip_normals, bool edges)
render an icosahedron at a given center.
PrimitiveType
different primitive types
@ VBT_VERTICES
The buffer contains vertices and will be bound to GL_ARRAY_BUFFER.
RenderPass
Enumeration of different render passes, which can be queried from the context and used to specify a n...
TextureType
different texture types
RenderPassFlags
available flags that can be queried from the context and set for a new render pass
@ RPF_DRAWABLES_FINISH_FRAME
whether to call finish frame method of drawables
@ RPF_SET_LIGHTS
whether to define default lights
@ RPF_DRAWABLES_DRAW
whether to call draw and finish_draw methods of drawables
@ RPF_DRAWABLES_AFTER_FINISH
whether to call after finish method of drawables
@ RPF_DEFAULT
all flags set, defines default render pass
@ RPF_NONE
no frame initialization is performed
@ RPF_HANDLE_SCREEN_SHOT
whether to perform a screen shot if this was scheduled
@ RPF_DRAW_TEXTUAL_INFO
whether to draw textual information
CompareFunction
different comparison functions used for depth testing or texture comparisons
GPUVendorID
IDs for GPU vendors.
unsigned int get_type_size(TypeId tid)
function that returns the size of a type specified through TypeId
@ 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_FLT64
floating point type stored in 32 bits
std::string to_string(const std::string &v, unsigned int w, unsigned int p, bool)
specialization of conversion from string to strings
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::media::color< float, cgv::media::RGB > rgb
declare rgb color type with 32 bit components
cgv::math::fvec< int32_t, 2 > ivec2
declare type of 2d 32 bit integer vectors
cgv::math::fvec< bool, 4 > bvec4
declare type of 4d boolean vectors
cgv::math::fvec< float, 3 > vec3
declare type of 3d single precision floating point 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.
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.
status information of light sources
information necessary for a rendering pass
configuration object used to define context parameters that need to be set already at creation time
bool multi_sample_buffer
default: false
bool stencil_buffer
default: false
int version_minor
default: -1 ... minor version of maximum supported OpenGL version
int depth_bits
default: -1
bool double_buffer
default: true
int version_major
default: -1 ... major version of maximum supported OpenGL version
context_config()
construct config with default parameters
bool debug
default: false in release and true in debug version
bool forward_compatible
default: false
bool stereo_buffer
default: false
bool alpha_buffer
default: false
bool self_reflect(cgv::reflect::reflection_handler &srh)
reflect the shader_path member
bool core_profile
default: true
int stencil_bits
default: -1
int nr_multi_samples
default: -1
bool accumulation_buffer
default: false
int accumulation_bits
default: -1
bool depth_buffer
default: true
structure to store information on a shader program variable, i.e.
unsigned array_size
dimension of arrays
void compute_sizes(size_t &cnt, size_t &s, size_t &S) const
helper member function to compute counts and sizes
cgv::render::type_descriptor type_descr
type descriptor providing information on component and compositions (scalar, vector or matrix)
configuration object used to define render view creation parameters including error handling configur...
int window_width
default: 640
render_config()
construct config with default parameters
bool dialog_on_error
default: true (only in case a gui_driver, which supports this, is loaded)
bool self_reflect(cgv::reflect::reflection_handler &srh)
reflect the shader_path member
int fullscreen_monitor
default: -1 ... no fullscreen
int window_height
default: 480
bool abort_on_error
default: false
std::string get_type_name() const
return "render_config"
bool show_error_on_console
default: true
compact type description of data that can be sent to the context; convertible to int