move QuarterWidget to QOpenGLWidget

This commit is contained in:
wmayer
2017-03-08 18:28:26 +01:00
parent ef5d3920db
commit a1dd462de9
29 changed files with 207 additions and 154 deletions

View File

@@ -38,11 +38,6 @@
# include <QMessageLogContext>
#endif
# include <QPointer>
# include <QGLFormat>
# include <QGLPixelBuffer>
#if QT_VERSION >= 0x040200
# include <QGLFramebufferObject>
#endif
# include <QSessionManager>
# include <QStatusBar>
# include <QTextStream>
@@ -50,6 +45,7 @@
#endif
#include <boost/interprocess/sync/file_lock.hpp>
#include <QtOpenGL.h>
// FreeCAD Base header
@@ -1553,26 +1549,26 @@ void Application::runApplication(void)
ActionStyleEvent::EventType = QEvent::registerEventType(QEvent::User + 1);
// check for OpenGL
#if !defined(HAVE_QT5_OPENGL)
if (!QGLFormat::hasOpenGL()) {
QMessageBox::critical(0, QObject::tr("No OpenGL"), QObject::tr("This system does not support OpenGL"));
throw Base::Exception("This system does not support OpenGL");
}
#if QT_VERSION >= 0x040200
if (!QGLFramebufferObject::hasOpenGLFramebufferObjects()) {
Base::Console().Log("This system does not support framebuffer objects\n");
}
#endif
if (!QGLPixelBuffer::hasOpenGLPbuffers()) {
Base::Console().Log("This system does not support pbuffers\n");
}
#endif
#if defined(HAVE_QT5_OPENGL)
// FIXME: HAVE_QT5_OPENGL
#else
QGLFormat::OpenGLVersionFlags version = QGLFormat::openGLVersionFlags ();
#if QT_VERSION >= 0x040500
if (version & QGLFormat::OpenGL_Version_3_0)
Base::Console().Log("OpenGL version 3.0 or higher is present\n");
else
#endif
if (version & QGLFormat::OpenGL_Version_2_1)
else if (version & QGLFormat::OpenGL_Version_2_1)
Base::Console().Log("OpenGL version 2.1 or higher is present\n");
else if (version & QGLFormat::OpenGL_Version_2_0)
Base::Console().Log("OpenGL version 2.0 or higher is present\n");
@@ -1588,6 +1584,7 @@ void Application::runApplication(void)
Base::Console().Log("OpenGL version 1.1 or higher is present\n");
else if (version & QGLFormat::OpenGL_Version_None)
Base::Console().Log("No OpenGL is present or no OpenGL context is current\n");
#endif
#if !defined(Q_OS_LINUX)
QIcon::setThemeSearchPaths(QIcon::themeSearchPaths() << QString::fromLatin1(":/icons/FreeCAD-default"));

View File

