|
26 | 26 |
|
27 | 27 | #include <QApplication>
|
28 | 28 | #include <QDateTime>
|
29 |
| -#include <QGLWidget> |
30 | 29 | #include <QHeaderView>
|
31 | 30 | #include <QStatusBar>
|
32 | 31 | #include <Inventor/actions/SoWriteAction.h>
|
|
36 | 35 | #include <rl/sg/UrdfFactory.h>
|
37 | 36 | #include <rl/sg/XmlFactory.h>
|
38 | 37 |
|
| 38 | +#if QT_VERSION >= 0x060000 |
| 39 | +#include <QOpenGLWindow> |
| 40 | +#else |
| 41 | +#include <QGLWidget> |
| 42 | +#endif |
| 43 | + |
39 | 44 | #include "ConfigurationDelegate.h"
|
40 | 45 | #include "ConfigurationModel.h"
|
41 | 46 | #include "MainWindow.h"
|
@@ -77,10 +82,16 @@ MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags f) :
|
77 | 82 | SoDB::init();
|
78 | 83 | SoGradientBackground::initClass();
|
79 | 84 |
|
| 85 | +#if QT_VERSION >= 0x060000 |
| 86 | + QSurfaceFormat format; |
| 87 | + format.setSamples(8); |
| 88 | + QSurfaceFormat::setDefaultFormat(format); |
| 89 | +#else |
80 | 90 | QGLFormat format;
|
81 | 91 | format.setAlpha(true);
|
82 | 92 | format.setSampleBuffers(true);
|
83 | 93 | QGLFormat::setDefaultFormat(format);
|
| 94 | +#endif |
84 | 95 |
|
85 | 96 | std::shared_ptr<rl::sg::Factory> geometryFactory;
|
86 | 97 | std::string geometryFilename = QApplication::arguments()[1].toStdString();
|
@@ -317,7 +328,21 @@ MainWindow::saveImage(bool withAlpha)
|
317 | 328 | }
|
318 | 329 |
|
319 | 330 | glReadBuffer(GL_FRONT);
|
| 331 | + |
| 332 | +#if QT_VERSION >= 0x060000 |
| 333 | + QOpenGLWindow* window = this->viewer->getGLWidget()->property("SoQtGLArea").value<QOpenGLWindow*>(); |
| 334 | + QSurfaceFormat surfaceFormat = window->format(); |
| 335 | + |
| 336 | + if (withAlpha != surfaceFormat.hasAlpha()) |
| 337 | + { |
| 338 | + surfaceFormat.setAlphaBufferSize(withAlpha ? 8 : 0); |
| 339 | + window->setFormat(surfaceFormat); |
| 340 | + } |
| 341 | + |
| 342 | + QImage image = window->grabFramebuffer(); |
| 343 | +#else |
320 | 344 | QImage image = static_cast<QGLWidget*>(this->viewer->getGLWidget())->grabFrameBuffer(withAlpha);
|
| 345 | +#endif |
321 | 346 |
|
322 | 347 | if (withAlpha)
|
323 | 348 | {
|
|
0 commit comments