drawable_object.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/drawable_object.h"
00018 #include "tango-gl/shaders.h"
00019 
00020 namespace tango_gl {
00021 
00022 void DrawableObject::SetShader() {
00023   shader_program_ =
00024       util::CreateProgram(shaders::GetBasicVertexShader().c_str(),
00025                           shaders::GetBasicFragmentShader().c_str());
00026   if (!shader_program_) {
00027     LOGE("Could not create program.");
00028   }
00029   uniform_mvp_mat_ = glGetUniformLocation(shader_program_, "mvp");
00030   attrib_vertices_ = glGetAttribLocation(shader_program_, "vertex");
00031   uniform_color_ = glGetUniformLocation(shader_program_, "color");
00032 }
00033 
00034 void DrawableObject::DeleteGlResources() {
00035   if (shader_program_) {
00036     glDeleteShader(shader_program_);
00037   }
00038 }
00039 
00040 void DrawableObject::SetColor(float red, float green, float blue) {
00041   red_ = red;
00042   green_ = green;
00043   blue_ = blue;
00044 }
00045 void DrawableObject::SetColor(const Color& color) {
00046   SetColor(color.r, color.g, color.b);
00047 }
00048 
00049 void DrawableObject::SetAlpha(const float alpha) { alpha_ = alpha; }
00050 
00051 void DrawableObject::SetVertices(const std::vector<GLfloat>& vertices) {
00052   vertices_ = vertices;
00053 }
00054 
00055 void DrawableObject::SetVertices(const std::vector<GLfloat>& vertices,
00056                                  const std::vector<GLushort>& indices) {
00057   vertices_ = vertices;
00058   indices_ = indices;
00059 }
00060 
00061 void DrawableObject::SetVertices(const std::vector<GLfloat>& vertices,
00062                                  const std::vector<GLfloat>& normals) {
00063   vertices_ = vertices;
00064   normals_ = normals;
00065 }
00066 }  // namespace tango_gl


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