Skip to content

Commit

Permalink
Fixed clang-tidy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Shobuj-Paul committed Sep 10, 2023
1 parent 3518c5f commit 198cf90
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
Expand Up @@ -299,11 +299,11 @@ class GLRenderer
float cy_;

/** \brief map from thread id to OpenGL context */
static std::map<std::thread::id, std::pair<unsigned, GLuint> > context_;
static std::map<std::thread::id, std::pair<unsigned, GLuint> > context;

/* \brief lock for context map */
static std::mutex context_lock_;
static std::mutex context_lock;

static bool glutInitialized_;
static bool glut_initialized;
};
} // namespace mesh_filter
28 changes: 14 additions & 14 deletions moveit_ros/perception/mesh_filter/src/gl_renderer.cpp
Expand Up @@ -357,9 +357,9 @@ GLuint mesh_filter::GLRenderer::loadShaders(const string& vertex_source, const s
return program_id;
}

map<std::thread::id, pair<unsigned, GLuint> > mesh_filter::GLRenderer::context_;
std::mutex mesh_filter::GLRenderer::context_lock_;
bool mesh_filter::GLRenderer::glutInitialized_ = false;
map<std::thread::id, pair<unsigned, GLuint> > mesh_filter::GLRenderer::context;
std::mutex mesh_filter::GLRenderer::context_lock;
bool mesh_filter::GLRenderer::glut_initialized = false;

namespace
{
Expand All @@ -370,25 +370,25 @@ void nullDisplayFunction()

void mesh_filter::GLRenderer::createGLContext()
{
std::unique_lock<std::mutex> _(context_lock_);
if (!glutInitialized_)
std::unique_lock<std::mutex> _(context_lock);
if (!glut_initialized)
{
char buffer[1];
char* args = buffer;
int n = 1;

glutInit(&n, &args);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH);
glutInitialized_ = true;
glut_initialized = true;
}

// check if our thread is initialized
std::thread::id thread_id = std::this_thread::get_id();
map<std::thread::id, pair<unsigned, GLuint> >::iterator context_it = context_.find(thread_id);
map<std::thread::id, pair<unsigned, GLuint> >::iterator context_it = context.find(thread_id);

if (context_it == context_.end())
if (context_it == context.end())
{
context_[thread_id] = std::pair<unsigned, GLuint>(1, 0);
context[thread_id] = std::pair<unsigned, GLuint>(1, 0);

glutInitWindowPosition(glutGet(GLUT_SCREEN_WIDTH) + 30000, 0);
glutInitWindowSize(1, 1);
Expand All @@ -409,18 +409,18 @@ void mesh_filter::GLRenderer::createGLContext()
for (int i = 0; i < 10; ++i)
glutMainLoopEvent();

context_[thread_id] = std::pair<unsigned, GLuint>(1, window_id);
context[thread_id] = std::pair<unsigned, GLuint>(1, window_id);
}
else
++(context_it->second.first);
}

void mesh_filter::GLRenderer::deleteGLContext()
{
std::unique_lock<std::mutex> _(context_lock_);
std::unique_lock<std::mutex> _(context_lock);
std::thread::id thread_id = std::this_thread::get_id();
map<std::thread::id, pair<unsigned, GLuint> >::iterator context_it = context_.find(thread_id);
if (context_it == context_.end())
map<std::thread::id, pair<unsigned, GLuint> >::iterator context_it = context.find(thread_id);
if (context_it == context.end())
{
stringstream error_msg;
error_msg << "No OpenGL context exists for Thread " << thread_id;
Expand All @@ -430,7 +430,7 @@ void mesh_filter::GLRenderer::deleteGLContext()
if (--(context_it->second.first) == 0)
{
glutDestroyWindow(context_it->second.second);
context_.erase(context_it);
context.erase(context_it);
}
}

Expand Down

0 comments on commit 198cf90

Please sign in to comment.