Use framebuffer object as fallback for off-screen rendering
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
# include <QAction>
|
||||
# include <QApplication>
|
||||
# include <QFileInfo>
|
||||
# include <QGLFramebufferObject>
|
||||
# include <QKeyEvent>
|
||||
# include <QEvent>
|
||||
# include <QDropEvent>
|
||||
@@ -483,12 +484,38 @@ void View3DInventor::print(QPrinter* printer)
|
||||
QImage img;
|
||||
QPainter p(printer);
|
||||
QRect rect = printer->pageRect();
|
||||
_viewer->savePicture(rect.width(), rect.height(), View3DInventorViewer::White, img);
|
||||
|
||||
if (App::GetApplication().GetParameterGroupByPath
|
||||
("User parameter:BaseApp/Preferences/Document")->GetBool("DisablePBuffers",false)) {
|
||||
previewFromFramebuffer(rect, img);
|
||||
}
|
||||
else {
|
||||
try {
|
||||
_viewer->savePicture(rect.width(), rect.height(), View3DInventorViewer::White, img);
|
||||
}
|
||||
catch (...) {
|
||||
previewFromFramebuffer(rect, img);
|
||||
}
|
||||
}
|
||||
|
||||
p.drawImage(0,0,img);
|
||||
p.end();
|
||||
#endif
|
||||
}
|
||||
|
||||
void View3DInventor::previewFromFramebuffer(const QRect& rect, QImage& img)
|
||||
{
|
||||
QGLFramebufferObject fbo(rect.width(), rect.height(), QGLFramebufferObject::Depth);
|
||||
const SbColor col = _viewer->getBackgroundColor();
|
||||
bool on = _viewer->hasGradientBackground();
|
||||
_viewer->setBackgroundColor(SbColor(1.0f,1.0f,1.0f));
|
||||
_viewer->setGradientBackground(false);
|
||||
_viewer->renderToFramebuffer(&fbo);
|
||||
_viewer->setBackgroundColor(col);
|
||||
_viewer->setGradientBackground(on);
|
||||
img = fbo.toImage();
|
||||
}
|
||||
|
||||
// **********************************************************************************
|
||||
|
||||
bool View3DInventor::onMsg(const char* pMsg, const char** ppReturn)
|
||||
|
||||
Reference in New Issue
Block a user