line.cpp
Go to the documentation of this file.
00001 /*
00002  * Copyright 2014 Google Inc. All Rights Reserved.
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *      http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
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 }  // namespace tango_gl


rtabmap
Author(s): Mathieu Labbe
autogenerated on Thu Jun 6 2019 21:59:20