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
tango_gl::DrawableObject::alpha_
float alpha_
Definition: drawable_object.h:50
tango_gl::DrawableObject::attrib_vertices_
GLuint attrib_vertices_
Definition: drawable_object.h:59
tango_gl::DrawableObject::red_
float red_
Definition: drawable_object.h:47
tango_gl::Line::SetLineWidth
void SetLineWidth(const float pixels)
Definition: line.cpp:24
tango_gl::Line::Render
void Render(const glm::mat4 &projection_mat, const glm::mat4 &view_mat) const
Definition: line.cpp:25
glm::value_ptr
GLM_FUNC_DECL const genType::value_type * value_ptr(genType const &vec)
tango_gl::DrawableObject::blue_
float blue_
Definition: drawable_object.h:49
glm::detail::tvec3
Definition: type_mat.hpp:37
glm::detail::tmat4x4
Definition: type_mat.hpp:47
tango_gl::DrawableObject::green_
float green_
Definition: drawable_object.h:48
tango_gl::DrawableObject::render_mode_
GLenum render_mode_
Definition: drawable_object.h:55
line.h
GL_FALSE
#define GL_FALSE
Definition: dummy.cpp:79
tango_gl::DrawableObject::uniform_color_
GLuint uniform_color_
Definition: drawable_object.h:57
tango_gl::Line::Line
Line(float line_width, GLenum render_mode)
Definition: line.cpp:20
tango_gl::DrawableObject::uniform_mvp_mat_
GLuint uniform_mvp_mat_
Definition: drawable_object.h:58
glUniformMatrix4fv
void glUniformMatrix4fv(GLuint, int, int, float *)
Definition: dummy.cpp:80
tango_gl
Definition: axis.cpp:20
tango_gl::Line::vec_vertices_
std::vector< glm::vec3 > vec_vertices_
Definition: line.h:34
tango_gl::DrawableObject::shader_program_
GLuint shader_program_
Definition: drawable_object.h:56
tango_gl::Transform::GetTransformationMatrix
glm::mat4 GetTransformationMatrix() const
Definition: transform.cpp:67
tango_gl::Line::line_width_
float line_width_
Definition: line.h:33


rtabmap
Author(s): Mathieu Labbe
autogenerated on Thu Jul 25 2024 02:50:11