Skip to content

Commit

Permalink
Downgrade to GLSL 140 on Mesa systems
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 committed Nov 16, 2020
1 parent 4596b3a commit 0faabf9
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 @@ -171,18 +171,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 @@ -213,8 +214,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 0faabf9

Please sign in to comment.