Copyright Matus Chochlik. Distributed under the Boost Software License, Version 1.0. See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
#include "resources.hpp"
void cel_program::init(execution_context& ec, video_context& vc) {
auto& gl = vc.gl_api();
gl.create_program() >> prog;
gl.build_program(prog, prog_src.unpack(ec));
gl.use_program(prog);
gl.get_uniform_location(prog, "Projection") >> projection_loc;
gl.get_uniform_location(prog, "Modelview") >> modelview_loc;
}
void cel_program::clean_up(video_context& vc) {
auto& gl = vc.gl_api();
gl.delete_program(std::move(prog));
}
void cel_program::set_projection(video_context& vc, orbiting_camera& camera) {
if(camera.has_changed()) {
vc.gl_api().set_uniform(prog, projection_loc, camera.matrix(vc));
}
}
void cel_program::set_modelview(execution_context& ec, video_context& vc) {
shp_turns += 0.1F * ec.state().frame_duration().value();
vc.gl_api().set_uniform(
prog,
modelview_loc,
}
void cel_program::bind_position_location(
video_context& vc,
vc.gl_api().bind_attrib_location(prog, loc, "Position");
}
void icosahedron_geometry::init(execution_context& ec, video_context& vc) {
const auto& glapi = vc.gl_api();
const auto& gl = glapi;
oglp::shape_generator shape(
ops.resize(
std_size(shape.operation_count()));
shape.instructions(glapi,
cover(ops));
gl.gen_vertex_arrays() >> vao;
gl.bind_vertex_array(vao);
gl.gen_buffers() >> positions;
shape.attrib_setup(
glapi,
vao,
positions,
position_loc(),
ec.buffer());
gl.gen_buffers() >> indices;
shape.index_setup(glapi, indices, ec.buffer());
}
void icosahedron_geometry::clean_up(video_context& vc) {
auto& gl = vc.gl_api();
gl.delete_buffers(std::move(indices));
gl.delete_buffers(std::move(positions));
gl.delete_vertex_arrays(std::move(vao));
}
void icosahedron_geometry::draw(video_context& vc) {
}
}