本文整理汇总了C++中operations::bind方法的典型用法代码示例。如果您正苦于以下问题:C++ operations::bind方法的具体用法?C++ operations::bind怎么用?C++ operations::bind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类operations
的用法示例。
在下文中一共展示了operations::bind方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
rendered_textures(GLsizei tex_side)
{
for(GLuint i=0; i<2u; ++i)
{
texture_name tex = texs[i];
gl.active_texture(GL.texture0+i);
gl.bind(GL.texture_2d, tex);
gl.texture_min_filter(GL.texture_2d, GL.linear);
gl.texture_mag_filter(GL.texture_2d, GL.linear);
gl.texture_image_2d(
GL.texture_2d,
0,
GL.rgb,
tex_side, tex_side,
0,
GL.rgb,
GL.unsigned_byte,
const_memory_block()
);
renderbuffer_name rbo = rbos[i];
gl.bind(GL.renderbuffer, rbo);
gl.renderbuffer_storage(
GL.renderbuffer,
GL.depth_component,
tex_side, tex_side
);
framebuffer_name fbo = fbos[i];
gl.bind(GL.draw_framebuffer, fbo);
gl.framebuffer_texture_2d(
GL.draw_framebuffer,
GL.color_attachment0,
GL.texture_2d,
tex, 0
);
gl.framebuffer_renderbuffer(
GL.draw_framebuffer,
GL.depth_attachment,
GL.renderbuffer,
rbo
);
gl.viewport(tex_side, tex_side);
gl.clear(GL.color_buffer_bit);
}
gl.bind(GL.draw_framebuffer, default_framebuffer);
gl.bind(GL.renderbuffer, no_renderbuffer);
}
示例2: render
void render(const example_state_view& state)
override
{
rad += radians_(0.5f*state.frame_duration().value());
current_buf = (current_buf+1)%2;
gl.uniform(
prog.light_pos,
vec3(cos(rad)*4, sin(rad)*4, 8)
);
gl.uniform(
prog.modelview,
matrix_rotation_x(rad*1)*
matrix_rotation_y(rad*2)*
matrix_rotation_z(rad*3)
);
// draw into the texture
gl.bind(GL.draw_framebuffer, rnd_tex.fbos[current_buf]);
gl.viewport(tex_side, tex_side);
GLfloat s = 0.5f;
gl.uniform(
prog.projection,
oglplus::matrix_perspective(-s,+s, -s,+s, 1.0f, 5)*
oglplus::matrix_translation(0,0,-2)
);
gl.clear(GL.color_buffer_bit|GL.depth_buffer_bit);
gl.draw_arrays(GL.triangles, 0, 6 * 2 * 3);
// draw on screen
gl.bind(GL.draw_framebuffer, default_framebuffer);
gl.viewport(state.width(), state.height());
gl.uniform(prog.cube_tex, GLint(current_buf));
GLfloat h = 0.55f;
GLfloat w = h*state.aspect();
gl.uniform(
prog.projection,
oglplus::matrix_perspective(-w,+w, -h,+h, 1, 3)*
oglplus::matrix_translation(0,0,-2)
);
gl.clear(GL.color_buffer_bit|GL.depth_buffer_bit);
gl.draw_arrays(GL.triangles, 0, 6 * 2 * 3);
}
示例3:
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] = {
-1.0f, -1.0f,
-1.0f, 1.0f,
1.0f, -1.0f,
1.0f, 1.0f
};
gl.bind(GL.array_buffer, coords);
gl.buffer_data(GL.array_buffer, coord_data, GL.static_draw);
vertex_attrib_location va_c;
gl.query_location(va_c, prog, "TexCoord");
gl.vertex_array_attrib_pointer(
va_c,
2, GL.float_,
false, 0, nullptr
);
gl.enable_vertex_array_attrib(va_c);
}
示例4: 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());
}
示例5: vs
example_mandelbrot(void)
: offset_x(-0.5f)
, offset_y(0.0f)
, scale(1.0f)
, aspect(1.0f)
{
shader vs(GL.vertex_shader);
vs.source(glsl_literal(
"#version 130\n"
"uniform vec2 Offset;\n"
"uniform vec2 Scale;\n"
"in vec2 Position;\n"
"in vec2 Coord;\n"
"out vec2 vertCoord;\n"
"void main(void)\n"
"{\n"
" vertCoord = Coord*Scale+Offset;\n"
" gl_Position = vec4(Position, 0.0, 1.0);\n"
"}\n"
));
vs.compile();
shader fs(GL.fragment_shader);
fs.source(glsl_literal(
"#version 130\n"
"uniform sampler1D gradient;\n"
"in vec2 vertCoord;\n"
"out vec4 fragColor;\n"
"void main(void)\n"
"{\n"
" vec2 z = vec2(0.0, 0.0);\n"
" vec2 c = vertCoord;\n"
" int i = 0, max = 256;\n"
" while((i != max) && (distance(z, c) < 2.0))\n"
" {\n"
" vec2 zn = vec2(\n"
" z.x * z.x - z.y * z.y + c.x,\n"
" 2.0 * z.x * z.y + c.y\n"
" );\n"
" z = zn;\n"
" ++i;\n"
" }\n"
" float a = float(i)/float(max);\n"
" fragColor = texture(gradient, a+sqrt(length(c))*0.1);\n"
"} \n"
));
fs.compile();
prog.attach(vs);
prog.attach(fs);
prog.link();
gl.use(prog);
gl.query_location(offset_loc, prog, "Offset");
gl.query_location(scale_loc, prog, "Scale");
gl.uniform(offset_loc, offset_x, offset_y);
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] = {
-1.0f, -1.0f,
-1.0f, 1.0f,
1.0f, -1.0f,
1.0f, 1.0f
};
gl.bind(GL.array_buffer, coords);
gl.buffer_data(GL.array_buffer, coord_data, GL.static_draw);
vertex_attrib_location va_c;
gl.query_location(va_c, prog, "Coord");
gl.vertex_array_attrib_pointer(
va_c,
2, GL.float_,
false, 0, nullptr
);
gl.enable_vertex_array_attrib(va_c);
//.........这里部分代码省略.........