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>
12#define SAFE_STACK_POP(STACK, WHERE) \
13if(STACK.size() == 1) error("context::" WHERE "() ... attempt to completely empty stack avoided."); \
20const int nr_backgrounds = 5;
21float background_colors[] = {
32 switch (
td.coordinate_type) {
39 switch (
td.element_type) {
40 case cgv::render::ElementType::ET_VALUE:
43 case cgv::render::ElementType::ET_VECTOR:
48 case cgv::render::ElementType::ET_MATRIX: type =
"mat";
break;
52 if (
td.nr_columns !=
td.nr_rows) {
64 if (
type_descr.element_type == cgv::render::ET_VECTOR)
66 if (
type_descr.element_type == cgv::render::ET_MATRIX)
78 os <<
V.type_descr <<
" " <<
V.name;
80 os <<
"[" <<
V.array_size <<
"]";
81 if (
V.program_location != -1)
82 os <<
" @" <<
V.program_location;
83 if (
V.current_value.empty())
88 V.compute_sizes(cnt, s, S);
91 for (
size_t j = 0;
j <
V.array_size; ++
j) {
96 for (
size_t k = 0; k < cnt; ++k) {
99 const void* value_ptr =
V.current_value.data() +
j * s;
100 switch (
V.type_descr.coordinate_type) {
111 if (
V.array_size > 1)
158 srh.reflect_member(
"debug",
debug) &&
192 return "render_config";
219 gpu_vendor = GPU_VENDOR_UNKNOWN;
253 projection_matrix_stack.push(cgv::math::identity4<double>());
256 wt.viewport =
ivec4(0, 0, 640, 480);
278 do_screen_shot =
false;
309 rc->last_error = message;
311 std::cerr << message << std::endl;
323 return gpu_capabilities;
331void context::init_render_pass()
336void context::draw_textual_info()
341void context::perform_screen_shot()
345void context::destruct_render_objects()
351void context::finish_render_pass()
369 error(
child->get_type_name()+
"::init(context&) failed");
502 error(
"context::enable_phong_shading() deprecated");
505void context::disable_phong_shading()
508 error(
"context::disable_phong_shading() deprecated");
513 error(
"context::enable_material(phong_material) deprecated");
518 error(
"context::disable_material(phong_material) deprecated");
520void context::enable_material(
const textured_material& mat,
MaterialSide ms,
float alpha)
522 error(
"context::enable_material(textured_material) deprecated");
570 dvec4 hL(
Le,
light.get_type() == cgv::media::illum::LT_DIRECTIONAL ? 0.0f : 1.0f);
573 if (
light.get_type() != cgv::media::illum::LT_DIRECTIONAL)
610 light_sources[handle] = std::pair<cgv::media::illum::light_source, light_source_status>(
626 if (iter->second.second.enabled) {
642 return iter->second.first;
649 return iter->second.second;
657 iter->second.first =
light;
661 if (iter->second.second.enabled)
672 prog.
set_uniform(*
this,
"inverse_modelview_matrix", cgv::math::inverse(
V));
685 NM = cgv::math::inverse(
NM);
691 prog.
set_uniform(*
this,
"inverse_projection_matrix", cgv::math::inverse(
P));
717 prog.
set_uniform(*
this,
prefix +
".spot_direction", iter->second.second.eye_spot_direction);
732 if (!prog.does_use_lights())
745 if (iter->second.second.enabled)
772 return iter->second.second.enabled;
781 if (iter->second.second.enabled)
783 iter->second.second.enabled =
true;
796 if (!iter->second.second.enabled)
798 iter->second.second.enabled =
false;
802 iter->second.second.light_source_index = -1;
827 "RP_OPAQUE_SURFACES",
828 "RP_TRANSPARENT_SURFACES",
889 if (
ri.pass_index != -1)
890 std::cout <<
":" <<
ri.pass_index;
891 std::cout <<
"> " << info << std::endl;
905 ri.user_data = user_data;
940 perform_screen_shot();
941 do_screen_shot =
false;
944 finish_render_pass();
952 unsigned int i,
j = 0;
953 for (
i = 0;
i<text.size(); ++
i) {
999 float y = (
float)cursor_y;
1002 cursor_y =
int(y + 0.5f);
1015 font_face->enable(
this, font_size);
1048 unsigned char*
dst =
dv1.get_ptr<
unsigned char>();
1049 for (
size_t i=0;
i<n; ++
i, ++
dst, ++
src)
1061 unsigned char*
dst = dv.
get_ptr<
unsigned char>();
1063 for (
size_t i=0;
i<n; ++
i, ++
dst)
1077 "repeat",
"clamp",
"clamp_to_edge",
"clamp_to_border",
"mirror_clamp",
1078 "mirror_clamp_to_edge",
"mirror_clamp_to_border"
1088 "undefined",
"Texture1D",
"Texture2D",
"Texture3D",
"CubeTexture"
1097 "x+",
"x-",
"y+",
"y-",
"z+",
"z-"
1106 "undef",
"points",
"lines",
"lines_adjacency",
"line_strip",
"line_strip_adjacency",
"line_loop",
1107 "triangles",
"triangles_adjacency",
"triangle_strip",
"triangle_strip_adjacency",
"triangle_fan",
1108 "quads",
"quad_strip",
"polygon",
"patches"
1119 "nearest_mipmap_nearest",
1120 "linear_mipmap_nearest",
1121 "nearest_mipmap_linear",
1122 "linear_mipmap_linear",
1129float black[4] = { 0, 0, 0, 1 };
1130float white[4] = { 1, 1, 1, 1 };
1131float gray[4] = { 0.25f, 0.25f, 0.25f, 1 };
1132float green[4] = { 0, 1, 0, 1 };
1133float brown[4] = { 0.3f, 0.1f, 0, 1 };
1134float dark_red[4] = { 0.4f, 0, 0, 1 };
1135float cyan[4] = { 0, 1, 1, 1 };
1136float yellow[4] = { 1, 1, 0, 1 };
1137float red[4] = { 1, 0, 0, 1 };
1138float blue[4] = { 0, 0, 1, 1 };
1140void compute_face_normals(
const float* vertices,
float* normals,
const int* vertex_indices,
int* normal_indices,
int nr_faces,
int face_degree)
1142 for (
int i = 0;
i < nr_faces; ++
i) {
1143 vec3& normal =
reinterpret_cast<vec3&
>(normals[3 *
i]);
1145 vec3 reference_pnt = *
reinterpret_cast<const vec3*
>(vertices + 3 * vertex_indices[face_degree*
i + face_degree - 1]);
1148 for (
int j = 0;
j < face_degree; ++
j) {
1154 for (
int j = 0;
j<face_degree; ++
j)
1155 normal_indices[face_degree*
i+
j] =
i;
1162 static float V[8*3] = {
1172 static float N[6*3] = {
1177 static const float ot =
float(1.0 / 3);
1178 static const float tt =
float(2.0 / 3);
1179 static float T[14*2] = {
1181 0.25f,0 , 0.25f,ot ,
1182 0.25f,tt , 0.25f,1 ,
1185 0.75f,ot , 0.75f,tt ,
1188 static int F[6*4] = {
1196 static int FN[6*4] = {
1201 static int FT[6*4] = {
1202 3,4,1,0 ,7,10,11,8 ,
1204 12,13,11,10 ,3,7,8,4
1215 static float N[6 * 3] = {
1220 static int F[6 * 4] = {
1228 static int FN[6 * 4] = {
1229 0, 0, 0, 0, 1, 1, 1, 1,
1230 2, 2, 2, 2, 3, 3, 3, 3,
1231 4, 4, 4, 4, 5, 5, 5, 5
1235 for (
unsigned i = 0;
i < 8; ++
i) {
1249 static const float V[6*3] = {
1257 static float a = 1.0f/
sqrt(5.0f);
1258 static float b = 2*a;
1259 static const float N[5*3] = {
1266 static const int FT[2*3] = { 0,1,2, 5,4,3 };
1267 static const int FQ[8] = { 4,1, 3,0, 5,2, 4,1};
1268 static const int FTN[2*3] = { 0,0,0, 1,1,1 };
1269 static const int FQN[8] = { 2,2, 2,2, 3,3, 4,4, };
1284 std::vector<float>
V;
V.reserve(3*(resolution+1));
1285 std::vector<float> N; N.reserve(3*(resolution+1));
1286 std::vector<float>
T;
T.reserve(2*(resolution+1));
1288 std::vector<int> F; F.resize(resolution+1);
1290 for (
i = 0;
i <= resolution; ++
i)
1293 float step =
float(2*M_PI/resolution);
1295 for (
i = 0;
i <= resolution; ++
i, phi += step) {
1296 float cp =
cos(phi);
1297 float sp =
sin(phi);
1301 T.push_back((
float)
i/resolution);
1316 std::vector<float>
V;
V.reserve(6*(resolution+1));
1317 std::vector<float> N; N.reserve(6*(resolution+1));
1318 std::vector<float>
T;
T.reserve(4*(resolution+1));
1320 std::vector<int> F; F.resize(2*resolution+2);
1322 for (
i = 0;
i <= 2*resolution+1; ++
i)
1325 static float a = 1.0f/
sqrt(5.0f);
1326 static float b = 2*a;
1327 float step =
float(2*M_PI/resolution);
1331 for (
int i = 0;
i <= resolution; ++
i, u +=
duv, phi += step) {
1332 float cp =
cos(phi);
1333 float sp =
sin(phi);
1360 std::vector<float>
V;
V.reserve(6*(resolution+1));
1361 std::vector<float> N; N.reserve(6*(resolution+1));
1362 std::vector<float>
T;
T.reserve(4*(resolution+1));
1364 std::vector<int> F; F.resize(2*(resolution+1));
1366 for (
i = 0;
i <= 2*resolution+1; ++
i)
1369 float step =
float(2*M_PI/resolution);
1373 for (
int i = 0;
i <= resolution; ++
i, u +=
duv, phi += step) {
1374 float cp =
cos(phi);
1375 float sp =
sin(phi);
1402 std::vector<float>
V;
V.resize(6*(resolution+1));
1403 std::vector<float> N; N.resize(6*(resolution+1));
1404 std::vector<float>
T;
T.resize(4*(resolution+1));
1405 std::vector<int> F; F.resize(2*(resolution+1));
1407 for (
int i = 0;
i <= resolution; ++
i) {
1411 float step =
float(2*M_PI/resolution);
1416 for (
i = 0;
i < resolution; ++
i, u +=
duv) {
1424 for (
int j = 0;
j <= resolution; ++
j,
theta += step, v +=
duv) {
1452 std::vector<float>
V;
V.resize(6*(resolution+1));
1453 std::vector<float> N; N.resize(6*(resolution+1));
1454 std::vector<float>
T;
T.resize(4*(resolution+1));
1455 std::vector<int> F; F.resize(2*(resolution+1));
1457 for (
int i = 0;
i <= resolution; ++
i) {
1461 float step =
float(M_PI/resolution);
1466 for (
i = 0;
i < resolution; ++
i, u +=
duv) {
1474 for (
int j = 0;
j <= resolution; ++
j,
theta += step, v +=
duv) {
1503 static const float a =
float(1.0/(2*
sqrt(3.0)));
1504 static const float b =
float(1.0/(3*
sqrt(3.0/2)));
1505 static const float V[4*3] = {
1511 static const int F[4*3] = {
1512 0,2,1,3,2,0,3,0,1,3,1,2
1515 static float N[4*3];
1518 compute_face_normals(
V, N, F,
FN, 4, 3);
1531 static float N[1*3] = {
1534 static float V[4*3] = {
1538 static float T[4*2] = {
1542 static int FN[1*4] = {
1545 static int F[1*4] = {
1558 static float N[8*3] = {
1559 -1,-1,+1, +1,-1,+1, -1,+1,+1, +1,+1,+1,
1560 -1,-1,-1, +1,-1,-1, -1,+1,-1, +1,+1,-1
1562 static float V[6*3] = {
1567 static int FN[8*3] = {
1577 static int F[8*3] = {
1596 static const float h = 0.4472135956f;
1597 static const float r = 0.8944271912f;
1598 static const float s =
float(M_PI/2.5);
1599 static const float o =
float(M_PI/5);
1600 static const float V[13*3] = {
1602 r*
sin(1*s),r*
cos(1*s),-h,
1603 r*
sin(2*s),r*
cos(2*s),-h,
1604 r*
sin(3*s),r*
cos(3*s),-h,
1605 r*
sin(4*s),r*
cos(4*s),-h,
1606 r*
sin(5*s),r*
cos(5*s),-h,
1607 r*
sin(1*s+o),r*
cos(1*s+o),h,
1608 r*
sin(2*s+o),r*
cos(2*s+o),h,
1609 r*
sin(3*s+o),r*
cos(3*s+o),h,
1610 r*
sin(4*s+o),r*
cos(4*s+o),h,
1611 r*
sin(5*s+o),r*
cos(5*s+o),h,
1615 static int F[20*3] = {
1616 0,1,2, 0,2,3, 0,3,4, 0,4,5, 0,5,1,
1617 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,
1618 11,6,10, 11,10,9, 11,9,8, 11,8,7, 11,7,6
1620 static int DF[12*5] = {
1634 static float N[20*3];
1635 static int FN[20*3];
1636 static int DFN[12*5] = {
1653 compute_face_normals(
V, N, F,
FN, 20, 3);
1706 if (prog.does_use_gamma())
1729 if (!prog.does_context_set_color())
1731 int clr_loc = prog.get_color_index();
1750 if (!prog.does_use_material())
1769 if (!prog.does_use_material())
1902 mask.red_flag = flags[0];
1903 mask.green_flag = flags[1];
1904 mask.blue_flag = flags[2];
1905 mask.alpha_flag = flags[3];
1933 SAFE_STACK_POP(projection_matrix_stack,
"pop_projection_matrix");
1954 if (!prog.does_use_view())
1962 projection_matrix_stack.top() =
P;
1971 if (!prog.does_use_view())
1986bool context::ensure_window_transformation_index(
int&
array_index)
1996 std::string message(
"context::ensure_window_transformation_index() ... attempt to resize window transformation array larger than maximum allowed size of ");
2009 if (!ensure_window_transformation_index(
array_index))
2016 if (!ensure_window_transformation_index(
array_index))
2030 std::string message(
"context::get_window_matrix() ... attempt to query window matrix with array index ");
2032 message +=
" out of range [0,";
2036 return cgv::math::identity4<double>();
2039 dmat4 M = cgv::math::identity4<double>();
2040 M(0, 0) = 0.5*
wt.viewport[2];
2041 M(0, 3) =
M(0, 0) +
wt.viewport[0];
2042 M(1, 1) = 0.5*
wt.viewport[3];
2043 M(1, 3) =
M(1, 1) +
wt.viewport[1];
2044 M(2, 2) = 0.5*(
wt.depth_range[1] -
wt.depth_range[0]);
2045 M(2, 3) =
M(2, 2) +
wt.depth_range[0];
2079 for (
unsigned int c = 0; c < p.
size(); ++c)
2086 error(
"context::put_cursor_coords() deprecated");
2096 static_cast<int>(
p4.x() /
p4.w()),
2097 static_cast<int>(
p4.y() /
p4.w())
2104 int x_offset,
int y_offset)
2112 case 0 : x -= (
int)(floor(w)*0.5f);
break;
2113 case 2 : x -= (
int)floor(w);
break;
2117 case 0 : y -= (
int)(floor(h)*0.3f);
break;
2118 case 4 : y -= (
int)(floor(h)*0.6f);
break;
2137 case 0:
cursor.x() -=
static_cast<int>(std::floor(w) * 0.5f);
break;
2138 case 2:
cursor.x() -=
static_cast<int>(std::floor(w));
break;
2142 case 0:
cursor.y() -=
static_cast<int>(std::floor(h) * 0.3f);
break;
2143 case 4:
cursor.y() -=
static_cast<int>(std::floor(h) * 0.6f);
break;
2166 std::cout <<
"tesselate_arrow not implemented in cgv::render::context" << std::endl;
2171 std::cout <<
"tesselate_arrow not implemented in cgv::render::context" << std::endl;
2176 std::cout <<
"draw_light_source not implemented in cgv::render::context" << std::endl;
2182 internal_format = 0;
2197 std::cerr <<
"no context set when render_component::put_id_void was called" << std::endl;
2203render_buffer_base::render_buffer_base()
2210 mag_filter = TF_LINEAR;
2211 min_filter = TF_LINEAR_MIPMAP_LINEAR;
2212 wrap_s = TW_CLAMP_TO_EDGE;
2213 wrap_t = TW_CLAMP_TO_EDGE;
2214 wrap_r = TW_CLAMP_TO_EDGE;
2217 border_color[0] = 1;
2218 border_color[1] = 1;
2219 border_color[2] = 1;
2220 border_color[3] = 1;
2222 compare_function = CF_LEQUAL;
2223 use_compare_function =
false;
2224 have_mipmaps =
false;
2227void shader_program_base::allow_context_to_set_color(
bool allow)
2229 context_sets_color =
allow;
2235 geometry_shader_input_type = PT_POINTS;
2236 geometry_shader_output_type = PT_POINTS;
2237 geometry_shader_output_count = 1;
2239 auto_detect_uniforms =
true;
2240 auto_detect_vertex_attributes =
true;
2243 uses_material =
false;
2244 uses_lights =
false;
2247 position_index = -1;
2250 context_sets_color =
true;
2251 texcoord_index = -1;
2255void shader_program_base::specify_standard_uniforms(
bool view,
bool material,
bool lights,
bool gamma)
2257 auto_detect_uniforms =
false;
2259 uses_material = material;
2264void shader_program_base::specify_standard_vertex_attribute_names(context& ctx,
bool color,
bool normal,
bool texcoord)
2266 auto_detect_vertex_attributes =
false;
2267 position_index = ctx.get_attribute_location(*
this,
"position");
2268 color_index =
color ? ctx.get_attribute_location(*
this,
"color") : -1;
2269 normal_index = normal ? ctx.get_attribute_location(*
this,
"normal") : -1;
2270 texcoord_index = texcoord ? ctx.get_attribute_location(*
this,
"texcoord") : -1;
2273void 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)
2275 auto_detect_vertex_attributes =
false;
2276 position_index = position.empty() ? -1 : ctx.get_attribute_location(*
this, position);
2277 color_index =
color.empty() ? -1 : ctx.get_attribute_location(*
this,
color);
2278 normal_index = normal.empty() ? -1 : ctx.get_attribute_location(*
this, normal);
2279 texcoord_index = texcoord.empty() ? -1 : ctx.get_attribute_location(*
this, texcoord);
2281bool context::shader_program_link(shader_program_base&
spb)
const
2283 if (
spb.handle == 0)
2285 if (
spb.auto_detect_vertex_attributes) {
2286 spb.position_index = get_attribute_location(
spb,
"position");
2287 spb.color_index = get_attribute_location(
spb,
"color");
2288 spb.normal_index = get_attribute_location(
spb,
"normal");
2289 spb.texcoord_index = get_attribute_location(
spb,
"texcoord");
2290 spb.auto_detect_vertex_attributes =
false;
2292 if (
spb.auto_detect_uniforms) {
2293 spb.uses_lights = get_uniform_location(
spb,
"light_sources[0].light_source_type") != -1;
2294 spb.uses_material = get_uniform_location(
spb,
"material.brdf_type") != -1;
2296 get_uniform_location(
spb,
"modelview_matrix") != -1 ||
2297 get_uniform_location(
spb,
"projection_matrix") != -1 ||
2298 get_uniform_location(
spb,
"inverse_projection_matrix") != -1 ||
2299 get_uniform_location(
spb,
"normal_matrix") != -1 ||
2300 get_uniform_location(
spb,
"inverse_modelview_matrix") != -1 ||
2301 get_uniform_location(
spb,
"inverse_normal_matrix") != -1;
2302 spb.uses_gamma = get_uniform_location(
spb,
"gamma3") != -1 || get_uniform_location(
spb,
"gamma") != -1;
2303 spb.auto_detect_uniforms =
false;
2308bool context::shader_program_enable(shader_program_base&
spb)
2310 if (
spb.is_enabled) {
2312 error(
"context::shader_program_enable() called with program that is currently active", &
spb);
2315 error(
"context::shader_program_enable() called with program that is recursively reactivated", &
spb);
2319 spb.is_enabled =
true;
2323bool context::shader_program_disable(shader_program_base&
spb)
2326 error(
"context::shader_program_disable() called with empty stack", &
spb);
2329 if (!
spb.is_enabled) {
2330 error(
"context::shader_program_disable() called with disabled program", &
spb);
2334 error(
"context::shader_program_disable() called with program that was not on top of shader program stack", &
spb);
2338 spb.is_enabled =
false;
2342bool context::shader_program_destruct(shader_program_base&
spb)
const
2344 if (
spb.is_enabled) {
2345 error(
"context::shader_program_destruct() on shader program that was still enabled", &
spb);
2369void context::shader_program_set_uniform_locations(shader_program_base&
spb)
const
2371 spb.uniform_locations.clear();
2390 if (aab.is_enabled) {
2391 error(
"context::attribute_array_binding_destruct() on array binding that was still enabled", &aab);
2416bool context::attribute_array_binding_enable(attribute_array_binding_base& aab)
2419 error(
"context::attribute_array_binding_enable() called in not created attribute array binding.", &aab);
2422 if (aab.is_enabled) {
2424 error(
"context::attribute_array_binding_enable() called with array binding that is currently active", &aab);
2427 error(
"context::attribute_array_binding_enable() called with array binding that is recursively reactivated", &aab);
2431 aab.is_enabled =
true;
2435bool context::attribute_array_binding_disable(attribute_array_binding_base& aab)
2438 error(
"context::attribute_array_binding_disable() called with empty stack", &aab);
2441 if (!aab.is_enabled) {
2442 error(
"context::attribute_array_binding_disable() called with disabled array binding", &aab);
2446 error(
"context::attribute_array_binding_disable() called with array binding that was not on top of array binding stack", &aab);
2450 aab.is_enabled =
false;
2467 depth_attached =
false;
2468 std::fill(attached, attached+16,
false);
2471void context::get_buffer_list(
frame_buffer_base&
fbb,
bool& depth_buffer, std::vector<int>& buffers,
int offset)
2473 if (
fbb.enabled_color_attachments.size() == 0) {
2474 for (
int i = 0;
i < 16; ++
i)
2475 if (
fbb.attached[
i])
2476 buffers.push_back(
i + offset);
2479 for (
int i = 0;
i < (
int)
fbb.enabled_color_attachments.size(); ++
i)
2480 if (
fbb.attached[
fbb.enabled_color_attachments[
i]])
2481 buffers.push_back(
fbb.enabled_color_attachments[
i]+offset);
2486bool context::frame_buffer_create(frame_buffer_base&
fbb)
const
2488 if (
fbb.width == -1)
2490 if (
fbb.height == -1)
2495bool context::frame_buffer_attach(frame_buffer_base&
fbb,
const render_buffer_base&
rb,
bool is_depth,
int i)
const
2497 if (
fbb.handle == 0) {
2498 error(
"gl_context::frame_buffer_attach: attempt to attach to frame buffer that is not created", &
fbb);
2501 if (
rb.handle == 0) {
2502 error(
"gl_context::frame_buffer_attach: attempt to attach empty render buffer", &
fbb);
2506 fbb.depth_attached =
true;
2508 fbb.attached[
i] =
true;
2513bool 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
2515 if (
fbb.handle == 0) {
2516 error(
"context::frame_buffer_attach: attempt to attach to frame buffer that is not created", &
fbb);
2519 if (t.handle == 0) {
2520 error(
"context::frame_buffer_attach: attempt to attach texture that is not created", &
fbb);
2524 fbb.depth_attached =
true;
2526 fbb.attached[
i] =
true;
2531bool context::frame_buffer_enable(frame_buffer_base&
fbb)
2533 if (
fbb.handle == 0) {
2534 error(
"context::frame_buffer_enable: attempt to enable not created frame buffer", &
fbb);
2537 if (
fbb.is_enabled) {
2539 error(
"context::frame_buffer_enable() called with frame buffer that is currently active", &
fbb);
2542 error(
"context::frame_buffer_enable() called with frame buffer that is recursively reactivated", &
fbb);
2546 fbb.is_enabled =
true;
2550bool context::frame_buffer_disable(frame_buffer_base&
fbb)
2553 error(
"gl_context::frame_buffer_disable called with empty stack", &
fbb);
2557 error(
"gl_context::frame_buffer_disable called with different frame buffer enabled", &
fbb);
2561 fbb.is_enabled =
false;
2565bool context::frame_buffer_destruct(frame_buffer_base&
fbb)
const
2567 if (
fbb.handle == 0) {
2568 error(
"context::frame_buffer_destruct: attempt to destruct not created frame buffer", &
fbb);
2571 if (
fbb.is_enabled) {
2572 error(
"context::frame_buffer_destruct() on frame buffer that was still enabled", &
fbb);
2578std::vector<context_creation_function_type>& ref_context_creation_functions()
2580 static std::vector<context_creation_function_type>
ccfs;
2587 ref_context_creation_functions().push_back(fp);
2590context_factory_registration::context_factory_registration(context_creation_function_type fp)
2599 unsigned int w,
unsigned int h,
2600 const std::string& title,
bool show)
2602 std::vector<context_creation_function_type>&
ccfs = ref_context_creation_functions();
2603 for (
unsigned i=0;
i<
ccfs.size(); ++
i) {
2610 std::cerr <<
"could not create context for given parameters" << std::endl;
2618#include <cgv/base/register.h>
2630#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
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
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 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
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
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