summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@digia.com>2014-03-13 12:37:40 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-14 22:39:27 +0100
commitf83ce63fe395f6ebefb2cfb1aa6ddd0929c82433 (patch)
treedf1e4fc36559b20ee1de8df0314ed6ed66ef6c1e
parentf202cd84087f1a049f204fac0dec16ef29e2c8ba (diff)
Add GL information to qpainfo.
Task-number: QTBUG-31611 Change-Id: Ibf9bcb74ed8dbf8625e77ef0870d758a77ea65cb Reviewed-by: Jørgen Lind <jorgen.lind@digia.com> Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
-rw-r--r--tests/manual/qpainfo/main.cpp72
1 files changed, 72 insertions, 0 deletions
diff --git a/tests/manual/qpainfo/main.cpp b/tests/manual/qpainfo/main.cpp
index 02ac88dd06..29e739aa41 100644
--- a/tests/manual/qpainfo/main.cpp
+++ b/tests/manual/qpainfo/main.cpp
@@ -54,6 +54,11 @@
#include <QLibraryInfo>
#include <QStandardPaths>
#include <QDir>
+#ifndef QT_NO_OPENGL
+# include <QOpenGLContext>
+# include <QOpenGLFunctions>
+#endif // QT_NO_OPENGL
+#include <QWindow>
#include <iostream>
#include <string>
@@ -92,6 +97,66 @@ std::ostream &operator<<(std::ostream &str, const QFont &f)
return str;
}
+#ifndef QT_NO_OPENGL
+
+std::ostream &operator<<(std::ostream &str, const QSurfaceFormat &format)
+{
+ str << "Version: " << format.majorVersion() << '.'
+ << format.minorVersion() << " Profile: " << format.profile()
+ << " Swap behavior: " << format.swapBehavior()
+ << " Buffer size (RGB";
+ if (format.hasAlpha())
+ str << 'A';
+ str << "): " << format.redBufferSize() << ',' << format.greenBufferSize()
+ << ',' << format.blueBufferSize();
+ if (format.hasAlpha())
+ str << ',' << format.alphaBufferSize();
+ if (const int dbs = format.depthBufferSize())
+ str << " Depth buffer: " << dbs;
+ if (const int sbs = format.stencilBufferSize())
+ str << " Stencil buffer: " << sbs;
+ const int samples = format.samples();
+ if (samples > 0)
+ str << " Samples: " << samples;
+ return str;
+}
+
+void dumpGlInfo(std::ostream &str)
+{
+ QOpenGLContext context;
+ if (context.create()) {
+# ifdef QT_OPENGL_DYNAMIC
+ str << "Dynamic GL ";
+# endif
+ switch (context.openGLModuleType()) {
+ case QOpenGLContext::DesktopGL:
+ str << "DesktopGL";
+ break;
+ case QOpenGLContext::GLES2:
+ str << "GLES2";
+ break;
+ case QOpenGLContext::GLES1:
+ str << "GLES1";
+ break;
+ }
+ QWindow window;
+ window.setSurfaceType(QSurface::OpenGLSurface);
+ window.create();
+ context.makeCurrent(&window);
+ QOpenGLFunctions functions(&context);
+
+ str << " Vendor: " << functions.glGetString(GL_VENDOR)
+ << "\nRenderer: " << functions.glGetString(GL_RENDERER)
+ << "\nVersion: " << functions.glGetString(GL_VERSION)
+ << "\nShading language: " << functions.glGetString(GL_SHADING_LANGUAGE_VERSION)
+ << "\nFormat: " << context.format();
+ } else {
+ str << "Unable to create an Open GL context.\n";
+ }
+}
+
+#endif // !QT_NO_OPENGL
+
static QStringList toNativeSeparators(QStringList in)
{
for (int i = 0; i < in.size(); ++i)
@@ -211,6 +276,7 @@ int main(int argc, char **argv)
const QScreen *screen = screens.at(s);
std::cout << (screen == QGuiApplication::primaryScreen() ? '*' : ' ')
<< '#' << ' ' << s << " \"" << screen->name().toStdString() << '"'
+ << " Depth: " << screen->depth()
<< "\n Geometry: " << screen->geometry() << " Available: " << screen->availableGeometry();
if (screen->geometry() != screen->virtualGeometry())
std::cout << "\n Virtual geometry: " << screen->virtualGeometry() << " Available: " << screen->availableVirtualGeometry();
@@ -228,5 +294,11 @@ int main(int argc, char **argv)
<< " OrientationUpdateMask: " << screen->orientationUpdateMask()
<< "\n\n";
}
+
+#ifndef QT_NO_OPENGL
+ dumpGlInfo(std::cout);
+ std::cout << "\n\n";
+#endif // !QT_NO_OPENGL
+
return 0;
}