本文整理汇总了C++中operations类的典型用法代码示例。如果您正苦于以下问题:C++ operations类的具体用法?C++ operations怎么用?C++ operations使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了operations类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: program_source_file
namespace oglplus {
static constants GL;
static operations gl;
class erase_program
: public program
{
private:
program_source_file
_get_source(const example_params& params)
{
std::string path = params.get_resource_file_path(
example_resource_type::program_source,
cstr_ref("028_lighting-bg.oglpprog")
);
return program_source_file(cstr_ref(path));
}
public:
uniform_location projection;
erase_program(const example_params& params)
: program(build_program(_get_source(params)))
{
gl.use(*this);
gl.query_location(projection, *this, "Projection");
}
};
class lighting_program
: public program
{
public:
uniform_location projection, modelview;
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");
}
};
class lighting_example
: public example
{
private:
erase_program erase_prog;
lighting_program light_prog;
shapes::generator_wrapper<shapes::unit_sphere_gen, 1> background;
shapes::generator_wrapper<shapes::unit_torus_gen, 3> shape;
float shp_turns;
float cam_orbit;
float cam_turns;
float cam_pitch;
short cam_dist_dir;
short cam_turn_dir;
short cam_elev_dir;
void mod_bouncing(short& dir, float& val, float inc)
{
val += inc;
if(val > 1.f)
{
val = 1.f;
dir = -1;
}
if(val < 0.f)
{
val = 0.f;
dir = +1;
}
}
void mod_cam_orbit(float inc)
{
mod_bouncing(cam_dist_dir, cam_orbit, inc);
}
void mod_cam_turns(float inc)
{
cam_turns += inc;
cam_turn_dir = (inc > 0)?1:-1;
}
void mod_cam_pitch(float inc)
{
mod_bouncing(cam_elev_dir, cam_pitch, inc);
//.........这里部分代码省略.........
开发者ID:matus-chochlik,项目名称:oglplu2,代码行数:101,代码来源:028_lighting.cpp
示例2: _init
namespace oglplus {
static constants GL;
static operations gl;
class voronoi_program
: public program
{
private:
void _init(const program_source_file& prog_src)
{
for(span_size_t i=0, n=prog_src.shader_source_count(); i<n; ++i)
{
shader shdr(prog_src.shader_type(i));
shdr.source(prog_src.shader_source(i));
shdr.compile();
shdr.report_compile_error();
attach(shdr);
}
link();
report_link_error();
}
public:
uniform<GLfloat> offset_loc;
uniform<GLfloat> scale_loc;
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");
}
};
class random_texture
: public texture
{
private:
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());
}
public:
random_texture(const example_params& params)
{
std::string path = params.get_resource_file_path(
example_resource_type::texture,
cstr_ref("noise.256x256x3.oglptex")
);
init(texture_image_file(cstr_ref(path)));
}
};
class screen_shape
{
private:
buffer positions;
buffer coords;
public:
vertex_array vao;
screen_shape(const program& prog)
{
gl.bind(vao);
GLfloat position_data[4*2] = {
-1.0f, -1.0f,
-1.0f, 1.0f,
1.0f, -1.0f,
1.0f, 1.0f
};
gl.bind(GL.array_buffer, positions);
gl.buffer_data(GL.array_buffer, position_data, GL.static_draw);
vertex_attrib_location va_p;
gl.query_location(va_p, prog, "Position");
gl.vertex_array_attrib_pointer(
va_p,
2, GL.float_,
false, 0, nullptr
);
gl.enable_vertex_array_attrib(va_p);
GLfloat coord_data[4*2] = {
//.........这里部分代码省略.........
开发者ID:matus-chochlik,项目名称:oglplu2,代码行数:101,代码来源:014_voronoi.cpp
示例3: scale
example_texgen(void)
: scale(1.0f)
, aspect(1.0f)
{
gl.uniform(erg.scale_loc, scale, scale);
gl.disable(GL.depth_test);
}
开发者ID:matus-chochlik,项目名称:oglplu2,代码行数:7,代码来源:008_texgen.cpp
示例4: 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);
}
开发者ID:matus-chochlik,项目名称:oglplu2,代码行数:29,代码来源:028_lighting.cpp
示例5: 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);
}
开发者ID:matus-chochlik,项目名称:oglplu2,代码行数:8,代码来源:014_voronoi.cpp
示例6: 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");
}
开发者ID:matus-chochlik,项目名称:oglplu2,代码行数:57,代码来源:010_cube.cpp
示例7: 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());
}
开发者ID:matus-chochlik,项目名称:oglplu2,代码行数:12,代码来源:014_voronoi.cpp
示例8:
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");
}
开发者ID:matus-chochlik,项目名称:oglplu2,代码行数:13,代码来源:014_voronoi.cpp
示例9:
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");
}
开发者ID:matus-chochlik,项目名称:oglplu2,代码行数:13,代码来源:028_lighting.cpp
示例10: 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);
}
}
开发者ID:matus-chochlik,项目名称:oglplu2,代码行数:30,代码来源:014_voronoi.cpp
示例11: 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();
}
开发者ID:matus-chochlik,项目名称:oglplu2,代码行数:8,代码来源:008_texgen.cpp
示例12: 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);
}
开发者ID:matus-chochlik,项目名称:oglplu2,代码行数:9,代码来源:008_texgen.cpp
示例13: 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);
}
开发者ID:matus-chochlik,项目名称:oglplu2,代码行数:19,代码来源:028_lighting.cpp
示例14: 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);
}
}
开发者ID:matus-chochlik,项目名称:oglplu2,代码行数:11,代码来源:014_voronoi.cpp
示例15: 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);
}
开发者ID:matus-chochlik,项目名称:oglplu2,代码行数:23,代码来源:010_cube.cpp
示例16: 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);
}
开发者ID:matus-chochlik,项目名称:oglplu2,代码行数:15,代码来源:014_voronoi.cpp
示例17: 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);
}
}
开发者ID:matus-chochlik,项目名称:oglplu2,代码行数:17,代码来源:008_texgen.cpp
示例18: user_idle
void user_idle(const example_state_view& state)
override
{
if(state.user_idle_time() > seconds_(1))
{
const float s = value(state.frame_duration())*60;
const float dest_offset_x = -0.525929f;
const float dest_offset_y = -0.668547f;
const float c = 0.02f * s;
offset_x = c*dest_offset_x + (1-c)*offset_x;
offset_y = c*dest_offset_y + (1-c)*offset_y;
scale *= (1-0.01f*s);
if(scale < min_scale) scale = min_scale;
gl.uniform(offset_loc, offset_x, offset_y);
gl.uniform(scale_loc, scale*aspect, scale);
}
}
开发者ID:deranen,项目名称:oglplu2,代码行数:20,代码来源:011_mandelbrot.cpp
示例19: cube
example_recursive_cube(void)
: tex_side(512)
, rnd_tex(tex_side)
, cube(prog)
, current_buf(0)
, rad(0.0f)
{
gl.clear_color(0.8f, 0.8f, 0.8f, 0.0f);
gl.clear_depth(1.0f);
gl.enable(GL.depth_test);
gl.enable(GL.cull_face);
gl.cull_face(GL.back);
gl.front_face(GL.ccw);
}
开发者ID:matus-chochlik,项目名称:oglplu2,代码行数:15,代码来源:030_recursive_cube.cpp
示例20: render
void render(const example_state_view& state)
override
{
gl.use(erase_prog);
gl.disable(GL.depth_test);
background.use();
background.draw();
shp_turns += 0.1f*state.frame_duration().value();
gl.use(light_prog);
gl.uniform(
light_prog.modelview,
matrix_rotation_x(turns_(shp_turns)/1)*
matrix_rotation_y(turns_(shp_turns)/2)*
matrix_rotation_z(turns_(shp_turns)/3)
);
gl.clear(GL.depth_buffer_bit);
gl.enable(GL.depth_test);
shape.use();
shape.draw();
}
开发者ID:matus-chochlik,项目名称:oglplu2,代码行数:23,代码来源:028_lighting.cpp
注:本文中的operations类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论