35 #include <GLES2/gl2.h> 37 #include <OpenGLES/ES2/gl.h> 42 const std::map<int, rtabmap::Transform> & poses,
43 const std::multimap<int, rtabmap::Link> & links) :
48 shader_program_(shaderProgram)
57 std::vector<float>
vertices = std::vector<float>(poses.size()*3);
59 std::map<int, int> idsToIndices;
60 for(std::map<int, rtabmap::Transform>::const_iterator iter=poses.begin(); iter!=poses.end(); ++iter)
62 vertices[i*3] = iter->second.x();
63 vertices[i*3+1] = iter->second.y();
64 vertices[i*3+2] = iter->second.z();
65 idsToIndices.insert(std::make_pair(iter->first, i));
70 glBufferData(GL_ARRAY_BUFFER,
sizeof(GLfloat) * (
int)vertices.size(), (
const void *)vertices.data(), GL_STATIC_DRAW);
71 glBindBuffer(GL_ARRAY_BUFFER, 0);
73 GLint error = glGetError();
74 if(error != GL_NO_ERROR)
76 LOGI(
"OpenGL: Could not allocate point cloud (0x%x)\n", error);
84 int oiLoopClosures = 0;
85 for(std::multimap<int, rtabmap::Link>::const_iterator iter=links.begin(); iter!=links.end(); ++iter)
87 std::map<int, int>::const_iterator jterFrom = idsToIndices.find(iter->second.from());
88 std::map<int, int>::const_iterator jterTo = idsToIndices.find(iter->second.to());
89 if(jterFrom != idsToIndices.end() && jterTo != idsToIndices.end())
140 GLint attribute_vertex = glGetAttribLocation(
shader_program_,
"vertex");
142 glEnableVertexAttribArray(attribute_vertex);
144 glVertexAttribPointer(attribute_vertex, 3, GL_FLOAT,
GL_FALSE, 3*
sizeof(GLfloat), 0);
148 glUniform3f(color_handle, 1.0
f, 0.0
f, 0.0
f);
153 glUniform3f(color_handle, 0.0
f, 0.0
f, 1.0
f);
157 glDisableVertexAttribArray(0);
158 glBindBuffer(GL_ARRAY_BUFFER, 0);
glm::mat4 glmFromTransform(const rtabmap::Transform &transform)
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_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.