line.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2014 Google Inc. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "tango-gl/line.h"
18 
19 namespace tango_gl {
20 Line::Line(float line_width, GLenum render_mode) {
21  line_width_ = line_width;
22  render_mode_ = render_mode;
23 }
24 void Line::SetLineWidth(const float pixels) { line_width_ = pixels; }
25 void Line::Render(const glm::mat4& projection_mat,
26  const glm::mat4& view_mat) const {
27  glUseProgram(shader_program_);
28  glLineWidth(line_width_);
29  glm::mat4 model_mat = GetTransformationMatrix();
30  glm::mat4 mvp_mat = projection_mat * view_mat * model_mat;
32 
33  glUniform4f(uniform_color_, red_, green_, blue_, alpha_);
34 
35  glEnableVertexAttribArray(attrib_vertices_);
36  glVertexAttribPointer(attrib_vertices_, 3, GL_FLOAT, GL_FALSE,
37  sizeof(glm::vec3), &vec_vertices_[0]);
38  glDrawArrays(render_mode_, 0, vec_vertices_.size());
39 
40  glDisableVertexAttribArray(attrib_vertices_);
41  glUseProgram(0);
42 }
43 
44 } // namespace tango_gl
float line_width_
Definition: line.h:33
void SetLineWidth(const float pixels)
Definition: line.cpp:24
void Render(const glm::mat4 &projection_mat, const glm::mat4 &view_mat) const
Definition: line.cpp:25
glm::mat4 GetTransformationMatrix() const
Definition: transform.cpp:67
GLM_FUNC_DECL genType::value_type const * value_ptr(genType const &vec)
#define GL_FALSE
Definition: dummy.cpp:79
Line(float line_width, GLenum render_mode)
Definition: line.cpp:20
void glUniformMatrix4fv(GLuint, int, int, float *)
Definition: dummy.cpp:80
std::vector< glm::vec3 > vec_vertices_
Definition: line.h:34


rtabmap
Author(s): Mathieu Labbe
autogenerated on Mon Jan 23 2023 03:37:28