Skip to content

Commit

Permalink
Non desired window opening alongside ignition GUI (#1063)
Browse files Browse the repository at this point in the history
Signed-off-by: ahcorde <ahcorde@gmail.com>
  • Loading branch information
ahcorde authored Sep 30, 2021
1 parent a452a01 commit cff085e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions include/ignition/gazebo/rendering/RenderUtil.hh
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ inline namespace IGNITION_GAZEBO_VERSION_NAMESPACE {
/// \param[in] _enable True to use the current GL context
public: void SetUseCurrentGLContext(bool _enable);

/// \brief Set the Window ID
/// \param[in] _winID Window ID
public: void SetWinID(const std::string &_winID);

/// \brief Set whether to create rendering sensors
/// \param[in] _enable True to create rendering sensors
/// \param[in] _createSensorCb Callback function for creating the sensors
Expand Down
3 changes: 3 additions & 0 deletions src/gui/plugins/scene3d/Scene3D.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2103,6 +2103,9 @@ void IgnRenderer::Initialize()
if (this->initialized)
return;

this->dataPtr->renderUtil.SetWinID(std::to_string(
ignition::gui::App()->findChild<ignition::gui::MainWindow *>()->
QuickWindow()->winId()));
this->dataPtr->renderUtil.SetUseCurrentGLContext(true);
this->dataPtr->renderUtil.Init();

Expand Down
10 changes: 10 additions & 0 deletions src/rendering/RenderUtil.cc
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ class ignition::gazebo::RenderUtilPrivate
/// \brief Flag to indicate if the current GL context should be used
public: bool useCurrentGLContext = false;

/// \brief Window ID handle
public: std::string winID = "";

/// \brief New scenes to be created
public: std::vector<sdf::Scene> newScenes;

Expand Down Expand Up @@ -2408,6 +2411,7 @@ void RenderUtil::Init()
params["useCurrentGLContext"] = "1";
if (this->dataPtr->isHeadlessRendering)
params["headless"] = "1";
params["winID"] = this->dataPtr->winID;
this->dataPtr->engine = rendering::engine(this->dataPtr->engineName, params);
if (!this->dataPtr->engine)
{
Expand Down Expand Up @@ -2527,6 +2531,12 @@ void RenderUtil::SetUseCurrentGLContext(bool _enable)
this->dataPtr->useCurrentGLContext = _enable;
}

/////////////////////////////////////////////////
void RenderUtil::SetWinID(const std::string &_winID)
{
this->dataPtr->winID = _winID;
}

/////////////////////////////////////////////////
void RenderUtil::SetEnableSensors(bool _enable,
std::function<std::string(const gazebo::Entity &, const sdf::Sensor &,
Expand Down

0 comments on commit cff085e

Please sign in to comment.