mirror of https://github.com/qt/qtdatavis3d.git
Force software renderer to using ES2
Task-number: QTRD-3410 Change-Id: I86b240b6548ec4c94f6be0dc352ed112965926f3 Change-Id: I86b240b6548ec4c94f6be0dc352ed112965926f3 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@theqtcompany.com>
This commit is contained in:
parent
a1feedcf46
commit
39d5ffbdc4
3
README
3
README
|
|
@ -88,4 +88,5 @@ Known Issues
|
||||||
"QT += datavisualization" in the pro file. This is because Qt Data Visualization QML plugin has
|
"QT += datavisualization" in the pro file. This is because Qt Data Visualization QML plugin has
|
||||||
a dependency to Qt Data Visualization C++ library, which Qt Creator doesn't automatically add
|
a dependency to Qt Data Visualization C++ library, which Qt Creator doesn't automatically add
|
||||||
to the deployment package.
|
to the deployment package.
|
||||||
|
- Only OpenGL ES2 emulation is available for software renderer (that is, when using
|
||||||
|
QCoreApplication::setAttribute(Qt::AA_UseSoftwareOpenGL))
|
||||||
|
|
|
||||||
|
|
@ -338,6 +338,8 @@
|
||||||
"QT += datavisualization" in the pro file. This is because Qt Data Visualization
|
"QT += datavisualization" in the pro file. This is because Qt Data Visualization
|
||||||
QML plugin has a dependency to Qt Data Visualization C++ library, which Qt Creator
|
QML plugin has a dependency to Qt Data Visualization C++ library, which Qt Creator
|
||||||
doesn't automatically add to the deployment package.
|
doesn't automatically add to the deployment package.
|
||||||
|
\li Only OpenGL ES2 emulation is available for software renderer (that is, when using
|
||||||
|
QCoreApplication::setAttribute(Qt::AA_UseSoftwareOpenGL))
|
||||||
\endlist
|
\endlist
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,29 +20,68 @@
|
||||||
#define QUTILS_H
|
#define QUTILS_H
|
||||||
|
|
||||||
#include <QtGui/QSurfaceFormat>
|
#include <QtGui/QSurfaceFormat>
|
||||||
|
#include <QtGui/QOpenGLContext>
|
||||||
|
#include <QtGui/QOffscreenSurface>
|
||||||
|
#include <QtCore/QCoreApplication>
|
||||||
|
|
||||||
namespace QtDataVisualization {
|
namespace QtDataVisualization {
|
||||||
|
|
||||||
inline static QSurfaceFormat qDefaultSurfaceFormat(bool antialias = true)
|
inline static QSurfaceFormat qDefaultSurfaceFormat(bool antialias = true)
|
||||||
{
|
{
|
||||||
|
bool isES = false;
|
||||||
|
|
||||||
QSurfaceFormat surfaceFormat;
|
QSurfaceFormat surfaceFormat;
|
||||||
|
|
||||||
|
// Common attributes
|
||||||
surfaceFormat.setDepthBufferSize(24);
|
surfaceFormat.setDepthBufferSize(24);
|
||||||
surfaceFormat.setStencilBufferSize(8);
|
surfaceFormat.setStencilBufferSize(8);
|
||||||
surfaceFormat.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
|
surfaceFormat.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
|
||||||
surfaceFormat.setRenderableType(QSurfaceFormat::DefaultRenderableType);
|
surfaceFormat.setRenderableType(QSurfaceFormat::DefaultRenderableType);
|
||||||
|
|
||||||
|
QOpenGLContext *ctx = QOpenGLContext::currentContext();
|
||||||
|
QOffscreenSurface *dummySurface = 0;
|
||||||
|
if (!ctx) {
|
||||||
|
dummySurface = new QOffscreenSurface();
|
||||||
|
dummySurface->setFormat(surfaceFormat);
|
||||||
|
dummySurface->create();
|
||||||
|
ctx = new QOpenGLContext;
|
||||||
|
ctx->setFormat(surfaceFormat);
|
||||||
|
ctx->create();
|
||||||
|
ctx->makeCurrent(dummySurface);
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(QT_OPENGL_ES_2)
|
#if defined(QT_OPENGL_ES_2)
|
||||||
// Antialias not supported for ES
|
isES = true;
|
||||||
antialias = false;
|
#elif (QT_VERSION < QT_VERSION_CHECK(5, 3, 0))
|
||||||
surfaceFormat.setRedBufferSize(8);
|
isES = false;
|
||||||
surfaceFormat.setBlueBufferSize(8);
|
#else
|
||||||
surfaceFormat.setGreenBufferSize(8);
|
isES = ctx->isOpenGLES();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (antialias)
|
if (dummySurface) {
|
||||||
surfaceFormat.setSamples(8);
|
ctx->doneCurrent();
|
||||||
else
|
delete ctx;
|
||||||
surfaceFormat.setSamples(0);
|
delete dummySurface;
|
||||||
|
}
|
||||||
|
|
||||||
|
// We support only ES2 emulation with software renderer for now
|
||||||
|
if (QCoreApplication::testAttribute(Qt::AA_UseSoftwareOpenGL)) {
|
||||||
|
qWarning("Only OpenGL ES2 emulation is available for software rendering.");
|
||||||
|
isES = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isES) {
|
||||||
|
// For ES2 only attributes
|
||||||
|
surfaceFormat.setRedBufferSize(8);
|
||||||
|
surfaceFormat.setBlueBufferSize(8);
|
||||||
|
surfaceFormat.setGreenBufferSize(8);
|
||||||
|
} else {
|
||||||
|
// For OpenGL only attributes
|
||||||
|
if (antialias)
|
||||||
|
surfaceFormat.setSamples(8);
|
||||||
|
else
|
||||||
|
surfaceFormat.setSamples(0);
|
||||||
|
}
|
||||||
|
|
||||||
return surfaceFormat;
|
return surfaceFormat;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -329,7 +329,7 @@ void Utils::resolveStatics()
|
||||||
QOpenGLContext *ctx = QOpenGLContext::currentContext();
|
QOpenGLContext *ctx = QOpenGLContext::currentContext();
|
||||||
QOffscreenSurface *dummySurface = 0;
|
QOffscreenSurface *dummySurface = 0;
|
||||||
if (!ctx) {
|
if (!ctx) {
|
||||||
QSurfaceFormat surfaceFormat = qDefaultSurfaceFormat();
|
QSurfaceFormat surfaceFormat;
|
||||||
dummySurface = new QOffscreenSurface();
|
dummySurface = new QOffscreenSurface();
|
||||||
dummySurface->setFormat(surfaceFormat);
|
dummySurface->setFormat(surfaceFormat);
|
||||||
dummySurface->create();
|
dummySurface->create();
|
||||||
|
|
@ -355,6 +355,12 @@ void Utils::resolveStatics()
|
||||||
delete dummySurface;
|
delete dummySurface;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We support only ES2 emulation with software renderer for now
|
||||||
|
if (QCoreApplication::testAttribute(Qt::AA_UseSoftwareOpenGL)) {
|
||||||
|
qWarning("Only OpenGL ES2 emulation is available for software rendering.");
|
||||||
|
isES = true;
|
||||||
|
}
|
||||||
|
|
||||||
staticsResolved = true;
|
staticsResolved = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue