Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "tango-gl/line.h"
00018
00019 namespace tango_gl {
00020 Line::Line(float line_width, GLenum render_mode) {
00021 line_width_ = line_width;
00022 render_mode_ = render_mode;
00023 }
00024 void Line::SetLineWidth(const float pixels) { line_width_ = pixels; }
00025 void Line::Render(const glm::mat4& projection_mat,
00026 const glm::mat4& view_mat) const {
00027 glUseProgram(shader_program_);
00028 glLineWidth(line_width_);
00029 glm::mat4 model_mat = GetTransformationMatrix();
00030 glm::mat4 mvp_mat = projection_mat * view_mat * model_mat;
00031 glUniformMatrix4fv(uniform_mvp_mat_, 1, GL_FALSE, glm::value_ptr(mvp_mat));
00032
00033 glUniform4f(uniform_color_, red_, green_, blue_, alpha_);
00034
00035 glEnableVertexAttribArray(attrib_vertices_);
00036 glVertexAttribPointer(attrib_vertices_, 3, GL_FLOAT, GL_FALSE,
00037 sizeof(glm::vec3), &vec_vertices_[0]);
00038 glDrawArrays(render_mode_, 0, vec_vertices_.size());
00039
00040 glDisableVertexAttribArray(attrib_vertices_);
00041 glUseProgram(0);
00042 }
00043
00044 }