Skip to content

Commit

Permalink
Enforce GLSL 1.4 on Mesa systems (ros-visualization#1559)
Browse files Browse the repository at this point in the history
Newer versions of libMesa cause issues when rendering materials with glsl150 scripts.
Thus, downgrade to glsl120 scripts.
  • Loading branch information
rhaschke authored and AndreasR30 committed Jun 7, 2021
1 parent ac34a1e commit 3c9c2b9
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/rviz/ogre_helpers/render_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,18 +169,19 @@ void RenderSystem::loadOgrePlugins()

void RenderSystem::detectGlVersion()
{
bool mesa_workaround = false;
if (force_gl_version_)
{
gl_version_ = force_gl_version_;
}
else
{
Ogre::RenderSystem* renderSys = ogre_root_->getRenderSystem();
renderSys->createRenderSystemCapabilities();
const Ogre::RenderSystemCapabilities* caps = renderSys->getCapabilities();
const Ogre::RenderSystemCapabilities* caps = renderSys->createRenderSystemCapabilities();
int major = caps->getDriverVersion().major;
int minor = caps->getDriverVersion().minor;
gl_version_ = major * 100 + minor * 10;
mesa_workaround = caps->getDeviceName().find("Mesa ") != std::string::npos && gl_version_ >= 320;
}

switch (gl_version_)
Expand Down Expand Up @@ -211,8 +212,16 @@ void RenderSystem::detectGlVersion()
}
break;
}
ROS_INFO_STREAM("OpenGl version: " << (float)gl_version_ / 100.0 << " (GLSL "
<< (float)glsl_version_ / 100.0 << ").");
if (mesa_workaround)
{ // https://github.com/ros-visualization/rviz/issues/1508
ROS_INFO("OpenGl version: %.1f (GLSL %.1f) limited to GLSL 1.4 on Mesa system.",
(float)gl_version_ / 100.0, (float)glsl_version_ / 100.0);

gl_version_ = 310;
glsl_version_ = 140;
return;
}
ROS_INFO("OpenGl version: %.1f (GLSL %.1f).", (float)gl_version_ / 100.0, (float)glsl_version_ / 100.0);
}

void RenderSystem::setupRenderSystem()
Expand Down

0 comments on commit 3c9c2b9

Please sign in to comment.