34 #include <GLES2/gl2.h> 38 const std::map<int, rtabmap::Transform> & poses,
39 const std::multimap<int, rtabmap::Link> & links) :
44 shader_program_(shaderProgram)
53 std::vector<float>
vertices = std::vector<float>(poses.size()*3);
55 std::map<int, int> idsToIndices;
56 for(std::map<int, rtabmap::Transform>::const_iterator iter=poses.begin(); iter!=poses.end(); ++iter)
58 vertices[i*3] = iter->second.x();
59 vertices[i*3+1] = iter->second.y();
60 vertices[i*3+2] = iter->second.z();
61 idsToIndices.insert(std::make_pair(iter->first, i));
66 glBufferData(GL_ARRAY_BUFFER,
sizeof(GLfloat) * (
int)vertices.size(), (
const void *)vertices.data(), GL_STATIC_DRAW);
67 glBindBuffer(GL_ARRAY_BUFFER, 0);
69 GLint error = glGetError();
70 if(error != GL_NO_ERROR)
72 LOGI(
"OpenGL: Could not allocate point cloud (0x%x)\n", error);
80 int oiLoopClosures = 0;
81 for(std::multimap<int, rtabmap::Link>::const_iterator iter=links.begin(); iter!=links.end(); ++iter)
83 std::map<int, int>::const_iterator jterFrom = idsToIndices.find(iter->second.from());
84 std::map<int, int>::const_iterator jterTo = idsToIndices.find(iter->second.to());
85 if(jterFrom != idsToIndices.end() && jterTo != idsToIndices.end())
136 GLint attribute_vertex = glGetAttribLocation(
shader_program_,
"vertex");
138 glEnableVertexAttribArray(attribute_vertex);
140 glVertexAttribPointer(attribute_vertex, 3, GL_FLOAT,
GL_FALSE, 3*
sizeof(GLfloat), 0);
144 glUniform3f(color_handle, 1.0
f, 0.0
f, 0.0
f);
149 glUniform3f(color_handle, 0.0
f, 0.0
f, 1.0
f);
153 glDisableVertexAttribArray(0);
154 glBindBuffer(GL_ARRAY_BUFFER, 0);
void Render(const glm::mat4 &projectionMatrix, const glm::mat4 &viewMatrix)
void setPose(const rtabmap::Transform &mapToOdom)
std::vector< GLushort > loopClosureIndices_
static const float vertices[]
glm::mat4 glmFromTransform(const rtabmap::Transform &transform)
GLM_FUNC_DECL genType::value_type const * value_ptr(genType const &vec)
#define UASSERT(condition)
GraphDrawable(GLuint shaderProgram, const std::map< int, rtabmap::Transform > &poses, const std::multimap< int, rtabmap::Link > &links)
std::vector< GLushort > neighborIndices_
void glUniformMatrix4fv(GLuint, int, int, float *)
void CheckGlError(const char *operation)
ULogger class and convenient macros.