1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-20 10:54:14 +01:00

OP-76 GCS/ModelView - Add option to enable Vertex Buffer Objects (VBOs), now disabled by default. VBOs reduce CPU load, but was causing crashes on GPUs with faulty drivers. Recommended for most to re-enable VBOs.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@736 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
chebuzz 2010-06-10 11:15:06 +00:00 committed by chebuzz
parent 6781febc5d
commit a8ba7f8d25
7 changed files with 36 additions and 6 deletions

View File

@ -44,6 +44,7 @@ void ModelViewGadget::loadConfiguration(IUAVGadgetConfiguration* config)
ModelViewGadgetConfiguration *m = qobject_cast<ModelViewGadgetConfiguration*>(config);
m_widget->setAcFilename(m->acFilename());
m_widget->setBgFilename(m->bgFilename());
m_widget->setVboEnable(m->vboEnabled());
m_widget->reloadScene();
}

View File

@ -31,12 +31,14 @@
ModelViewGadgetConfiguration::ModelViewGadgetConfiguration(QString classId, const QByteArray &state, QObject *parent) :
IUAVGadgetConfiguration(classId, parent),
m_acFilename("../artwork/3D Model/quad.dae"),
m_bgFilename("../artwork/3D Model/default_background.png")
m_bgFilename("../artwork/3D Model/default_background.png"),
m_enableVbo(false)
{
if (state.count() > 0) {
QDataStream stream(state);
stream >> m_acFilename;
stream >> m_bgFilename;
stream >> m_enableVbo;
}
}
@ -45,6 +47,7 @@ IUAVGadgetConfiguration *ModelViewGadgetConfiguration::clone()
ModelViewGadgetConfiguration *mv = new ModelViewGadgetConfiguration(this->classId());
mv->m_acFilename = m_acFilename;
mv->m_bgFilename = m_bgFilename;
mv->m_enableVbo = m_enableVbo;
return mv;
}
@ -55,6 +58,7 @@ QByteArray ModelViewGadgetConfiguration::saveState() const
QDataStream stream(&bytes, QIODevice::WriteOnly);
stream << m_acFilename;
stream << m_bgFilename;
stream << m_enableVbo;
return bytes;
}

View File

@ -43,6 +43,8 @@ public:
void setAcFilename(QString acFile) { m_acFilename = acFile; }
QString bgFilename() { return m_bgFilename; }
void setBgFilename(QString bgFile) { m_bgFilename = bgFile; }
bool vboEnabled() { return m_enableVbo; }
void setVboEnabled(bool vboEnable) { m_enableVbo = vboEnable; }
signals:
public slots:
@ -50,6 +52,7 @@ public slots:
private:
QString m_acFilename;
QString m_bgFilename;
bool m_enableVbo; // Vertex buffer objects, a few GPUs crash if enabled
};
#endif // MODELVIEWGADGETCONFIGURATION_H

View File

@ -61,6 +61,7 @@ void ModelViewGadgetOptionsPage::apply()
{
m_config->setAcFilename(m_page->modelPathChooser->path());
m_config->setBgFilename(m_page->backgroundPathChooser->path());
m_config->setVboEnabled(m_page->enableVbo->isChecked());
}
void ModelViewGadgetOptionsPage::finish()

View File

@ -78,9 +78,13 @@ void ModelViewGadgetWidget::initializeGL()
{
// OpenGL initialization
m_GlView.initGl();
if (!vboEnable)
{
GLC_State::setVboUsage(false);
qDebug("VBOs disabled. Enable for better performance if GPU supports it.");
}
m_GlView.reframe(m_ModelBoundingBox);
//m_GlView.reframe(m_World.boundingBox());
// Calculate camera depth of view
m_GlView.setDistMinAndMax(m_World.boundingBox());
glEnable(GL_NORMALIZE);
@ -90,7 +94,6 @@ void ModelViewGadgetWidget::initializeGL()
void ModelViewGadgetWidget::resizeEvent(QResizeEvent *event)
{
// printf("%d,%d\n", width(), height());
// m_GlView.setWinGLSize(width(), height());
QWidget::resizeEvent(event);
}
@ -124,7 +127,6 @@ void ModelViewGadgetWidget::resizeGL(int width, int height)
// Create GLC_Object to display
void ModelViewGadgetWidget::CreateScene()
{
// TODO: Replace with files from configuration page
if (QFile::exists(bgFilename))
{
m_GlView.loadBackGroundImage(bgFilename);

View File

@ -51,6 +51,7 @@ public:
~ModelViewGadgetWidget();
void setAcFilename(QString acf) { acFilename = acf; }
void setBgFilename(QString bgf) { bgFilename = bgf; }
void setVboEnable(bool eVbo) { vboEnable = eVbo; }
void reloadScene();
void updateAttitude(int value);
@ -87,6 +88,7 @@ private:
QString acFilename;
QString bgFilename;
bool vboEnable;
AttitudeActual* attActual;
};

View File

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<width>378</width>
<height>300</height>
</rect>
</property>
@ -37,7 +37,7 @@
<item row="0" column="1">
<widget class="Utils::PathChooser" name="modelPathChooser" native="true"/>
</item>
<item row="2" column="0">
<item row="3" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
@ -50,6 +50,23 @@
</property>
</spacer>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="enableVbo">
<property name="whatsThis">
<string>VBO allow for performance gains for GPUs that support it (most cards). This may cause cards with faulty drivers to crash.</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Enable VBOs:</string>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>