本文整理汇总了C++中Shared::binding方法的典型用法代码示例。如果您正苦于以下问题:C++ Shared::binding方法的具体用法?C++ Shared::binding怎么用?C++ Shared::binding使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shared
的用法示例。
在下文中一共展示了Shared::binding方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: render_frame_for_time
void LightingScene::render_frame_for_time (TimeT time) {
Scene::render_frame_for_time(time);
_trail_particles->update(time);
for (std::size_t i = 0; i < 3; i += 1) {
_flowing_lights[i].update();
_light_positions[i] = _flowing_lights[i].position << 1.0;
if (_flowing_lights[i].history.size() > 1) {
// Add some particle effects
_trail_particles->add(_flowing_lights[i].end_segment(), _light_colors[i].reduce());
}
}
_rotation += 0.01;
/// Dequeue any button/motion/resize events and process them now (in this thread).
manager()->process_pending_events(this);
check_graphics_error();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
{
check_graphics_error();
auto binding = _textured_program->binding();
_renderer_state->texture_manager->bind(0, _crate_texture);
Mat44 modelview_matrix = Mat44::rotating_matrix_around_z(_rotation);
//modelview_matrix = modelview_matrix * _viewport->display_matrix();
modelview_matrix = _viewport->display_matrix() * modelview_matrix;
GLuint display_matrix_uniform = _textured_program->uniform_location("display_matrix");
binding.set_uniform("light_colors", _light_colors);
binding.set_uniform(_light_positions_uniform, _light_positions);
check_graphics_error();
//Vec2 p(0.5 * Math::sin(time), 0.5 * Math::cos(time));
binding.set_uniform(_position_uniform, _point);
check_graphics_error();
// Draw the various objects to the screen:
binding.set_uniform(display_matrix_uniform, _viewport->display_matrix());
_grid_mesh_buffer->draw();
binding.set_uniform(display_matrix_uniform, modelview_matrix);
_object_mesh_buffer->draw();
check_graphics_error();
}
{
auto binding = _solid_program->binding();
binding.set_uniform("display_matrix", _viewport->display_matrix());
for (std::size_t i = 0; i < 3; i += 1) {
binding.set_uniform("light_position", _light_positions[i]);
binding.set_uniform("light_color", _light_colors[i]);
auto array_binding = _flowing_array->binding();
array_binding.attach(*_flowing_buffer);
auto buffer_binding = _flowing_buffer->binding<Vec3>();
buffer_binding.set_data(_flowing_lights[i].history);
array_binding.draw_arrays(GL_LINE_STRIP, 0, (GLsizei)_flowing_lights[i].history.size());
check_graphics_error();
}
}
{
auto binding = _wireframe_program->binding();
binding.set_uniform("display_matrix", _viewport->display_matrix());
binding.set_uniform("major_color", Vec4(1.0, 0.0, 0.0, 1.0));
AlignedBox3 xbox = AlignedBox3::from_center_and_size(Vec3(15.0, 0.0, 0.0), 1.0);
_wireframe_renderer->render(xbox);
binding.set_uniform("major_color", Vec4(0.0, 1.0, 0.0, 1.0));
AlignedBox3 ybox = AlignedBox3::from_center_and_size(Vec3(0.0, 15.0, 0.0), 1.0);
_wireframe_renderer->render(ybox);
binding.set_uniform("major_color", Vec4(0.0, 0.0, 1.0, 1.0));
AlignedBox3 zbox = AlignedBox3::from_center_and_size(Vec3(0.0, 0.0, 15.0), 1.0);
_wireframe_renderer->render(zbox);
}
{
glDepthMask(GL_FALSE);
//.........这里部分代码省略.........
示例2: will_become_current
void LightingScene::will_become_current(ISceneManager * manager)
{
Scene::will_become_current(manager);
glEnable(GL_DEPTH_TEST);
//glEnable(GL_CULL_FACE);
//glCullFace(GL_BACK);
check_graphics_error();
_camera = new BirdsEyeCamera;
_camera->set_distance(10);
_camera->set_multiplier(Vec3(0.1, 0.1, 0.01));
_projection = new PerspectiveProjection(R90 * 0.7, 1, 1024 * 12);
_viewport = new Viewport(_camera, _projection);
_viewport->set_bounds(AlignedBox<2>(ZERO, manager->display_context()->size()));
_point.zero();
_light_positions[0].zero();
_light_positions[1].zero();
_light_positions[2].zero();
_rotation = 0.0;
_light_colors[0] = Vec4(2.0, 0.8, 0.4, 0.0);
_light_colors[1] = Vec4(0.4, 0.8, 2.0, 0.0);
_light_colors[2] = Vec4(0.4, 2.0, 0.8, 0.0);
//_light_colors[0] = Vec4(1.2, 0.2, 0.2, 0.0);
//_light_colors[1] = Vec4(0.2, 0.2, 1.2, 0.0);
//_light_colors[2] = Vec4(0.2, 1.2, 0.2, 0.0);
_renderer_state = new RendererState;
_renderer_state->shader_manager = new ShaderManager;
_renderer_state->texture_manager = new TextureManager;
_renderer_state->resource_loader = this->resource_loader();
{
_crate_texture = _renderer_state->load_texture(TextureParameters::LINEAR, "Textures/Checkers");
_particle_texture = _renderer_state->load_texture(TextureParameters::LINEAR, "Textures/Trail");
}
check_graphics_error();
{
_pixel_buffer_renderer = new PixelBufferRenderer(_renderer_state->texture_manager);
}
{
_solid_program = _renderer_state->load_program("Shaders/solid");
}
{
_wireframe_program = _renderer_state->load_program("Shaders/wireframe");
_wireframe_program->set_attribute_location("position", WireframeRenderer::POSITION);
_wireframe_program->link();
_wireframe_renderer = new WireframeRenderer;
}
{
_particle_program = _renderer_state->load_program("Shaders/particle");
_particle_program->set_attribute_location("position", TrailParticles::POSITION);
_particle_program->set_attribute_location("offset", TrailParticles::OFFSET);
_particle_program->set_attribute_location("mapping", TrailParticles::MAPPING);
_particle_program->set_attribute_location("color", TrailParticles::COLOR);
_particle_program->link();
auto binding = _particle_program->binding();
binding.set_texture_unit("diffuse_texture", 0);
_trail_particles = new TrailParticles;
}
{
// Setup the buffer for drawing the light trails.
_flowing_array = new VertexArray;
_flowing_buffer = new VertexBuffer<BasicVertex<Vec3>>;
auto binding = _flowing_array->binding();
auto attributes = binding.attach(*_flowing_buffer);
attributes[0] = &BasicVertex<Vec3>::element;
check_graphics_error();
}
{
_flat_program = _renderer_state->load_program("Shaders/flat");
_flat_program->set_attribute_location("position", 0);
_flat_program->set_attribute_location("mapping", 1);
_flat_program->link();
auto binding = _flat_program->binding();
binding.set_texture_unit("diffuse_texture", 0);
check_graphics_error();
}
{
//.........这里部分代码省略.........