Skip to content

Commit

Permalink
fix: adds bool to signal OSMesa cleanup necessity
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidPL1 committed Dec 2, 2024
1 parent 6c9fc3e commit b8ce3da
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions mujoco_ros/include/mujoco_ros/mujoco_env.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ struct OffscreenRenderContext
{
OSMesaContext ctx;
unsigned char buffer[10000000]; // TODO: size necessary or resize later?
bool initialized = false;
} osmesa;
#endif
mjrContext con = {};
Expand Down
4 changes: 4 additions & 0 deletions mujoco_ros/src/offscreen_rendering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ OffscreenRenderContext::~OffscreenRenderContext()
eglTerminate(display);
}
#elif RENDER_BACKEND == USE_OSMESA
if (!osmesa.initialized) {
return;
}
ROS_DEBUG("Freeing OSMESA offscreen context");
mjr_defaultContext(&con);
mjr_freeContext(&con);
Expand Down Expand Up @@ -256,6 +259,7 @@ bool MujocoEnv::InitGL()
return false;
}
ROS_DEBUG("OSMesa initialized");
offscreen_.osmesa.initialized = true;
return true;
} // InitGL
#endif
Expand Down

0 comments on commit b8ce3da

Please sign in to comment.