@@ -1055,13 +1055,7 @@ void Document::createView(const Base::Type& typeId)
std::list<MDIView*> theViews = this->getMDIViewsOfType(typeId);
if (typeId == View3DInventor::getClassTypeId()) {
View3DInventor* firstView = 0;
QGLWidget* shareWidget = 0;
if (!theViews.empty()) {
firstView = static_cast<View3DInventor*>(theViews.front());
shareWidget = qobject_cast<QGLWidget*>(firstView->getViewer()->getGLWidget());
}
View3DInventor* view3D = new View3DInventor(this, getMainWindow(), shareWidget);
View3DInventor* view3D = new View3DInventor(this, getMainWindow());
if (firstView) {
std::string overrideMode = firstView->getViewer()->getOverrideMode();
view3D->getViewer()->setOverrideMode(overrideMode);

View File

@@ -138,7 +138,7 @@ void drawImage(QGLWidget* w,double x1, double y1, double x2, double y2, QImage p
// Embed complete widgets
Flag::Flag(QWidget* parent)
: QGLWidget(parent), coord(0.0f, 0.0f, 0.0f)
: QtGLWidget(parent), coord(0.0f, 0.0f, 0.0f)
{
this->setFixedHeight(20);
}
@@ -146,15 +146,28 @@ Flag::Flag(QWidget* parent)
void Flag::initializeGL()
{
const QPalette& p = this->palette();
#if !defined(HAVE_QT5_OPENGL)
qglClearColor(/*Qt::white*/p.color(QPalette::Window));
#else
QColor c(p.color(QPalette::Window));
QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions();
f->glClearColor(c.redF(), c.greenF(), c.blueF(), c.alphaF());
#endif
}
void Flag::paintGL()
{
const QPalette& p = this->palette();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
#if !defined(HAVE_QT5_OPENGL)
qglColor(/*Qt::black*/p.color(QPalette::Text));
renderText(10,15,this->text);
#else
QColor c(p.color(QPalette::Text));
QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions();
f->glBlendColor(c.redF(), c.greenF(), c.blueF(), c.alphaF());
//FIXME: HAVE_QT5_OPENGL
#endif
}
void Flag::resizeGL(int width, int height)
@@ -243,7 +256,7 @@ void Flag::resizeEvent(QResizeEvent * )
void Flag::paintEvent(QPaintEvent* e)
{
#if 1
QGLWidget::paintEvent(e);
QtGLWidget::paintEvent(e);
#else
#if 1
QPainter painter;

View File

@@ -27,8 +27,8 @@
#include <QLayout>
#include <QRect>
#include <QWidgetItem>
#include <QGLWidget>
#include <Inventor/SbVec3f.h>
#include <QtOpenGL.h>
#include <Gui/GLPainter.h>
namespace Gui {
@@ -38,7 +38,7 @@ class View3DInventorViewer;
* @author Werner Mayer
*/
#if 1
class GuiExport Flag : public QGLWidget
class GuiExport Flag : public QtGLWidget
{
Q_OBJECT

View File

@@ -26,7 +26,6 @@
#ifndef _PreComp_
#endif
#include <QGLWidget>
#include "GLPainter.h"
#include "View3DInventorViewer.h"
#include <Base/Console.h>
@@ -49,7 +48,7 @@ bool GLPainter::begin(QPaintDevice * device)
if (viewer)
return false;
viewer = dynamic_cast<QGLWidget*>(device);
viewer = dynamic_cast<QtGLWidget*>(device);
if (!viewer)
return false;

View File

@@ -35,10 +35,10 @@
#endif
#include <Base/BaseClass.h>
#include <QtOpenGL.h>
#include <QPoint>
class QPaintDevice;
class QGLWidget;
namespace Gui {
class View3DInventorViewer;
@@ -72,7 +72,7 @@ public:
//@}
private:
QGLWidget* viewer;
QtGLWidget* viewer;
GLfloat depthrange[2];
GLdouble projectionmatrix[16];
GLint width, height;

View File

@@ -337,14 +337,14 @@ class AlignmentView : public Gui::AbstractSplitView
public:
QLabel* myLabel;
AlignmentView(Gui::Document* pcDocument, QWidget* parent, QGLWidget* shareWidget=0, Qt::WindowFlags wflags=0)
AlignmentView(Gui::Document* pcDocument, QWidget* parent, Qt::WindowFlags wflags=0)
: AbstractSplitView(pcDocument, parent, wflags)
{
QSplitter* mainSplitter=0;
mainSplitter = new QSplitter(Qt::Horizontal, this);
_viewer.push_back(new View3DInventorViewer(mainSplitter, shareWidget));
_viewer.push_back(new View3DInventorViewer(mainSplitter));
_viewer.back()->setDocument(pcDocument);
_viewer.push_back(new View3DInventorViewer(mainSplitter, shareWidget));
_viewer.push_back(new View3DInventorViewer(mainSplitter));
_viewer.back()->setDocument(pcDocument);
QFrame* vbox = new QFrame(this);
@@ -759,15 +759,8 @@ void ManualAlignment::startAlignment(Base::Type mousemodel)
if (myAlignModel.isEmpty())
return;
QGLWidget* shareWidget = 0;
std::list<MDIView*> theViews = myDocument->getMDIViewsOfType(View3DInventor::getClassTypeId());
if (!theViews.empty()) {
shareWidget = qobject_cast<QGLWidget*>(static_cast<View3DInventor*>
(theViews.front())->getViewer()->getGLWidget());
}
// create a splitted window for picking the points
myViewer = new AlignmentView(myDocument,Gui::getMainWindow(),shareWidget);
myViewer = new AlignmentView(myDocument,Gui::getMainWindow());
myViewer->setWindowTitle(tr("Alignment[*]"));
myViewer->setWindowIcon(QApplication::windowIcon());
myViewer->resize(400, 300);

View File

@@ -28,7 +28,6 @@
# include <qevent.h>
# include <qpainter.h>
# include <qpixmap.h>
# include <QGLFramebufferObject>
# include <QMenu>
# include <Inventor/SbBox.h>
# include <Inventor/events/SoEvent.h>
@@ -37,6 +36,7 @@
# include <Inventor/events/SoMouseButtonEvent.h>
#endif
#include <QtOpenGL.h>
#include <Base/Console.h>
#include "MouseSelection.h"
@@ -640,7 +640,7 @@ void RubberbandSelection::initialize()
rubberband.setViewer(_pcView3D);
rubberband.setWorking(false);
_pcView3D->addGraphicsItem(&rubberband);
if (QGLFramebufferObject::hasOpenGLFramebufferObjects()) {
if (QtGLFramebufferObject::hasOpenGLFramebufferObjects()) {
_pcView3D->setRenderType(View3DInventorViewer::Image);
}
_pcView3D->redraw();
@@ -649,7 +649,7 @@ void RubberbandSelection::initialize()
void RubberbandSelection::terminate()
{
_pcView3D->removeGraphicsItem(&rubberband);
if (QGLFramebufferObject::hasOpenGLFramebufferObjects()) {
if (QtGLFramebufferObject::hasOpenGLFramebufferObjects()) {
_pcView3D->setRenderType(View3DInventorViewer::Native);
}
_pcView3D->redraw();

View File

@@ -158,12 +158,6 @@
#include <QNetworkAccessManager>
#include <QTcpServer>
#include <QTcpSocket>
// QtOpenGL
#include <qgl.h>
#if QT_VERSION >= 0x040200
#include <QGLFramebufferObject>
#endif
#include <QGLPixelBuffer>
// QtSvg
#include <QSvgRenderer>
#include <QSvgWidget>

View File

@@ -138,6 +138,19 @@ using namespace SIM::Coin3D::Quarter;
#endif
//We need to avoid buffer swaping when initializing a QPainter on this widget
#if defined(HAVE_QT5_OPENGL)
class CustomGLWidget : public QOpenGLWidget {
public:
CustomGLWidget(const QSurfaceFormat& format, QWidget* parent = 0, const QOpenGLWidget* shareWidget = 0, Qt::WindowFlags f = 0)
: QOpenGLWidget(parent, f)
{
Q_UNUSED(shareWidget);
QSurfaceFormat surfaceFormat(format);
surfaceFormat.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
setFormat(surfaceFormat);
}
};
#else
class CustomGLWidget : public QGLWidget {
public:
CustomGLWidget(const QGLFormat& fo, QWidget* parent = 0, const QGLWidget* shareWidget = 0, Qt::WindowFlags f = 0)
@@ -146,9 +159,10 @@ public:
setAutoBufferSwap(false);
}
};
#endif
/*! constructor */
QuarterWidget::QuarterWidget(const QGLFormat & format, QWidget * parent, const QGLWidget * sharewidget, Qt::WindowFlags f)
QuarterWidget::QuarterWidget(const QtGLFormat & format, QWidget * parent, const QtGLWidget * sharewidget, Qt::WindowFlags f)
: inherited(parent)
{
Q_UNUSED(f);
@@ -156,15 +170,15 @@ QuarterWidget::QuarterWidget(const QGLFormat & format, QWidget * parent, const Q
}
/*! constructor */
QuarterWidget::QuarterWidget(QWidget * parent, const QGLWidget * sharewidget, Qt::WindowFlags f)
QuarterWidget::QuarterWidget(QWidget * parent, const QtGLWidget * sharewidget, Qt::WindowFlags f)
: inherited(parent)
{
Q_UNUSED(f);
this->constructor(QGLFormat(), sharewidget);
this->constructor(QtGLFormat(), sharewidget);
}
/*! constructor */
QuarterWidget::QuarterWidget(QGLContext * context, QWidget * parent, const QGLWidget * sharewidget, Qt::WindowFlags f)
QuarterWidget::QuarterWidget(QtGLContext * context, QWidget * parent, const QtGLWidget * sharewidget, Qt::WindowFlags f)
: inherited(parent)
{
Q_UNUSED(f);
@@ -172,7 +186,7 @@ QuarterWidget::QuarterWidget(QGLContext * context, QWidget * parent, const QGLWi
}
void
QuarterWidget::constructor(const QGLFormat & format, const QGLWidget * sharewidget)
QuarterWidget::constructor(const QtGLFormat & format, const QtGLWidget * sharewidget)
{
QGraphicsScene* scene = new QGraphicsScene;
setScene(scene);
@@ -759,7 +773,7 @@ void QuarterWidget::paintEvent(QPaintEvent* event)
glEnable(GL_DEPTH_TEST);
glMatrixMode(GL_PROJECTION);
QGLWidget* w = static_cast<QGLWidget*>(this->viewport());
QtGLWidget* w = static_cast<QtGLWidget*>(this->viewport());
assert(w->isValid() && "No valid GL context found!");
// We might have to process the delay queue here since we don't know
// if paintGL() is called from Qt, and we might have some sensors
@@ -785,7 +799,11 @@ void QuarterWidget::paintEvent(QPaintEvent* event)
assert(w->isValid() && "No valid GL context found!");
#if defined(HAVE_QT5_OPENGL)
glDrawBuffer(w->format().swapBehavior() == QSurfaceFormat::DoubleBuffer ? GL_BACK : GL_FRONT);
#else
glDrawBuffer(w->doubleBuffer() ? GL_BACK : GL_FRONT);
#endif
w->makeCurrent();
this->actualRedraw();
@@ -797,7 +815,12 @@ void QuarterWidget::paintEvent(QPaintEvent* event)
inherited::paintEvent(event);
glPopAttrib();
#if defined(HAVE_QT5_OPENGL)
if (w->format().swapBehavior() == QSurfaceFormat::DoubleBuffer)
w->context()->swapBuffers(w->context()->surface());
#else
if (w->doubleBuffer()) { w->swapBuffers(); }
#endif
PRIVATE(this)->autoredrawenabled = true;

View File

@@ -40,7 +40,7 @@
#include <QtGui/QColor>
#include <QGraphicsView>
#include <QtCore/QUrl>
#include <QtOpenGL/QGLWidget>
#include <QtOpenGL.h>
#include "Gui/Quarter/Basic.h"
class QMenu;
@@ -81,9 +81,9 @@ class QUARTER_DLL_API QuarterWidget : public QGraphicsView {
public:
explicit QuarterWidget(QWidget * parent = 0, const QGLWidget * sharewidget = 0, Qt::WindowFlags f = 0);
explicit QuarterWidget(QGLContext * context, QWidget * parent = 0, const QGLWidget * sharewidget = 0, Qt::WindowFlags f = 0);
explicit QuarterWidget(const QGLFormat & format, QWidget * parent = 0, const QGLWidget * shareWidget = 0, Qt::WindowFlags f = 0);
explicit QuarterWidget(QWidget * parent = 0, const QtGLWidget * sharewidget = 0, Qt::WindowFlags f = 0);
explicit QuarterWidget(QtGLContext * context, QWidget * parent = 0, const QtGLWidget * sharewidget = 0, Qt::WindowFlags f = 0);
explicit QuarterWidget(const QtGLFormat & format, QWidget * parent = 0, const QtGLWidget * shareWidget = 0, Qt::WindowFlags f = 0);
virtual ~QuarterWidget();
enum TransparencyType {
@@ -199,7 +199,7 @@ protected:
double renderTime;
private:
void constructor(const QGLFormat& format, const QGLWidget* sharewidget);
void constructor(const QtGLFormat& format, const QtGLWidget* sharewidget);
friend class QuarterWidgetP;
class QuarterWidgetP * pimpl;
bool initialized;

View File

@@ -64,12 +64,12 @@ using namespace SIM::Coin3D::Quarter;
class QuarterWidgetP_cachecontext {
public:
uint32_t id;
SbList <const QGLWidget *> widgetlist;
SbList <const QtGLWidget *> widgetlist;
};
static SbList <QuarterWidgetP_cachecontext *> * cachecontext_list = NULL;
QuarterWidgetP::QuarterWidgetP(QuarterWidget * masterptr, const QGLWidget * sharewidget)
QuarterWidgetP::QuarterWidgetP(QuarterWidget * masterptr, const QtGLWidget * sharewidget)
: master(masterptr),
scene(NULL),
eventfilter(NULL),
@@ -100,7 +100,7 @@ QuarterWidgetP::QuarterWidgetP(QuarterWidget * masterptr, const QGLWidget * shar
QuarterWidgetP::~QuarterWidgetP()
{
QGLWidget* glMaster = static_cast<QGLWidget*>(this->master->viewport());
QtGLWidget* glMaster = static_cast<QtGLWidget*>(this->master->viewport());
removeFromCacheContext(this->cachecontext, glMaster);
if (this->contextmenu) {
delete this->contextmenu;
@@ -131,7 +131,7 @@ QuarterWidgetP::getCacheContextId(void) const
}
QuarterWidgetP_cachecontext *
QuarterWidgetP::findCacheContext(QuarterWidget * widget, const QGLWidget * sharewidget)
QuarterWidgetP::findCacheContext(QuarterWidget * widget, const QtGLWidget * sharewidget)
{
if (cachecontext_list == NULL) {
// FIXME: static memory leak
@@ -142,23 +142,23 @@ QuarterWidgetP::findCacheContext(QuarterWidget * widget, const QGLWidget * share
for (int j = 0; j < cachecontext->widgetlist.getLength(); j++) {
if (cachecontext->widgetlist[j] == sharewidget) {
cachecontext->widgetlist.append(static_cast<const QGLWidget*>(widget->viewport()));
cachecontext->widgetlist.append(static_cast<const QtGLWidget*>(widget->viewport()));
return cachecontext;
}
}
}
QuarterWidgetP_cachecontext * cachecontext = new QuarterWidgetP_cachecontext;
cachecontext->id = SoGLCacheContextElement::getUniqueCacheContext();
cachecontext->widgetlist.append(static_cast<const QGLWidget*>(widget->viewport()));
cachecontext->widgetlist.append(static_cast<const QtGLWidget*>(widget->viewport()));
cachecontext_list->append(cachecontext);
return cachecontext;
}
void
QuarterWidgetP::removeFromCacheContext(QuarterWidgetP_cachecontext * context, const QGLWidget * widget)
QuarterWidgetP::removeFromCacheContext(QuarterWidgetP_cachecontext * context, const QtGLWidget * widget)
{
context->widgetlist.removeItem((const QGLWidget*) widget);
context->widgetlist.removeItem((const QtGLWidget*) widget);
if (context->widgetlist.getLength() == 0) { // last context in this share group?
assert(cachecontext_list);
@@ -166,12 +166,12 @@ QuarterWidgetP::removeFromCacheContext(QuarterWidgetP_cachecontext * context, co
for (int i = 0; i < cachecontext_list->getLength(); i++) {
if ((*cachecontext_list)[i] == context) {
// set the context while calling destructingContext() (might trigger OpenGL calls)
const_cast<QGLWidget*> (widget)->makeCurrent();
const_cast<QtGLWidget*> (widget)->makeCurrent();
// fetch the cc_glglue context instance as a workaround for a bug fixed in Coin r12818
(void) cc_glglue_instance(context->id);
cachecontext_list->removeFast(i);
SoContextHandler::destructingContext(context->id);
const_cast<QGLWidget*> (widget)->doneCurrent();
const_cast<QtGLWidget*> (widget)->doneCurrent();
delete context;
return;
}

View File

@@ -38,6 +38,7 @@
#include <QtGui/QCursor>
#include <QtCore/QList>
#include <QtCore/QUrl>
#include <QtOpenGL.h>
class SoNode;
class SoCamera;
@@ -45,7 +46,6 @@ class SoRenderManager;
class SoEventManager;
class SoDirectionalLight;
class QuarterWidgetP_cachecontext;
class QGLWidget;
class QAction;
class QActionGroup;
class QMenu;
@@ -62,7 +62,7 @@ class ContextMenu;
class QuarterWidgetP {
public:
QuarterWidgetP(class QuarterWidget * master, const QGLWidget * sharewidget);
QuarterWidgetP(class QuarterWidget * master, const QtGLWidget * sharewidget);
~QuarterWidgetP();
SoCamera * searchForCamera(SoNode * root);
@@ -112,8 +112,8 @@ public:
static bool nativeEventFilter(void * message, long * result);
private:
QuarterWidgetP_cachecontext * findCacheContext(QuarterWidget * widget, const QGLWidget * sharewidget);
static void removeFromCacheContext(QuarterWidgetP_cachecontext * context, const QGLWidget * widget);
QuarterWidgetP_cachecontext * findCacheContext(QuarterWidget * widget, const QtGLWidget * sharewidget);
static void removeFromCacheContext(QuarterWidgetP_cachecontext * context, const QtGLWidget * widget);
};
#endif // QUARTER_QUARTERWIDGETP_H

View File

@@ -132,19 +132,19 @@ static unsigned char fps2dfont[][12] = {
{ 0, 0, 0, 0, 0, 0, 78, 57, 0, 0, 0, 0 } // ~
};
SIM::Coin3D::Quarter::SoQTQuarterAdaptor::SoQTQuarterAdaptor(QWidget* parent, const QGLWidget* sharewidget, Qt::WindowFlags f)
SIM::Coin3D::Quarter::SoQTQuarterAdaptor::SoQTQuarterAdaptor(QWidget* parent, const QtGLWidget* sharewidget, Qt::WindowFlags f)
: QuarterWidget(parent, sharewidget, f), matrixaction(SbViewportRegion(100,100))
{
init();
}
SIM::Coin3D::Quarter::SoQTQuarterAdaptor::SoQTQuarterAdaptor(const QGLFormat& format, QWidget* parent, const QGLWidget* shareWidget, Qt::WindowFlags f)
SIM::Coin3D::Quarter::SoQTQuarterAdaptor::SoQTQuarterAdaptor(const QtGLFormat& format, QWidget* parent, const QtGLWidget* shareWidget, Qt::WindowFlags f)
: QuarterWidget(format, parent, shareWidget, f), matrixaction(SbViewportRegion(100,100))
{
init();
}
SIM::Coin3D::Quarter::SoQTQuarterAdaptor::SoQTQuarterAdaptor(QGLContext* context, QWidget* parent, const QGLWidget* sharewidget, Qt::WindowFlags f)
SIM::Coin3D::Quarter::SoQTQuarterAdaptor::SoQTQuarterAdaptor(QtGLContext* context, QWidget* parent, const QtGLWidget* sharewidget, Qt::WindowFlags f)
: QuarterWidget(context, parent, sharewidget, f), matrixaction(SbViewportRegion(100,100))
{
init();

View File

@@ -46,9 +46,9 @@ typedef void SoQTQuarterAdaptorCB(void* data, SoQTQuarterAdaptor* viewer);
class QUARTER_DLL_API SoQTQuarterAdaptor : public QuarterWidget {
public:
explicit SoQTQuarterAdaptor(QWidget* parent = 0, const QGLWidget* sharewidget = 0, Qt::WindowFlags f = 0);
explicit SoQTQuarterAdaptor(const QGLFormat& format, QWidget* parent = 0, const QGLWidget* shareWidget = 0, Qt::WindowFlags f = 0);
explicit SoQTQuarterAdaptor(QGLContext* context, QWidget* parent = 0, const QGLWidget* sharewidget = 0, Qt::WindowFlags f = 0);
explicit SoQTQuarterAdaptor(QWidget* parent = 0, const QtGLWidget* sharewidget = 0, Qt::WindowFlags f = 0);
explicit SoQTQuarterAdaptor(const QtGLFormat& format, QWidget* parent = 0, const QtGLWidget* shareWidget = 0, Qt::WindowFlags f = 0);
explicit SoQTQuarterAdaptor(QtGLContext* context, QWidget* parent = 0, const QtGLWidget* sharewidget = 0, Qt::WindowFlags f = 0);
virtual ~SoQTQuarterAdaptor();
//the functions available in soqtviewer but missing in quarter

View File

@@ -87,14 +87,14 @@ SoGLWidgetElement::~SoGLWidgetElement()
{
}
void SoGLWidgetElement::set(SoState * state, QGLWidget * window)
void SoGLWidgetElement::set(SoState * state, QtGLWidget * window)
{
SoGLWidgetElement * elem = static_cast<SoGLWidgetElement *>
(SoElement::getElement(state, classStackIndex));
elem->window = window;
}
void SoGLWidgetElement::get(SoState * state, QGLWidget *& window)
void SoGLWidgetElement::get(SoState * state, QtGLWidget *& window)
{
const SoGLWidgetElement* that = static_cast<const SoGLWidgetElement *>
(SoElement::getConstElement(state, classStackIndex));

View File

@@ -28,7 +28,7 @@
# include "InventorAll.h"
#endif
class QGLWidget;
#include <QtOpenGL.h>
namespace Gui {
/**
@@ -70,14 +70,14 @@ public:
virtual SbBool matches(const SoElement * element) const;
virtual SoElement * copyMatchInfo(void) const;
static void set(SoState * state, QGLWidget * window);
static void get(SoState * state, QGLWidget *& window);
static void set(SoState * state, QtGLWidget * window);
static void get(SoState * state, QtGLWidget *& window);
protected:
virtual ~SoGLWidgetElement();
protected:
QGLWidget * window;
QtGLWidget * window;
};
class GuiExport SoGLRenderActionElement : public SoElement {
@@ -114,7 +114,7 @@ public:
static void initClass(void);
SoGLWidgetNode(void);
QGLWidget * window;
QtGLWidget * window;
virtual void doAction(SoAction * action);
virtual void GLRender(SoGLRenderAction * action);

View File

@@ -29,9 +29,6 @@
# include <QBuffer>
# include <QDateTime>
# include <QFile>
# include <QGLFormat>
# include <QGLFramebufferObject>
# include <QGLPixelBuffer>
# include <QImage>
# include <QImageWriter>
#endif
@@ -403,11 +400,17 @@ void SoQtOffscreenRenderer::init(const SbViewportRegion & vpr,
this->didallocation = glrenderaction ? false : true;
this->viewport = vpr;
#if !defined(HAVE_QT5_OPENGL)
this->pixelbuffer = NULL; // constructed later
#endif
this->framebuffer = NULL;
this->numSamples = -1;
this->cache_context = 0;
#if !defined(HAVE_QT5_OPENGL)
this->pbuffer = QGLPixelBuffer::hasOpenGLPbuffers();
#else
this->pbuffer = false;
#endif
}
/*!
@@ -434,7 +437,9 @@ SoQtOffscreenRenderer::SoQtOffscreenRenderer(SoGLRenderAction * action)
*/
SoQtOffscreenRenderer::~SoQtOffscreenRenderer()
{
#if !defined(HAVE_QT5_OPENGL)
delete pixelbuffer;
#endif
delete framebuffer;
if (this->didallocation) {
@@ -538,6 +543,7 @@ SoQtOffscreenRenderer::pre_render_cb(void * /*userdata*/, SoGLRenderAction * act
action->setRenderingIsRemote(false);
}
#if !defined(HAVE_QT5_OPENGL)
void
SoQtOffscreenRenderer::makePixelBuffer(int width, int height, int samples)
{
@@ -560,6 +566,7 @@ SoQtOffscreenRenderer::makePixelBuffer(int width, int height, int samples)
pixelbuffer = new QGLPixelBuffer(width, height, fmt);
cache_context = SoGLCacheContextElement::getUniqueCacheContext(); // unique per pixel buffer object, just to be sure
}
#endif
void
SoQtOffscreenRenderer::makeFrameBuffer(int width, int height, int samples)
@@ -572,15 +579,15 @@ SoQtOffscreenRenderer::makeFrameBuffer(int width, int height, int samples)
viewport.setWindowSize(width, height);
#if QT_VERSION >= 0x040600
QGLFramebufferObjectFormat fmt;
QtGLFramebufferObjectFormat fmt;
fmt.setSamples(samples);
fmt.setAttachment(QGLFramebufferObject::Depth);
fmt.setAttachment(QtGLFramebufferObject::Depth);
#else
QGLFramebufferObject::Attachment fmt;
fmt = QGLFramebufferObject::Depth;
QtGLFramebufferObject::Attachment fmt;
fmt = QtGLFramebufferObject::Depth;
#endif
framebuffer = new QGLFramebufferObject(width, height, fmt);
framebuffer = new QtGLFramebufferObject(width, height, fmt);
cache_context = SoGLCacheContextElement::getUniqueCacheContext(); // unique per pixel buffer object, just to be sure
}
@@ -589,6 +596,7 @@ SoQtOffscreenRenderer::renderFromBase(SoBase * base)
{
const SbVec2s fullsize = this->viewport.getViewportSizePixels();
#if !defined(HAVE_QT5_OPENGL)
if (PRIVATE(this)->pbuffer) {
if (!pixelbuffer) {
makePixelBuffer(fullsize[0], fullsize[1], PRIVATE(this)->numSamples);
@@ -600,7 +608,9 @@ SoQtOffscreenRenderer::renderFromBase(SoBase * base)
pixelbuffer->makeCurrent(); // activate us!
}
else {
else
#endif
{
if (!framebuffer) {
makeFrameBuffer(fullsize[0], fullsize[1], PRIVATE(this)->numSamples);
}
@@ -638,10 +648,13 @@ SoQtOffscreenRenderer::renderFromBase(SoBase * base)
this->renderaction->removePreRenderCallback(pre_render_cb, NULL);
#if !defined(HAVE_QT5_OPENGL)
if (PRIVATE(this)->pbuffer) {
pixelbuffer->doneCurrent();
}
else {
else
#endif
{
framebuffer->release();
}
@@ -712,11 +725,14 @@ SoQtOffscreenRenderer::render(SoPath * scene)
void
SoQtOffscreenRenderer::writeToImage (QImage& img) const
{
#if !defined(HAVE_QT5_OPENGL)
if (PRIVATE(this)->pbuffer) {
if (pixelbuffer)
img = pixelbuffer->toImage();
}
else {
else
#endif
{
if (framebuffer)
img = framebuffer->toImage();
}

View File

@@ -27,10 +27,9 @@
#include <Inventor/SoOffscreenRenderer.h>
#include <Inventor/SbMatrix.h>
#include <QStringList>
#include <QtOpenGL.h>
class QImage;
class QGLFramebufferObject;
class QGLPixelBuffer;
namespace Gui {
@@ -114,12 +113,12 @@ public:
void setGLRenderAction(SoGLRenderAction * action);
SoGLRenderAction * getGLRenderAction(void) const;
void setNumPasses(const int num);
int getNumPasses(void) const;
void setPbufferEnable(SbBool enable);
SbBool getPbufferEnable(void) const;
void setNumPasses(const int num);
int getNumPasses(void) const;
void setPbufferEnable(SbBool enable);
SbBool getPbufferEnable(void) const;
SbBool render(SoNode * scene);
SbBool render(SoPath * scene);
@@ -131,12 +130,16 @@ private:
void init(const SbViewportRegion & vpr, SoGLRenderAction * glrenderaction = NULL);
static void pre_render_cb(void * userdata, SoGLRenderAction * action);
SbBool renderFromBase(SoBase * base);
#if !defined(HAVE_QT5_OPENGL)
void makePixelBuffer(int width, int height, int samples);
#endif
void makeFrameBuffer(int width, int height, int samples);
QGLPixelBuffer* pixelbuffer; // the offscreen rendering supported by Qt
QGLFramebufferObject* framebuffer;
uint32_t cache_context; // our unique context id
#if !defined(HAVE_QT5_OPENGL)
QGLPixelBuffer* pixelbuffer; // the offscreen rendering supported by Qt
#endif
QtGLFramebufferObject* framebuffer;
uint32_t cache_context; // our unique context id
SbViewportRegion viewport;
SbColor backgroundcolor;

View File

@@ -25,7 +25,6 @@
#ifndef _PreComp_
# include <qstatusbar.h>
# include <qstring.h>
# include <QGLWidget>
# include <Inventor/details/SoFaceDetail.h>
# include <Inventor/details/SoLineDetail.h>
#endif

View File

@@ -25,7 +25,6 @@
#ifndef _PreComp_
# include <qstatusbar.h>
# include <qstring.h>
# include <QGLWidget>
# include <Inventor/details/SoFaceDetail.h>
# include <Inventor/details/SoLineDetail.h>
#endif
@@ -65,6 +64,8 @@
#include <Inventor/events/SoLocation2Event.h>
#include <Inventor/SoPickedPoint.h>
#include <QtOpenGL.h>
#include <Base/Console.h>
#include <Base/UnitsApi.h>
#include <App/Application.h>
@@ -561,7 +562,7 @@ void SoFCUnifiedSelection::GLRenderBelowPath(SoGLRenderAction * action)
// this is called when a selection gate forbade to select an object
// and the user moved the mouse to an empty area
this->preSelection = -1;
QGLWidget* window;
QtGLWidget* window;
SoState *state = action->getState();
SoGLWidgetElement::get(state, window);
QWidget* parent = window ? window->parentWidget() : 0;

View File

@@ -35,7 +35,6 @@
# include <cfloat>
# include <algorithm>
# include <QFontMetrics>
# include <QGLWidget>
# include <QPainter>
# include <QPen>
# include <Inventor/actions/SoGLRenderAction.h>
@@ -62,6 +61,7 @@
#include <Inventor/elements/SoGLTexture3EnabledElement.h>
#endif
#include <QtOpenGL.h>
#include "SoTextLabel.h"
#include "SoFCInteractiveElement.h"
#include "BitmapFactory.h"
@@ -318,7 +318,7 @@ SoStringLabel::SoStringLabel()
*/
void SoStringLabel::GLRender(SoGLRenderAction *action)
{
QGLWidget* window;
QtGLWidget* window;
SoState * state = action->getState();
state->push();
SoLazyElement::setLightModel(state, SoLazyElement::BASE_COLOR);
@@ -376,7 +376,11 @@ void SoStringLabel::GLRender(SoGLRenderAction *action)
QStringList list;
for (int i=0; i<this->string.getNum(); i++)
list << QLatin1String(this->string[i].getString());
#if !defined(HAVE_QT5_OPENGL)
window->renderText(nil[0],nil[1],nil[2],list.join(QLatin1String("\n")),font);
#else
//FIXME: HAVE_QT5_OPENGL
#endif
// Leave 2D screen mode
glPopAttrib();
@@ -492,7 +496,7 @@ void SoFrameLabel::GLRender(SoGLRenderAction *action)
{
inherited::GLRender(action);
#if 0
QGLWidget* window;
QtGLWidget* window;
SoState * state = action->getState();
state->push();
SoLazyElement::setLightModel(state, SoLazyElement::BASE_COLOR);

View File

@@ -684,23 +684,29 @@ SplitView3DInventor::SplitView3DInventor(int views, Gui::Document* pcDocument, Q
hGrp->Attach(this);
//anti-aliasing settings
QGLFormat f;
QtGLFormat f;
bool smoothing = false;
bool glformat = false;
switch (hGrp->GetInt("AntiAliasing",0) ) {
case View3DInventorViewer::MSAA2x:
glformat = true;
#if !defined(HAVE_QT5_OPENGL)
f.setSampleBuffers(true);
#endif
f.setSamples(2);
break;
case View3DInventorViewer::MSAA4x:
glformat = true;
#if !defined(HAVE_QT5_OPENGL)
f.setSampleBuffers(true);
#endif
f.setSamples(4);
break;
case View3DInventorViewer::MSAA8x:
glformat = true;
#if !defined(HAVE_QT5_OPENGL)
f.setSampleBuffers(true);
#endif
f.setSamples(8);
break;
case View3DInventorViewer::Smoothing:

View File

@@ -29,10 +29,9 @@
# include <QByteArray>
# include <QDateTime>
# include <QImage>
# include <QGLFramebufferObject>
# include <QGLPixelBuffer>
#endif
#include <QtOpenGL.h>
#include "Thumbnail.h"
#include "BitmapFactory.h"
#include "View3DInventorViewer.h"
@@ -88,7 +87,11 @@ void Thumbnail::SaveDocFile (Base::Writer &writer) const
if (!this->viewer)
return;
QImage img;
#if !defined(HAVE_QT5_OPENGL)
bool pbuffer = QGLPixelBuffer::hasOpenGLPbuffers();
#else
bool pbuffer = QtGLFramebufferObject::hasOpenGLFramebufferObjects();
#endif
if (App::GetApplication().GetParameterGroupByPath
("User parameter:BaseApp/Preferences/Document")->GetBool("DisablePBuffers",!pbuffer)) {
this->createThumbnailFromFramebuffer(img);
@@ -131,7 +134,7 @@ void Thumbnail::RestoreDocFile(Base::Reader &reader)
void Thumbnail::createThumbnailFromFramebuffer(QImage& img) const
{
// Alternative way of off-screen rendering
QGLFramebufferObject fbo(this->size, this->size,QGLFramebufferObject::Depth);
QtGLFramebufferObject fbo(this->size, this->size,QtGLFramebufferObject::Depth);
if (this->viewer->isActiveWindow()) {
this->viewer->renderToFramebuffer(&fbo);
img = fbo.toImage();

View File

@@ -27,15 +27,11 @@
# include <QAction>
# include <QApplication>
# include <QFileInfo>
# include <QGLFramebufferObject>
# include <QKeyEvent>
# include <QEvent>
# include <QDropEvent>
# include <QDragEnterEvent>
# include <QFileDialog>
# include <QGLFormat>
# include <QGLWidget>
# include <QGLPixelBuffer>
# include <QMessageBox>
# include <QPainter>
# include <QPrinter>
@@ -105,7 +101,7 @@ void GLOverlayWidget::paintEvent(QPaintEvent*)
TYPESYSTEM_SOURCE_ABSTRACT(Gui::View3DInventor,Gui::MDIView);
View3DInventor::View3DInventor(Gui::Document* pcDocument, QWidget* parent,
const QGLWidget* sharewidget, Qt::WindowFlags wflags)
const QtGLWidget* sharewidget, Qt::WindowFlags wflags)
: MDIView(pcDocument, parent, wflags), _viewerPy(0)
{
stack = new QStackedWidget(this);
@@ -119,23 +115,29 @@ View3DInventor::View3DInventor(Gui::Document* pcDocument, QWidget* parent,
hGrp->Attach(this);
//anti-aliasing settings
QGLFormat f;
QtGLFormat f;
bool smoothing = false;
bool glformat = false;
switch( hGrp->GetInt("AntiAliasing",0) ) {
case View3DInventorViewer::MSAA2x:
glformat = true;
#if !defined(HAVE_QT5_OPENGL)
f.setSampleBuffers(true);
#endif
f.setSamples(2);
break;
case View3DInventorViewer::MSAA4x:
glformat = true;
#if !defined(HAVE_QT5_OPENGL)
f.setSampleBuffers(true);
#endif
f.setSamples(4);
break;
case View3DInventorViewer::MSAA8x:
glformat = true;
#if !defined(HAVE_QT5_OPENGL)
f.setSampleBuffers(true);
#endif
f.setSamples(8);
break;
case View3DInventorViewer::Smoothing:
@@ -552,7 +554,11 @@ void View3DInventor::print(QPrinter* printer)
}
QRect rect = printer->pageRect();
#if !defined(HAVE_QT5_OPENGL)
bool pbuffer = QGLPixelBuffer::hasOpenGLPbuffers();
#else
bool pbuffer = QtGLFramebufferObject::hasOpenGLFramebufferObjects();
#endif
if (App::GetApplication().GetParameterGroupByPath
("User parameter:BaseApp/Preferences/Document")->GetBool("DisablePBuffers",!pbuffer)) {
previewFromFramebuffer(rect, img);
@@ -574,12 +580,12 @@ void View3DInventor::print(QPrinter* printer)
void View3DInventor::previewFromFramebuffer(const QRect& rect, QImage& img)
{
#if QT_VERSION >= 0x040600
QGLFramebufferObjectFormat format;
QtGLFramebufferObjectFormat format;
format.setSamples(8);
format.setAttachment(QGLFramebufferObject::Depth);
QGLFramebufferObject fbo(rect.width(), rect.height(), format);
format.setAttachment(QtGLFramebufferObject::Depth);
QtGLFramebufferObject fbo(rect.width(), rect.height(), format);
#else
QGLFramebufferObject fbo(rect.width(), rect.height(), QGLFramebufferObject::Depth);
QtGLFramebufferObject fbo(rect.width(), rect.height(), QtGLFramebufferObject::Depth);
#endif
const QColor col = _viewer->backgroundColor();
bool on = _viewer->hasGradientBackground();

View File

@@ -28,9 +28,9 @@
#include <Base/Parameter.h>
#include <QImage>
#include <QtOpenGL.h>
class SoNode;
class QGLWidget;
class QPrinter;
class QStackedWidget;
@@ -68,7 +68,7 @@ class GuiExport View3DInventor : public MDIView, public ParameterGrp::ObserverTy
TYPESYSTEM_HEADER();
public:
View3DInventor(Gui::Document* pcDocument, QWidget* parent, const QGLWidget* sharewidget = 0, Qt::WindowFlags wflags=0);
View3DInventor(Gui::Document* pcDocument, QWidget* parent, const QtGLWidget* sharewidget = 0, Qt::WindowFlags wflags=0);
~View3DInventor();
/// Message handler

View File

@@ -75,8 +75,6 @@
# include <Inventor/SoPickedPoint.h>
# include <Inventor/VRMLnodes/SoVRMLGroup.h>
# include <QEventLoop>
# include <QGLFramebufferObject>
# include <QGLPixelBuffer>
# include <QKeyEvent>
# include <QWheelEvent>
# include <QMessageBox>
@@ -335,7 +333,7 @@ public:
// *************************************************************************
View3DInventorViewer::View3DInventorViewer(QWidget* parent, const QGLWidget* sharewidget)
View3DInventorViewer::View3DInventorViewer(QWidget* parent, const QtGLWidget* sharewidget)
: Quarter::SoQTQuarterAdaptor(parent, sharewidget), editViewProvider(0), navigation(0),
renderType(Native), framebuffer(0), axisCross(0), axisGroup(0), editing(false), redirected(false),
allowredir(false), overrideMode("As Is"), _viewerPy(0)
@@ -343,7 +341,7 @@ View3DInventorViewer::View3DInventorViewer(QWidget* parent, const QGLWidget* sha
init();
}
View3DInventorViewer::View3DInventorViewer(const QGLFormat& format, QWidget* parent, const QGLWidget* sharewidget)
View3DInventorViewer::View3DInventorViewer(const QtGLFormat& format, QWidget* parent, const QtGLWidget* sharewidget)
: Quarter::SoQTQuarterAdaptor(format, parent, sharewidget), editViewProvider(0), navigation(0),
renderType(Native), framebuffer(0), axisCross(0), axisGroup(0), editing(false), redirected(false),
allowredir(false), overrideMode("As Is"), _viewerPy(0)
@@ -767,7 +765,7 @@ void View3DInventorViewer::setGLWidgetCB(void* userdata, SoAction* action)
// Separator (set envvar COIN_GLERROR_DEBUGGING=1 and re-run to get more information)
if (action->isOfType(SoGLRenderAction::getClassTypeId())) {
QWidget* gl = reinterpret_cast<QWidget*>(userdata);
SoGLWidgetElement::set(action->getState(), qobject_cast<QGLWidget*>(gl));
SoGLWidgetElement::set(action->getState(), qobject_cast<QtGLWidget*>(gl));
}
}
@@ -777,7 +775,7 @@ void View3DInventorViewer::handleEventCB(void* ud, SoEventCallback* n)
SoGLRenderAction* glra = that->getSoRenderManager()->getGLRenderAction();
SoAction* action = n->getAction();
SoGLRenderActionElement::set(action->getState(), glra);
SoGLWidgetElement::set(action->getState(), qobject_cast<QGLWidget*>(that->getGLWidget()));
SoGLWidgetElement::set(action->getState(), qobject_cast<QtGLWidget*>(that->getGLWidget()));
}
void View3DInventorViewer::setGradientBackground(bool on)
@@ -930,7 +928,11 @@ void View3DInventorViewer::savePicture(int w, int h, const QColor& bg, QImage& i
// If 'QGLPixelBuffer::hasOpenGLPbuffers()' returns false then
// SoQtOffscreenRenderer won't work. In this case we try to use
// Coin's implementation of the off-screen rendering.
#if !defined(HAVE_QT5_OPENGL)
bool useCoinOffscreenRenderer = !QGLPixelBuffer::hasOpenGLPbuffers();
#else
bool useCoinOffscreenRenderer = !QtGLFramebufferObject::hasOpenGLFramebufferObjects();
#endif
useCoinOffscreenRenderer = App::GetApplication().GetParameterGroupByPath
("User parameter:BaseApp/Preferences/Document")->
GetBool("CoinOffscreenRenderer", useCoinOffscreenRenderer);
@@ -1304,15 +1306,15 @@ void View3DInventorViewer::setRenderType(const RenderType type)
const SbViewportRegion vp = this->getSoRenderManager()->getViewportRegion();
SbVec2s size = vp.getViewportSizePixels();
QGLWidget* gl = static_cast<QGLWidget*>(this->viewport());
QtGLWidget* gl = static_cast<QtGLWidget*>(this->viewport());
gl->makeCurrent();
framebuffer = new QGLFramebufferObject(size[0],size[1],QGLFramebufferObject::Depth);
framebuffer = new QtGLFramebufferObject(size[0],size[1],QtGLFramebufferObject::Depth);
renderToFramebuffer(framebuffer);
}
break;
case Image:
{
QGLWidget* gl = static_cast<QGLWidget*>(this->viewport());
QtGLWidget* gl = static_cast<QtGLWidget*>(this->viewport());
gl->makeCurrent();
int w = gl->width();
int h = gl->height();
@@ -1329,9 +1331,9 @@ View3DInventorViewer::RenderType View3DInventorViewer::getRenderType() const
return this->renderType;
}
void View3DInventorViewer::renderToFramebuffer(QGLFramebufferObject* fbo)
void View3DInventorViewer::renderToFramebuffer(QtGLFramebufferObject* fbo)
{
static_cast<QGLWidget*>(this->viewport())->makeCurrent();
static_cast<QtGLWidget*>(this->viewport())->makeCurrent();
fbo->bind();
int width = fbo->size().width();
int height = fbo->size().height();
@@ -1483,7 +1485,7 @@ void View3DInventorViewer::renderScene(void)
// Render our scenegraph with the image.
SoGLRenderAction* glra = this->getSoRenderManager()->getGLRenderAction();
SoState* state = glra->getState();
SoGLWidgetElement::set(state, qobject_cast<QGLWidget*>(this->getGLWidget()));
SoGLWidgetElement::set(state, qobject_cast<QtGLWidget*>(this->getGLWidget()));
SoGLRenderActionElement::set(state, glra);
SoGLVBOActivatedElement::set(state, this->vboEnabled);
glra->apply(this->backgroundroot);

View File

@@ -52,7 +52,6 @@ class SbSphereSheetProjector;
class SoEventCallback;
class SbBox2s;
class SoVectorizeAction;
class QGLFramebufferObject;
class QImage;
class SoGroup;
@@ -124,8 +123,8 @@ public:
};
//@}
View3DInventorViewer (QWidget *parent, const QGLWidget* sharewidget = 0);
View3DInventorViewer (const QGLFormat& format, QWidget *parent, const QGLWidget* sharewidget = 0);
View3DInventorViewer (QWidget *parent, const QtGLWidget* sharewidget = 0);
View3DInventorViewer (const QtGLFormat& format, QWidget *parent, const QtGLWidget* sharewidget = 0);
virtual ~View3DInventorViewer();
void init();
@@ -158,7 +157,7 @@ public:
void setRenderType(const RenderType type);
RenderType getRenderType() const;
void renderToFramebuffer(QGLFramebufferObject*);
void renderToFramebuffer(QtGLFramebufferObject*);
virtual void setViewing(SbBool enable);
virtual void setCursorEnabled(SbBool enable);
@@ -409,7 +408,7 @@ private:
SoFCUnifiedSelection* selectionRoot;
RenderType renderType;
QGLFramebufferObject* framebuffer;
QtGLFramebufferObject* framebuffer;
QImage glImage;
SbBool shading;
SoSwitch *dimensionRoot;

View File

@@ -30,14 +30,11 @@
# include <QDir>
# include <QFileInfo>
# include <QImage>
# include <QGLContext>
# include <QGLFramebufferObject>
# include <QGLPixelBuffer>
# include <Inventor/SbViewVolume.h>
# include <Inventor/nodes/SoCamera.h>
#endif
#include <QtOpenGL.h>
#include "View3DPy.h"
#include "ViewProviderDocumentObject.h"
#include "ViewProviderExtern.h"
@@ -699,18 +696,18 @@ Py::Object View3DInventorPy::isAnimationEnabled(const Py::Tuple& args)
void View3DInventorPy::createImageFromFramebuffer(int width, int height, const QColor& bgcolor, QImage& img)
{
const QGLContext* context = QGLContext::currentContext();
const QtGLContext* context = QtGLContext::currentContext();
if (!context) {
Base::Console().Warning("createImageFromFramebuffer failed because no context is active\n");
return;
}
#if QT_VERSION >= 0x040600
QGLFramebufferObjectFormat format;
QtGLFramebufferObjectFormat format;
format.setSamples(8);
format.setAttachment(QGLFramebufferObject::Depth);
QGLFramebufferObject fbo(width, height, format);
format.setAttachment(QtGLFramebufferObject::Depth);
QtGLFramebufferObject fbo(width, height, format);
#else
QGLFramebufferObject fbo(width, height, QGLFramebufferObject::Depth);
QtGLFramebufferObject fbo(width, height, QtGLFramebufferObject::Depth);
#endif
const QColor col = _view->getViewer()->backgroundColor();
bool on = _view->getViewer()->hasGradientBackground();
@@ -749,7 +746,11 @@ Py::Object View3DInventorPy::saveImage(const Py::Tuple& args)
bg.setNamedColor(colname);
QImage img;
#if !defined(HAVE_QT5_OPENGL)
bool pbuffer = QGLPixelBuffer::hasOpenGLPbuffers();
#else
bool pbuffer = QtGLFramebufferObject::hasOpenGLFramebufferObjects();
#endif
if (App::GetApplication().GetParameterGroupByPath
("User parameter:BaseApp/Preferences/Document")->GetBool("DisablePBuffers",!pbuffer)) {
createImageFromFramebuffer(w, h, bg, img);