本文整理汇总了C++中operations类的典型用法代码示例。如果您正苦于以下问题:C++ operations类的具体用法?C++ operations怎么用?C++ operations使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了operations类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: scale
example_texgen(void)
: scale(1.0f)
, aspect(1.0f)
{
gl.uniform(erg.scale_loc, scale, scale);
gl.disable(GL.depth_test);
}
示例2: background
lighting_example(
const example_params& params,
const example_state_view& state,
eagine::memory::buffer& temp_buffer
): erase_prog(params)
, light_prog(params)
, background(
temp_buffer,
(shapes::vertex_attrib_kind::position |0),
36, 72
), shape(
temp_buffer,
(shapes::vertex_attrib_kind::position |0)+
(shapes::vertex_attrib_kind::normal |1)+
(shapes::vertex_attrib_kind::wrap_coord|2),
96, 144
), shp_turns(0.0f)
, cam_orbit(0.0f)
, cam_turns(0.0f)
, cam_pitch(0.5f)
, cam_dist_dir(-1)
, cam_turn_dir(1)
, cam_elev_dir(1)
{
gl.clear_depth(1);
gl.disable(GL.cull_face);
set_projection(state);
}
示例3: resize
void resize(const example_state_view& state)
override
{
gl.viewport(state.width(), state.height());
aspect = state.aspect();
gl.uniform(prog.scale_loc, scale*aspect, scale);
}
示例4: vs
example_program(void)
{
shader vs(GL.vertex_shader);
vs.source(glsl_literal(
"#version 140\n"
"uniform mat4 Projection;\n"
"in vec4 Position;\n"
"in vec3 Normal;\n"
"in vec3 BoxCoord;\n"
"in vec3 TexCoord;\n"
"out vec2 vertCoord;\n"
"out vec3 vertColor1;\n"
"out vec3 vertColor2;\n"
"void main(void)\n"
"{\n"
" gl_Position = Projection*Position;\n"
" vertColor1 = mix(BoxCoord,abs(Normal),0.5);\n"
" vertColor2 = vertColor1 * 0.3;\n"
" vertCoord = TexCoord.xy*(2+TexCoord.z);\n"
"}\n"
));
vs.compile();
shader fs(GL.fragment_shader);
fs.source(glsl_literal(
"#version 140\n"
"in vec2 vertCoord;\n"
"in vec3 vertColor1;\n"
"in vec3 vertColor2;\n"
"out vec3 fragColor;\n"
"float pattern(vec2 tc)\n"
"{\n"
" return float((int(tc.x)%2+int(tc.y)%2)%2);\n"
"}\n"
"void main(void)\n"
"{\n"
" float c = pattern(vertCoord);\n"
" fragColor = mix(vertColor1, vertColor2, c);\n"
"}\n"
));
fs.compile();
attach(vs);
attach(fs);
link();
report_link_error();
gl.use(*this);
gl.query_location(projection, *this, "Projection");
}
示例5: init
void init(const texture_image_file& image_data)
{
gl.bind(GL.texture_2d, *this);
gl.texture_min_filter(GL.texture_2d, GL.nearest);
gl.texture_mag_filter(GL.texture_2d, GL.nearest);
gl.texture_wrap(
GL.texture_2d,
GL.texture_wrap_s,
GL.repeat
);
gl.texture_image_2d(GL.texture_2d, image_data.spec());
}
示例6:
voronoi_program(const example_params& params)
{
std::string path = params.get_resource_file_path(
example_resource_type::program_source,
cstr_ref("014_voronoi.oglpprog")
);
_init(program_source_file(cstr_ref(path)));
gl.use(*this);
gl.query_location(offset_loc, *this, "Offset");
gl.query_location(scale_loc, *this, "Scale");
}
示例7:
lighting_program(const example_params& params)
{
std::string path = params.get_resource_file_path(
example_resource_type::program_source,
cstr_ref("028_lighting-lt.oglpprog")
);
build_program(*this, program_source_file(cstr_ref(path)));
gl.use(*this);
gl.query_location(projection, *this, "Projection");
gl.query_location(modelview, *this, "Modelview");
}
示例8: user_idle
void user_idle(const example_state_view& state)
override
{
if(state.user_idle_time() > seconds_(1))
{
const float t = value(state.frame_duration())*60;
scale *= std::pow(1.f+0.05f*t, scale_dir);
if(scale < min_scale)
{
scale_dir *= -1.f;
ofs_x_dir *= -1.f;
ofs_y_dir *= ofs_x_dir;
scale = min_scale;
}
if(scale > max_scale)
{
scale_dir *= -1.f;
ofs_y_dir *= -1.f;
ofs_x_dir *= ofs_y_dir;
scale = max_scale;
}
offset_x += ofs_x_dir*t*scale/30;
offset_y += ofs_y_dir*t*scale/30;
gl.uniform(prog.offset_loc, offset_x, offset_y);
gl.uniform(prog.scale_loc, scale*aspect, scale);
}
}
示例9: resize
void resize(const example_state_view& state)
override
{
gl.viewport(0, 0, state.width(), state.height());
erg.set_dimensions(state.width(), state.height());
aspect = state.aspect();
}
示例10: pointer_scrolling
void pointer_scrolling(const example_state_view& state)
override
{
scale *= float(std::pow(2,-state.norm_delta_pointer_z()));
if(scale < min_scale) scale = min_scale;
if(scale > max_scale) scale = max_scale;
gl.uniform(erg.scale_loc, scale*aspect, scale);
}
示例11: set_projection
void set_projection(const example_state_view& state)
{
auto projection =
matrix_perspective::y(
right_angle_(),
state.aspect(),
0.5f, 50.f
)*matrix_orbiting_y_up(
vec3(),
smooth_lerp(1.5f, 5.0f, cam_orbit),
turns_(cam_turns),
smooth_oscillate(radians_(1.5f), cam_pitch)
);
gl.use(light_prog);
gl.uniform(light_prog.projection, projection);
gl.use(erase_prog);
gl.uniform(erase_prog.projection, projection);
}
示例12: pointer_motion
void pointer_motion(const example_state_view& state)
override
{
if(state.pointer_dragging())
{
offset_x -= 2*state.norm_delta_pointer_x()*scale;
offset_y -= 2*state.norm_delta_pointer_y()*scale;
gl.uniform(prog.offset_loc, offset_x, offset_y);
}
}
示例13: prog
cube_example(
const example_state_view& state,
eagine::memory::buffer& temp_buffer
): prog()
, cube(
temp_buffer,
shapes::vertex_attrib_kind::position+
shapes::vertex_attrib_kind::normal+
shapes::vertex_attrib_kind::box_coord+
shapes::vertex_attrib_kind::face_coord
), cam_orbit(0.5)
, cam_turns(0.12f)
, cam_pitch(0.72f)
, cam_dist_dir(-1)
, cam_turn_dir(1)
, cam_elev_dir(1)
{
gl.clear_color(0.6f, 0.6f, 0.5f, 0);
gl.clear_depth(1);
gl.enable(GL.depth_test);
set_projection(state);
}
示例14: tex
example_voronoi(const example_params& params)
: tex(params)
, prog(params)
, screen(prog)
, ofs_x_dir(1.f)
, ofs_y_dir(1.f)
, offset_x(-0.5f)
, offset_y(0.0f)
, scale_dir(1.f)
, scale(10.0f)
, aspect(1.0f)
{
gl.disable(GL.depth_test);
}
示例15: user_idle
void user_idle(const example_state_view& state)
override
{
if(state.user_idle_time() > seconds_(1))
{
using namespace eagine::math;
float new_sc = float(smooth_lerp(
min_scale,
max_scale,
value(state.exec_time())*0.4f
));
scale = interpolate_linear(new_sc, scale, 0.9f);
gl.uniform(erg.scale_loc, scale, scale);
}
}