Accelerate 3D rendering with VBO support
*First step to move Part rendering using VBO instead of direct rendering *Update comments inside the code *Assume VBO is available if OpenGL > 3.0 is detected *Add initial Color support to VBO rendering ! *Initial full feature VBO rendering implementation *Modify some include issue for linux build *Try to fix linux include header *Reupdate header include for linux support *Fix compilation on linux *Fix linux and MacoOS build *Fix glGetString definition *Fix Windows build *Add VBO support as an option into the Preference menu *Fix crash while running FreeCAD test bench with new VBO rendering infrastructure (in both cases) *Improve performances *Compute material index only when a VBO update is required (improve frame rate by 10%) *Clean the code *Fix Travis compilation warning *Try to fix Windows compilation issue *Update include for Windows
This commit is contained in:
committed by
wmayer
parent
b5ad50abfd
commit
44af3629db
@@ -49,6 +49,19 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Gui::PrefCheckBox" name="CheckBox_useVBO">
|
||||
<property name="text">
|
||||
<string>Use OpenGL Vertex Buffer Object (experimental)</string>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>useVBO</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>View</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Gui::PrefCheckBox" name="CheckBox_UseAutoRotation">
|
||||
<property name="enabled">
|
||||
@@ -515,6 +528,7 @@
|
||||
<tabstops>
|
||||
<tabstop>CheckBox_CornerCoordSystem</tabstop>
|
||||
<tabstop>CheckBox_ShowFPS</tabstop>
|
||||
<tabstop>CheckBox_useVBO</tabstop>
|
||||
<tabstop>CheckBox_UseAutoRotation</tabstop>
|
||||
<tabstop>comboNavigationStyle</tabstop>
|
||||
<tabstop>mouseButton</tabstop>
|
||||
|
||||
@@ -85,6 +85,7 @@ void DlgSettings3DViewImp::saveSettings()
|
||||
spinBoxZoomStep->onSave();
|
||||
CheckBox_CornerCoordSystem->onSave();
|
||||
CheckBox_ShowFPS->onSave();
|
||||
CheckBox_useVBO->onSave();
|
||||
CheckBox_UseAutoRotation->onSave();
|
||||
FloatSpinBox_EyeDistance->onSave();
|
||||
checkBoxBacklight->onSave();
|
||||
@@ -101,6 +102,7 @@ void DlgSettings3DViewImp::loadSettings()
|
||||
spinBoxZoomStep->onRestore();
|
||||
CheckBox_CornerCoordSystem->onRestore();
|
||||
CheckBox_ShowFPS->onRestore();
|
||||
CheckBox_useVBO->onRestore();
|
||||
CheckBox_UseAutoRotation->onRestore();
|
||||
FloatSpinBox_EyeDistance->onRestore();
|
||||
checkBoxBacklight->onRestore();
|
||||
|
||||
@@ -89,6 +89,7 @@ void AbstractSplitView::setupSettings()
|
||||
OnChange(*hGrp,"UseBackgroundColorMid");
|
||||
OnChange(*hGrp,"UseAntialiasing");
|
||||
OnChange(*hGrp,"ShowFPS");
|
||||
OnChange(*hGrp,"useVBO");
|
||||
OnChange(*hGrp,"Orthographic");
|
||||
OnChange(*hGrp,"HeadlightColor");
|
||||
OnChange(*hGrp,"HeadlightDirection");
|
||||
@@ -226,7 +227,13 @@ void AbstractSplitView::OnChange(ParameterGrp::SubjectType &rCaller,ParameterGrp
|
||||
else if (strcmp(Reason,"ShowFPS") == 0) {
|
||||
for (std::vector<View3DInventorViewer*>::iterator it = _viewer.begin(); it != _viewer.end(); ++it)
|
||||
(*it)->setEnabledFPSCounter(rGrp.GetBool("ShowFPS",false));
|
||||
puts("updating FPS 1");
|
||||
}
|
||||
else if (strcmp(Reason,"useVBO") == 0) {
|
||||
for (std::vector<View3DInventorViewer*>::iterator it = _viewer.begin(); it != _viewer.end(); ++it)
|
||||
(*it)->setEnableduseVBO(rGrp.GetBool("useVBO",false));
|
||||
}
|
||||
|
||||
else if (strcmp(Reason,"Orthographic") == 0) {
|
||||
// check whether a perspective or orthogrphic camera should be set
|
||||
if (rGrp.GetBool("Orthographic", true)) {
|
||||
|
||||
@@ -177,6 +177,7 @@ View3DInventor::View3DInventor(Gui::Document* pcDocument, QWidget* parent,
|
||||
OnChange(*hGrp,"BackgroundColor4");
|
||||
OnChange(*hGrp,"UseBackgroundColorMid");
|
||||
OnChange(*hGrp,"ShowFPS");
|
||||
OnChange(*hGrp,"useVBO");
|
||||
OnChange(*hGrp,"Orthographic");
|
||||
OnChange(*hGrp,"HeadlightColor");
|
||||
OnChange(*hGrp,"HeadlightDirection");
|
||||
@@ -368,6 +369,9 @@ void View3DInventor::OnChange(ParameterGrp::SubjectType &rCaller,ParameterGrp::M
|
||||
else if (strcmp(Reason,"ShowFPS") == 0) {
|
||||
_viewer->setEnabledFPSCounter(rGrp.GetBool("ShowFPS",false));
|
||||
}
|
||||
else if (strcmp(Reason,"useVBO") == 0) {
|
||||
_viewer->setEnableduseVBO(rGrp.GetBool("useVBO",false));
|
||||
}
|
||||
else if (strcmp(Reason,"Orthographic") == 0) {
|
||||
// check whether a perspective or orthogrphic camera should be set
|
||||
if (rGrp.GetBool("Orthographic", true))
|
||||
|
||||
@@ -787,6 +787,11 @@ void View3DInventorViewer::setEnabledFPSCounter(bool on)
|
||||
fpsEnabled = on;
|
||||
}
|
||||
|
||||
void View3DInventorViewer::setEnableduseVBO(bool on)
|
||||
{
|
||||
vboEnabled = on;
|
||||
}
|
||||
|
||||
void View3DInventorViewer::setAxisCross(bool on)
|
||||
{
|
||||
SoNode* scene = getSceneGraph();
|
||||
@@ -1339,7 +1344,10 @@ void View3DInventorViewer::actualRedraw()
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool View3DInventorViewer::get_vbo_state()
|
||||
{
|
||||
return vboEnabled;
|
||||
}
|
||||
void View3DInventorViewer::renderFramebuffer()
|
||||
{
|
||||
const SbViewportRegion vp = this->getSoRenderManager()->getViewportRegion();
|
||||
@@ -1408,7 +1416,7 @@ void View3DInventorViewer::renderGLImage()
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
}
|
||||
|
||||
//#define ENABLE_GL_DEPTH_RANGE
|
||||
// #define ENABLE_GL_DEPTH_RANGE
|
||||
// The calls of glDepthRange inside renderScene() causes problems with transparent objects
|
||||
// so that's why it is disabled now: http://forum.freecadweb.org/viewtopic.php?f=3&t=6037&hilit=transparency
|
||||
|
||||
@@ -1442,6 +1450,7 @@ void View3DInventorViewer::renderScene(void)
|
||||
SoGLRenderActionElement::set(glra->getState(), glra);
|
||||
glra->apply(this->backgroundroot);
|
||||
|
||||
|
||||
navigation->updateAnimation();
|
||||
|
||||
try {
|
||||
|
||||
@@ -96,6 +96,7 @@ public:
|
||||
DisallowRotation=8,/**< switch of the rotation. */
|
||||
DisallowPanning=16,/**< switch of the panning. */
|
||||
DisallowZooming=32,/**< switch of the zooming. */
|
||||
useVBO=64,/**< switch of the OpenGL VBO usage. */
|
||||
};
|
||||
//@}
|
||||
|
||||
@@ -339,6 +340,7 @@ public:
|
||||
bool hasAxisCross(void);
|
||||
|
||||
void setEnabledFPSCounter(bool b);
|
||||
void setEnableduseVBO(bool b);
|
||||
|
||||
NavigationStyle* navigationStyle() const;
|
||||
|
||||
@@ -346,6 +348,8 @@ public:
|
||||
Gui::Document* getDocument();
|
||||
|
||||
virtual PyObject *getPyObject(void);
|
||||
bool vboEnabled;
|
||||
bool get_vbo_state();
|
||||
|
||||
protected:
|
||||
void renderScene();
|
||||
|
||||
Reference in New Issue
Block a user