Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce GLSL 1.4 on Mesa systems #1559

Merged
merged 2 commits into from
Nov 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
9 changes: 7 additions & 2 deletions src/rviz/properties/combo_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,17 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

#include "rviz/properties/combo_box.h"
#include <rviz/properties/combo_box.h>
#include <QAbstractItemView>

namespace rviz
{
ComboBox::ComboBox(QWidget* parent) : QComboBox(parent)
// allow popup list to become larger than QCombBox itself
void ComboBox::showPopup()
{
auto view = this->view();
view->setMinimumWidth(view->sizeHintForColumn(0));
QComboBox::showPopup();
}

} // end namespace rviz
3 changes: 2 additions & 1 deletion src/rviz/properties/combo_box.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ class ComboBox : public QComboBox
Q_OBJECT
Q_PROPERTY(QString currentText READ currentText USER true)
public:
ComboBox(QWidget* parent = nullptr);
using QComboBox::QComboBox;
void showPopup() override;
};

} // end namespace rviz
Expand Down
2 changes: 2 additions & 0 deletions src/rviz/properties/editable_enum_property.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ QWidget* EditableEnumProperty::createEditor(QWidget* parent, const QStyleOptionV
Q_EMIT requestOptions(this);

EditableComboBox* cb = new EditableComboBox(parent);
// avoid larger comboxbox than column width of PropertyWidget
cb->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLengthWithIcon);
cb->addItems(strings_);
cb->setEditText(getValue().toString());
QObject::connect(cb, SIGNAL(currentIndexChanged(const QString&)), this,
Expand Down
3 changes: 2 additions & 1 deletion src/rviz/properties/splitter_handle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ SplitterHandle::SplitterHandle(QTreeView* parent)
bool SplitterHandle::eventFilter(QObject* event_target, QEvent* event)
{
if (event_target == parent_ &&
(event->type() == QEvent::Resize || event->type() == QEvent::LayoutRequest))
(event->type() == QEvent::Resize || event->type() == QEvent::LayoutRequest ||
event->type() == QEvent::Show))
{
updateGeometry();
}
Expand Down