diff options
author | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2012-07-03 20:47:44 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-07-09 17:49:48 +0200 |
commit | c8c2f3ba5de7c3d5a9e94d1b0d26715f083023b0 (patch) | |
tree | 2236505f9824bde3f5129848e2d6d40a37e14f4f /tools | |
parent | 1dbec879b1f6b309a0c63ef7861c4ca00c5fb12c (diff) |
rename util/ => tools/
to fit generic naming convention
Change-Id: I06c1f52bff24038bf4d211a33e0569cb2e214566
Reviewed-by: Danny Pope <daniel.pope@nokia.com>
Diffstat (limited to 'tools')
24 files changed, 2419 insertions, 0 deletions
diff --git a/tools/gencube/gencube.cpp b/tools/gencube/gencube.cpp new file mode 100644 index 000000000..6fedf406c --- /dev/null +++ b/tools/gencube/gencube.cpp @@ -0,0 +1,152 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// Used to generate the cube vertex arrays for qglcube.cpp. + +#include <stdio.h> + +static float const normals[6 * 3] = { + -1.0f, 0.0f, 0.0f, + 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, + 0.0f, -1.0f, 0.0f, + 0.0f, 0.0f, 1.0f, + 0.0f, 0.0f, -1.0f +}; + +static float const vertices[8 * 3] = { + -0.5f, -0.5f, -0.5f, + -0.5f, -0.5f, 0.5f, + -0.5f, 0.5f, 0.5f, + -0.5f, 0.5f, -0.5f, + 0.5f, -0.5f, -0.5f, + 0.5f, -0.5f, 0.5f, + 0.5f, 0.5f, 0.5f, + 0.5f, 0.5f, -0.5f +}; + +static float const texCoords[4 * 2] = { + 1.0f, 0.0f, + 1.0f, 1.0f, + 0.0f, 1.0f, + 0.0f, 0.0f +}; + +static unsigned short const indices[6 * 4] = { + 0, 1, 2, 3, 3, 2, 6, 7, 7, 6, 5, 4, + 4, 5, 1, 0, 5, 6, 2, 1, 7, 4, 0, 3 +}; + +int main(int argc, char *argv[]) +{ + float vert[6][6][3]; + float norm[6][6][3]; + float tcoords[6][6][2]; + for (int face = 0; face < 6; ++face) { + norm[face][0][0] = normals[face * 3 + 0]; + norm[face][0][1] = normals[face * 3 + 1]; + norm[face][0][2] = normals[face * 3 + 2]; + norm[face][1][0] = normals[face * 3 + 0]; + norm[face][1][1] = normals[face * 3 + 1]; + norm[face][1][2] = normals[face * 3 + 2]; + norm[face][2][0] = normals[face * 3 + 0]; + norm[face][2][1] = normals[face * 3 + 1]; + norm[face][2][2] = normals[face * 3 + 2]; + norm[face][3][0] = normals[face * 3 + 0]; + norm[face][3][1] = normals[face * 3 + 1]; + norm[face][3][2] = normals[face * 3 + 2]; + norm[face][4][0] = normals[face * 3 + 0]; + norm[face][4][1] = normals[face * 3 + 1]; + norm[face][4][2] = normals[face * 3 + 2]; + norm[face][5][0] = normals[face * 3 + 0]; + norm[face][5][1] = normals[face * 3 + 1]; + norm[face][5][2] = normals[face * 3 + 2]; + + vert[face][0][0] = vertices[indices[face * 4] * 3 + 0]; + vert[face][0][1] = vertices[indices[face * 4] * 3 + 1]; + vert[face][0][2] = vertices[indices[face * 4] * 3 + 2]; + vert[face][1][0] = vertices[indices[face * 4 + 1] * 3 + 0]; + vert[face][1][1] = vertices[indices[face * 4 + 1] * 3 + 1]; + vert[face][1][2] = vertices[indices[face * 4 + 1] * 3 + 2]; + vert[face][2][0] = vertices[indices[face * 4 + 2] * 3 + 0]; + vert[face][2][1] = vertices[indices[face * 4 + 2] * 3 + 1]; + vert[face][2][2] = vertices[indices[face * 4 + 2] * 3 + 2]; + vert[face][3][0] = vertices[indices[face * 4] * 3 + 0]; + vert[face][3][1] = vertices[indices[face * 4] * 3 + 1]; + vert[face][3][2] = vertices[indices[face * 4] * 3 + 2]; + vert[face][4][0] = vertices[indices[face * 4 + 2] * 3 + 0]; + vert[face][4][1] = vertices[indices[face * 4 + 2] * 3 + 1]; + vert[face][4][2] = vertices[indices[face * 4 + 2] * 3 + 2]; + vert[face][5][0] = vertices[indices[face * 4 + 3] * 3 + 0]; + vert[face][5][1] = vertices[indices[face * 4 + 3] * 3 + 1]; + vert[face][5][2] = vertices[indices[face * 4 + 3] * 3 + 2]; + + tcoords[face][0][0] = texCoords[0]; + tcoords[face][0][1] = texCoords[1]; + tcoords[face][1][0] = texCoords[2]; + tcoords[face][1][1] = texCoords[3]; + tcoords[face][2][0] = texCoords[4]; + tcoords[face][2][1] = texCoords[5]; + tcoords[face][3][0] = texCoords[0]; + tcoords[face][3][1] = texCoords[1]; + tcoords[face][4][0] = texCoords[4]; + tcoords[face][4][1] = texCoords[5]; + tcoords[face][5][0] = texCoords[6]; + tcoords[face][5][1] = texCoords[7]; + } + printf("#define QGL_CUBE_SIZE (6 * 6 * (3 + 3 + 2))\n"); + printf("static float const cubeVertices[QGL_CUBE_SIZE] = {\n"); + for (int face = 0; face < 6; ++face) { + for (int index = 0; index < 6; ++index) { + printf(" %.1ff, %.1ff, %.1ff, ", + vert[face][index][0], vert[face][index][1], + vert[face][index][2]); + printf("%.1ff, %.1ff, %.1ff, ", + norm[face][index][0], norm[face][index][1], + norm[face][index][2]); + printf("%.1ff, %.1ff,\n", + tcoords[face][index][0], tcoords[face][index][1]); + } + printf("\n"); + } + printf("};\n\n"); + return 0; +} diff --git a/tools/gencube/genobjcube.cpp b/tools/gencube/genobjcube.cpp new file mode 100644 index 000000000..75edbd975 --- /dev/null +++ b/tools/gencube/genobjcube.cpp @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// Used to generate cube.obj. + +#include <stdio.h> + +static float const normals[6 * 3] = { + -1.0f, 0.0f, 0.0f, + 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, + 0.0f, -1.0f, 0.0f, + 0.0f, 0.0f, 1.0f, + 0.0f, 0.0f, -1.0f +}; + +static float const vertices[8 * 3] = { + -0.5f, -0.5f, -0.5f, + -0.5f, -0.5f, 0.5f, + -0.5f, 0.5f, 0.5f, + -0.5f, 0.5f, -0.5f, + 0.5f, -0.5f, -0.5f, + 0.5f, -0.5f, 0.5f, + 0.5f, 0.5f, 0.5f, + 0.5f, 0.5f, -0.5f +}; + +static float const texCoords[4 * 2] = { + 1.0f, 0.0f, + 1.0f, 1.0f, + 0.0f, 1.0f, + 0.0f, 0.0f +}; + +static unsigned short const indices[6 * 4] = { + 0, 1, 2, 3, 3, 2, 6, 7, 7, 6, 5, 4, + 4, 5, 1, 0, 5, 6, 2, 1, 7, 4, 0, 3 +}; + +int main(int argc, char *argv[]) +{ + printf("s 0\n"); + for (int vert = 0; vert < 8; ++vert) { + printf("v %.1f %.1f %.1f\n", + vertices[vert * 3 + 0], + vertices[vert * 3 + 1], + vertices[vert * 3 + 2]); + } + for (int norm = 0; norm < 6; ++norm) { + printf("vn %.1f %.1f %.1f\n", + normals[norm * 3 + 0], + normals[norm * 3 + 1], + normals[norm * 3 + 2]); + } + for (int tex = 0; tex < 4; ++tex) { + printf("vt %.1f %.1f\n", + texCoords[tex * 2 + 0], + texCoords[tex * 2 + 1]); + } + for (int face = 0; face < 6; ++face) { + printf("f %d/%d/%d %d/%d/%d %d/%d/%d %d/%d/%d\n", + indices[face * 4 + 0] + 1, 1, face + 1, + indices[face * 4 + 1] + 1, 2, face + 1, + indices[face * 4 + 2] + 1, 3, face + 1, + indices[face * 4 + 3] + 1, 4, face + 1); + } + return 0; +} diff --git a/tools/meshcvt/README b/tools/meshcvt/README new file mode 100644 index 000000000..71679eff1 --- /dev/null +++ b/tools/meshcvt/README @@ -0,0 +1,32 @@ +This program converts an object defined as a set of Bezier patches +into vertex array data that can be used to draw it. A Bezier patch +is a curved surface defined in terms of 16 control points. +The object is decomposed into triangles for rendering. + +The primary use for this program is to convert the patch data from +http://www.sjbaker.org/teapot/teaset.tgz for the classic 3D teapot, +but it should work on other objects defined as Bezier patches +or triangle meshes. + +The usage for this utility is: + + meshcvt mesh-filename name [depth] + +The data to represent the object will be written to standard output. +The "depth" parameter indicates the recursive depth for sub-dividing +Bezier patches into triangles. The default value is 4. + +The input file format starts with the number of patches. +The following lines contain 16 indices to define a patch. +The indices should be comma-separated. + +Following the index groups is the number of vertices, and then that +many vertex definitions. Each vertex definition consists of three +floating-point values, comma-separated. Three more comma-separated +floating-point values can appear on the line after the vertex +co-ordinates to define a vertex normal. + +The teapot.txt file provides the data for the classic 3D teapot +from the above URL as an example of what a Bezier patch definition +file looks like. The above URL also has Bezier patch data for a +teacup and a teaspoon, to complete your tea service. diff --git a/tools/meshcvt/meshcvt.cpp b/tools/meshcvt/meshcvt.cpp new file mode 100644 index 000000000..d4d8f3d41 --- /dev/null +++ b/tools/meshcvt/meshcvt.cpp @@ -0,0 +1,216 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <QtGui/qvector3d.h> +#include "qarray.h" + +static void meshError(const char *filename) +{ + qWarning("%s: does not contain valid mesh data\n", filename); + exit(1); +} + +static int numPatches = 0; +static int numVertices = 0; +static int *patches = 0; + +int main(int argc, char *argv[]) +{ + int depth = 4; + int teapotAdjust = 0; + int reversePatches = 0; + char buffer[BUFSIZ]; + char *filename; + char *name; + QArray<QVector3D> vertices; + + // Validate the command-line arguments. + if (argc < 3) { + qWarning("Usage: %s [--teapot-adjust] [--reverse-patches] mesh-filename name [depth]\n", argv[0]); + return 1; + } + if (!strcmp(argv[1], "--teapot-adjust")) { + // Adjust the vertices to correctly size and position the teapot. + ++argv; + --argc; + teapotAdjust = 1; + } + if (!strcmp(argv[1], "--reverse-patches")) { + // Reverse the coordinate order of patches (fixes teacup). + ++argv; + --argc; + reversePatches = 1; + } + filename = argv[1]; + name = argv[2]; + if (argc > 3) + depth = atoi(argv[3]); + + // Read the mesh data from the input file and determine + // if it is a Bezier patch mesh or a triangle mesh. + FILE *file; + if ((file = fopen(filename, "r")) == NULL) { + perror(filename); + return 1; + } + if (fscanf(file, "%i\n", &numPatches) != 1) + meshError(filename); + patches = new int [numPatches * 17]; + for (int patch = 0; patch < numPatches; ++patch) { + int *p = patches + patch * 17; + if (!fgets(buffer, sizeof(buffer), file)) + meshError(filename); + if (sscanf(buffer, "%i, %i, %i, %i, %i, %i, %i, %i, " + "%i, %i, %i, %i, %i, %i, %i, %i, %i\n", + p, p + 1, p + 2, p + 3, + p + 4, p + 5, p + 6, p + 7, + p + 8, p + 9, p + 10, p + 11, + p + 12, p + 13, p + 14, p + 15, p + 16) != 17) { + if (sscanf(buffer, "%i, %i, %i, %i, %i, %i, %i, %i, " + "%i, %i, %i, %i, %i, %i, %i, %i\n", + p, p + 1, p + 2, p + 3, + p + 4, p + 5, p + 6, p + 7, + p + 8, p + 9, p + 10, p + 11, + p + 12, p + 13, p + 14, p + 15) != 16) { + meshError(filename); + } else { + p[16] = -1; // Use the default minimum depth value. + } + } + if (reversePatches) { + int reversed[16]; + for (int i = 0; i < 16; ++i) + reversed[i] = p[(i & 0x0C) + (3 - (i % 4))]; + for (int i = 0; i < 16; ++i) + p[i] = reversed[i]; + } + // The standard patch indices are 1-based, not 0-based. + // Correct for that problem here. + for (int offset = 0; offset < 16; ++offset) + --(p[offset]); + } + if (fscanf(file, "%i\n", &numVertices) != 1) + meshError(filename); + for (int vertex = 0; vertex < numVertices; ++vertex) { + float x, y, z, xnormal, ynormal, znormal; + if (!fgets(buffer, sizeof(buffer), file)) + meshError(filename); + if (sscanf(buffer, "%f, %f, %f, %f, %f, %f\n", + &x, &y, &z, &xnormal, &ynormal, &znormal) != 6) { + if (sscanf(buffer, "%f, %f, %f\n", &x, &y, &z) != 3) + meshError(filename); + } + if (teapotAdjust) { + // Do the equivalent of the following transformation: + // matrix.rotate(270.0f, 1.0f, 0.0f, 0.0f); + // matrix.scale(0.5f, 0.5f, 0.5f); + // matrix.translate(0.0f, 0.0f, -1.5f); + z -= 1.5f; + x *= 0.5f; + y *= 0.5f; + z *= 0.5f; + float y2 = z; + float z2 = -y; + y = y2; + z = z2; + } + vertices.append(QVector3D(x, y, z)); + } + fclose(file); + + // Generate the output data. + printf("// Generated from %s by meshcvt, depth = %d\n\n", filename, depth); + printf("#define %sBezierVertexCount %d\n", name, numVertices); + printf("#define %sPatchCount %d\n", name, numPatches); + printf("#define %sDepth %d\n", name, depth); + printf("static float const %sBezierVertexData[] = {\n", name); + for (int vertex = 0; vertex < vertices.count(); ++vertex) { + QVector3D v = vertices[vertex]; + printf(" %ff, %ff, %ff", v.x(), v.y(), v.z()); + if (vertex < (vertices.count() - 1)) + printf(",\n"); + else + printf("\n"); + } + printf("};\n\n"); + printf("static ushort const %sPatchData[] = {\n", name); + for (int patch = 0; patch < numPatches; ++patch) { + int *p = patches + patch * 17; + printf(" %d, %d, %d, %d, %d, %d, %d, %d, " + "%d, %d, %d, %d, %d, %d, %d, %d", + p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], + p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15]); + if (patch < (numPatches - 1)) + printf(",\n"); + else + printf("\n"); + } + printf("};\n"); + printf("\n"); + printf("class %sPatches : public QGLBezierPatches\n{\n", name); + printf("public:\n"); + printf(" %sPatches()\n", name); + printf(" {\n"); + printf(" QVector3DArray positions;\n"); + printf(" for (int pindex = 0; pindex < %sPatchCount * 16; ++pindex) {\n", name); + printf(" int vindex = %sPatchData[pindex];\n", name); + printf(" positions.append(%sBezierVertexData[vindex * 3],\n", name); + printf(" %sBezierVertexData[vindex * 3 + 1],\n", name); + printf(" %sBezierVertexData[vindex * 3 + 2]);\n", name); + printf(" }\n"); + printf(" setPositions(positions);\n"); + printf(" setSubdivisionDepth(%sDepth);\n", name); + printf(" }\n"); + printf("};\n"); + + // Dump some statistics to stderr. + qWarning("Depth: %d\n", depth); + qWarning("Number of vertices: %d\n", numVertices); + qWarning("Number of patches: %d\n", numPatches); + int storage = numVertices * sizeof(float) * 3; + storage += numPatches * sizeof(ushort); + qWarning("Bezier storage: %d bytes\n", storage); + + return 0; +} diff --git a/tools/meshcvt/meshcvt.pro b/tools/meshcvt/meshcvt.pro new file mode 100644 index 000000000..5df99ce3f --- /dev/null +++ b/tools/meshcvt/meshcvt.pro @@ -0,0 +1,8 @@ +TARGET = meshcvt + +QT += 3d + +SOURCES += \ + meshcvt.cpp \ + +win32:DEFINES+=_CRT_SECURE_NO_WARNINGS diff --git a/tools/meshcvt/teapot.txt b/tools/meshcvt/teapot.txt new file mode 100644 index 000000000..9f62bb5e9 --- /dev/null +++ b/tools/meshcvt/teapot.txt @@ -0,0 +1,340 @@ +32 +1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 +4,17,18,19,8,20,21,22,12,23,24,25,16,26,27,28 +19,29,30,31,22,32,33,34,25,35,36,37,28,38,39,40 +31,41,42,1,34,43,44,5,37,45,46,9,40,47,48,13 +13,14,15,16,49,50,51,52,53,54,55,56,57,58,59,60 +16,26,27,28,52,61,62,63,56,64,65,66,60,67,68,69 +28,38,39,40,63,70,71,72,66,73,74,75,69,76,77,78 +40,47,48,13,72,79,80,49,75,81,82,53,78,83,84,57 +57,58,59,60,85,86,87,88,89,90,91,92,93,94,95,96 +60,67,68,69,88,97,98,99,92,100,101,102,96,103,104,105 +69,76,77,78,99,106,107,108,102,109,110,111,105,112,113,114 +78,83,84,57,108,115,116,85,111,117,118,89,114,119,120,93 +121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136 +124,137,138,121,128,139,140,125,132,141,142,129,136,143,144,133 +133,134,135,136,145,146,147,148,149,150,151,152,69,153,154,155 +136,143,144,133,148,156,157,145,152,158,159,149,155,160,161,69 +162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177 +165,178,179,162,169,180,181,166,173,182,183,170,177,184,185,174 +174,175,176,177,186,187,188,189,190,191,192,193,194,195,196,197 +177,184,185,174,189,198,199,186,193,200,201,190,197,202,203,194 +204,204,204,204,207,208,209,210,211,211,211,211,212,213,214,215,4 +204,204,204,204,210,217,218,219,211,211,211,211,215,220,221,222,4 +204,204,204,204,219,224,225,226,211,211,211,211,222,227,228,229,4 +204,204,204,204,226,230,231,207,211,211,211,211,229,232,233,212,4 +212,213,214,215,234,235,236,237,238,239,240,241,242,243,244,245 +215,220,221,222,237,246,247,248,241,249,250,251,245,252,253,254 +222,227,228,229,248,255,256,257,251,258,259,260,254,261,262,263 +229,232,233,212,257,264,265,234,260,266,267,238,263,268,269,242 +270,270,270,270,279,280,281,282,275,276,277,278,271,272,273,274,4 +270,270,270,270,282,289,290,291,278,286,287,288,274,283,284,285,4 +270,270,270,270,291,298,299,300,288,295,296,297,285,292,293,294,4 +270,270,270,270,300,305,306,279,297,303,304,275,294,301,302,271,4 +306 +1.4,0.0,2.4 +1.4,-0.784,2.4 +0.784,-1.4,2.4 +0.0,-1.4,2.4 +1.3375,0.0,2.53125 +1.3375,-0.749,2.53125 +0.749,-1.3375,2.53125 +0.0,-1.3375,2.53125 +1.4375,0.0,2.53125 +1.4375,-0.805,2.53125 +0.805,-1.4375,2.53125 +0.0,-1.4375,2.53125 +1.5,0.0,2.4 +1.5,-0.84,2.4 +0.84,-1.5,2.4 +0.0,-1.5,2.4 +-0.784,-1.4,2.4 +-1.4,-0.784,2.4 +-1.4,0.0,2.4 +-0.749,-1.3375,2.53125 +-1.3375,-0.749,2.53125 +-1.3375,0.0,2.53125 +-0.805,-1.4375,2.53125 +-1.4375,-0.805,2.53125 +-1.4375,0.0,2.53125 +-0.84,-1.5,2.4 +-1.5,-0.84,2.4 +-1.5,0.0,2.4 +-1.4,0.784,2.4 +-0.784,1.4,2.4 +0.0,1.4,2.4 +-1.3375,0.749,2.53125 +-0.749,1.3375,2.53125 +0.0,1.3375,2.53125 +-1.4375,0.805,2.53125 +-0.805,1.4375,2.53125 +0.0,1.4375,2.53125 +-1.5,0.84,2.4 +-0.84,1.5,2.4 +0.0,1.5,2.4 +0.784,1.4,2.4 +1.4,0.784,2.4 +0.749,1.3375,2.53125 +1.3375,0.749,2.53125 +0.805,1.4375,2.53125 +1.4375,0.805,2.53125 +0.84,1.5,2.4 +1.5,0.84,2.4 +1.75,0.0,1.875 +1.75,-0.98,1.875 +0.98,-1.75,1.875 +0.0,-1.75,1.875 +2.0,0.0,1.35 +2.0,-1.12,1.35 +1.12,-2.0,1.35 +0.0,-2.0,1.35 +2.0,0.0,0.9 +2.0,-1.12,0.9 +1.12,-2.0,0.9 +0.0,-2.0,0.9 +-0.98,-1.75,1.875 +-1.75,-0.98,1.875 +-1.75,0.0,1.875 +-1.12,-2.0,1.35 +-2.0,-1.12,1.35 +-2.0,0.0,1.35 +-1.12,-2.0,0.9 +-2.0,-1.12,0.9 +-2.0,0.0,0.9 +-1.75,0.98,1.875 +-0.98,1.75,1.875 +0.0,1.75,1.875 +-2.0,1.12,1.35 +-1.12,2.0,1.35 +0.0,2.0,1.35 +-2.0,1.12,0.9 +-1.12,2.0,0.9 +0.0,2.0,0.9 +0.98,1.75,1.875 +1.75,0.98,1.875 +1.12,2.0,1.35 +2.0,1.12,1.35 +1.12,2.0,0.9 +2.0,1.12,0.9 +2.0,0.0,0.45 +2.0,-1.12,0.45 +1.12,-2.0,0.45 +0.0,-2.0,0.45 +1.5,0.0,0.225 +1.5,-0.84,0.225 +0.84,-1.5,0.225 +0.0,-1.5,0.225 +1.5,0.0,0.15 +1.5,-0.84,0.15 +0.84,-1.5,0.15 +0.0,-1.5,0.15 +-1.12,-2.0,0.45 +-2.0,-1.12,0.45 +-2.0,0.0,0.45 +-0.84,-1.5,0.225 +-1.5,-0.84,0.225 +-1.5,0.0,0.225 +-0.84,-1.5,0.15 +-1.5,-0.84,0.15 +-1.5,0.0,0.15 +-2.0,1.12,0.45 +-1.12,2.0,0.45 +0.0,2.0,0.45 +-1.5,0.84,0.225 +-0.84,1.5,0.225 +0.0,1.5,0.225 +-1.5,0.84,0.15 +-0.84,1.5,0.15 +0.0,1.5,0.15 +1.12,2.0,0.45 +2.0,1.12,0.45 +0.84,1.5,0.225 +1.5,0.84,0.225 +0.84,1.5,0.15 +1.5,0.84,0.15 +-1.6,0.0,2.025 +-1.6,-0.3,2.025 +-1.5,-0.3,2.25 +-1.5,0.0,2.25 +-2.3,0.0,2.025 +-2.3,-0.3,2.025 +-2.5,-0.3,2.25 +-2.5,0.0,2.25 +-2.7,0.0,2.025 +-2.7,-0.3,2.025 +-3.0,-0.3,2.25 +-3.0,0.0,2.25 +-2.7,0.0,1.8 +-2.7,-0.3,1.8 +-3.0,-0.3,1.8 +-3.0,0.0,1.8 +-1.5,0.3,2.25 +-1.6,0.3,2.025 +-2.5,0.3,2.25 +-2.3,0.3,2.025 +-3.0,0.3,2.25 +-2.7,0.3,2.025 +-3.0,0.3,1.8 +-2.7,0.3,1.8 +-2.7,0.0,1.575 +-2.7,-0.3,1.575 +-3.0,-0.3,1.35 +-3.0,0.0,1.35 +-2.5,0.0,1.125 +-2.5,-0.3,1.125 +-2.65,-0.3,0.9375 +-2.65,0.0,0.9375 +-2.0,-0.3,0.9 +-1.9,-0.3,0.6 +-1.9,0.0,0.6 +-3.0,0.3,1.35 +-2.7,0.3,1.575 +-2.65,0.3,0.9375 +-2.5,0.3,1.125 +-1.9,0.3,0.6 +-2.0,0.3,0.9 +1.7,0.0,1.425 +1.7,-0.66,1.425 +1.7,-0.66,0.6 +1.7,0.0,0.6 +2.6,0.0,1.425 +2.6,-0.66,1.425 +3.1,-0.66,0.825 +3.1,0.0,0.825 +2.3,0.0,2.1 +2.3,-0.25,2.1 +2.4,-0.25,2.025 +2.4,0.0,2.025 +2.7,0.0,2.4 +2.7,-0.25,2.4 +3.3,-0.25,2.4 +3.3,0.0,2.4 +1.7,0.66,0.6 +1.7,0.66,1.425 +3.1,0.66,0.825 +2.6,0.66,1.425 +2.4,0.25,2.025 +2.3,0.25,2.1 +3.3,0.25,2.4 +2.7,0.25,2.4 +2.8,0.0,2.475 +2.8,-0.25,2.475 +3.525,-0.25,2.49375 +3.525,0.0,2.49375 +2.9,0.0,2.475 +2.9,-0.15,2.475 +3.45,-0.15,2.5125 +3.45,0.0,2.5125 +2.8,0.0,2.4 +2.8,-0.15,2.4 +3.2,-0.15,2.4 +3.2,0.0,2.4 +3.525,0.25,2.49375 +2.8,0.25,2.475 +3.45,0.15,2.5125 +2.9,0.15,2.475 +3.2,0.15,2.4 +2.8,0.15,2.4 +0.0,0.0,3.15 +0.0,-0.002,3.15 +0.002,0.0,3.15 +0.8,0.0,3.15 +0.8,-0.45,3.15 +0.45,-0.8,3.15 +0.0,-0.8,3.15 +0.0,0.0,2.85,0.0,0.0,1.0 +0.2,0.0,2.7 +0.2,-0.112,2.7 +0.112,-0.2,2.7 +0.0,-0.2,2.7 +-0.002,0.0,3.15 +-0.45,-0.8,3.15 +-0.8,-0.45,3.15 +-0.8,0.0,3.15 +-0.112,-0.2,2.7 +-0.2,-0.112,2.7 +-0.2,0.0,2.7 +0.0,0.002,3.15 +-0.8,0.45,3.15 +-0.45,0.8,3.15 +0.0,0.8,3.15 +-0.2,0.112,2.7 +-0.112,0.2,2.7 +0.0,0.2,2.7 +0.45,0.8,3.15 +0.8,0.45,3.15 +0.112,0.2,2.7 +0.2,0.112,2.7 +0.4,0.0,2.55 +0.4,-0.224,2.55 +0.224,-0.4,2.55 +0.0,-0.4,2.55 +1.3,0.0,2.55 +1.3,-0.728,2.55 +0.728,-1.3,2.55 +0.0,-1.3,2.55 +1.3,0.0,2.4 +1.3,-0.728,2.4 +0.728,-1.3,2.4 +0.0,-1.3,2.4 +-0.224,-0.4,2.55 +-0.4,-0.224,2.55 +-0.4,0.0,2.55 +-0.728,-1.3,2.55 +-1.3,-0.728,2.55 +-1.3,0.0,2.55 +-0.728,-1.3,2.4 +-1.3,-0.728,2.4 +-1.3,0.0,2.4 +-0.4,0.224,2.55 +-0.224,0.4,2.55 +0.0,0.4,2.55 +-1.3,0.728,2.55 +-0.728,1.3,2.55 +0.0,1.3,2.55 +-1.3,0.728,2.4 +-0.728,1.3,2.4 +0.0,1.3,2.4 +0.224,0.4,2.55 +0.4,0.224,2.55 +0.728,1.3,2.55 +1.3,0.728,2.55 +0.728,1.3,2.4 +1.3,0.728,2.4 +0.0,0.0,0.0,0.0,0.0,-1.0 +1.5,0.0,0.15 +1.5,0.84,0.15 +0.84,1.5,0.15 +0.0,1.5,0.15 +1.5,0.0,0.075 +1.5,0.84,0.075 +0.84,1.5,0.075 +0.0,1.5,0.075 +1.425,0.0,0.0 +1.425,0.798,0.0 +0.798,1.425,0.0 +0.0,1.425,0.0 +-0.84,1.5,0.15 +-1.5,0.84,0.15 +-1.5,0.0,0.15 +-0.84,1.5,0.075 +-1.5,0.84,0.075 +-1.5,0.0,0.075 +-0.798,1.425,0.0 +-1.425,0.798,0.0 +-1.425,0.0,0.0 +-1.5,-0.84,0.15 +-0.84,-1.5,0.15 +0.0,-1.5,0.15 +-1.5,-0.84,0.075 +-0.84,-1.5,0.075 +0.0,-1.5,0.075 +-1.425,-0.798,0.0 +-0.798,-1.425,0.0 +0.0,-1.425,0.0 +0.84,-1.5,0.15 +1.5,-0.84,0.15 +0.84,-1.5,0.075 +1.5,-0.84,0.075 +0.798,-1.425,0.0 +1.425,-0.798,0.0 diff --git a/tools/qt3d/qglinfo/aboutdialog.cpp b/tools/qt3d/qglinfo/aboutdialog.cpp new file mode 100644 index 000000000..ab289d039 --- /dev/null +++ b/tools/qt3d/qglinfo/aboutdialog.cpp @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "aboutdialog.h" +#include "ui_aboutdialog.h" + +AboutDialog::AboutDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::AboutDialog) +{ + ui->setupUi(this); +} + +AboutDialog::~AboutDialog() +{ + delete ui; +} + +void AboutDialog::changeEvent(QEvent *e) +{ + QDialog::changeEvent(e); + switch (e->type()) { + case QEvent::LanguageChange: + ui->retranslateUi(this); + break; + default: + break; + } +} + +void AboutDialog::on_pushButton_clicked() +{ + close(); +} diff --git a/tools/qt3d/qglinfo/aboutdialog.h b/tools/qt3d/qglinfo/aboutdialog.h new file mode 100644 index 000000000..0a7977b55 --- /dev/null +++ b/tools/qt3d/qglinfo/aboutdialog.h @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef ABOUTDIALOG_H +#define ABOUTDIALOG_H + +#include <QDialog> + +namespace Ui { + class AboutDialog; +} + +class AboutDialog : public QDialog { + Q_OBJECT +public: + AboutDialog(QWidget *parent = 0); + ~AboutDialog(); + +protected: + void changeEvent(QEvent *e); + +private: + Ui::AboutDialog *ui; + +private slots: + void on_pushButton_clicked(); +}; + +#endif // ABOUTDIALOG_H diff --git a/tools/qt3d/qglinfo/aboutdialog.ui b/tools/qt3d/qglinfo/aboutdialog.ui new file mode 100644 index 000000000..7807a5b6b --- /dev/null +++ b/tools/qt3d/qglinfo/aboutdialog.ui @@ -0,0 +1,72 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>AboutDialog</class> + <widget class="QDialog" name="AboutDialog"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>375</width> + <height>456</height> + </rect> + </property> + <property name="windowTitle"> + <string>About</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QLabel" name="label"> + <property name="maximumSize"> + <size> + <width>400</width> + <height>16777215</height> + </size> + </property> + <property name="text"> + <string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Lucida Grande'; font-size:13pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:20pt;">QGL Info Tool</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:20pt;"></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:14pt;"> </span><span style=" font-size:12pt;">Qt3D is Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt;"> Contact: http://www.qt-project.org/</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt;"> Qt3D is available under the GPL.</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:14pt;"></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:14pt;"></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt;">Qt3D gratefully acknowledges the</span><span style=" font-size:14pt;"> </span><a href="http://assimp.sourceforge.net/"><span style=" text-decoration: underline; color:#0000ff;">The Open Asset Importer Library</span></a><span style=" font-size:14pt;"> </span><span style=" font-size:12pt;">project (AssImp) which provides all 3D asset file loading in the Qt3D project. Qt3D ships with AssImp which in turn includes code from Info-ZIP (by Mark Adler et al), PStdInt (by Paul Hsieh), PicoModel (by Randy Reddig &amp; seaw0lf).</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:12pt;"></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt;">See the file licensing.html in your documentation package or </span><a href="http://doc-snapshot.qt-project.org/qt3d-1.0/licensing.html"><span style=" text-decoration: underline; color:#0000ff;">on-line</span></a><span style=" font-size:12pt;"> for further details.</span></p></body></html></string> + </property> + <property name="wordWrap"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string/> + </property> + <property name="pixmap"> + <pixmap resource="qglinfo.qrc">:/images/teapot</pixmap> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="pushButton"> + <property name="text"> + <string>Ok</string> + </property> + </widget> + </item> + </layout> + </widget> + <resources> + <include location="qglinfo.qrc"/> + </resources> + <connections/> +</ui> diff --git a/tools/qt3d/qglinfo/fpswidget.cpp b/tools/qt3d/qglinfo/fpswidget.cpp new file mode 100644 index 000000000..8d8bff4c0 --- /dev/null +++ b/tools/qt3d/qglinfo/fpswidget.cpp @@ -0,0 +1,279 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "fpswidget.h" + +#include <QtCore/qtimer.h> +#include <QtCore/qdatetime.h> + +static GLfloat materialColor[] = { 0.1f, 0.85f, 0.25f, 1.0f }; + +// dont drive the updates any faster than every this many millisecondss +#define MAX_ANIM_FREQUENCY 5 + +#define QGL_CUBE_SIZE (6 * 6 * (3 + 3)) +static float const cubeVertices[QGL_CUBE_SIZE] = { + -0.5f, -0.5f, -0.5f, -1.0f, 0.0f, 0.0f, + -0.5f, -0.5f, 0.5f, -1.0f, 0.0f, 0.0f, + -0.5f, 0.5f, 0.5f, -1.0f, 0.0f, 0.0f, + -0.5f, -0.5f, -0.5f, -1.0f, 0.0f, 0.0f, + -0.5f, 0.5f, 0.5f, -1.0f, 0.0f, 0.0f, + -0.5f, 0.5f, -0.5f, -1.0f, 0.0f, 0.0f, + + -0.5f, 0.5f, -0.5f, 0.0f, 1.0f, 0.0f, + -0.5f, 0.5f, 0.5f, 0.0f, 1.0f, 0.0f, + 0.5f, 0.5f, 0.5f, 0.0f, 1.0f, 0.0f, + -0.5f, 0.5f, -0.5f, 0.0f, 1.0f, 0.0f, + 0.5f, 0.5f, 0.5f, 0.0f, 1.0f, 0.0f, + 0.5f, 0.5f, -0.5f, 0.0f, 1.0f, 0.0f, + + 0.5f, 0.5f, -0.5f, 1.0f, 0.0f, 0.0f, + 0.5f, 0.5f, 0.5f, 1.0f, 0.0f, 0.0f, + 0.5f, -0.5f, 0.5f, 1.0f, 0.0f, 0.0f, + 0.5f, 0.5f, -0.5f, 1.0f, 0.0f, 0.0f, + 0.5f, -0.5f, 0.5f, 1.0f, 0.0f, 0.0f, + 0.5f, -0.5f, -0.5f, 1.0f, 0.0f, 0.0f, + + 0.5f, -0.5f, -0.5f, 0.0f, -1.0f, 0.0f, + 0.5f, -0.5f, 0.5f, 0.0f, -1.0f, 0.0f, + -0.5f, -0.5f, 0.5f, 0.0f, -1.0f, 0.0f, + 0.5f, -0.5f, -0.5f, 0.0f, -1.0f, 0.0f, + -0.5f, -0.5f, 0.5f, 0.0f, -1.0f, 0.0f, + -0.5f, -0.5f, -0.5f, 0.0f, -1.0f, 0.0f, + + 0.5f, -0.5f, 0.5f, 0.0f, 0.0f, 1.0f, + 0.5f, 0.5f, 0.5f, 0.0f, 0.0f, 1.0f, + -0.5f, 0.5f, 0.5f, 0.0f, 0.0f, 1.0f, + 0.5f, -0.5f, 0.5f, 0.0f, 0.0f, 1.0f, + -0.5f, 0.5f, 0.5f, 0.0f, 0.0f, 1.0f, + -0.5f, -0.5f, 0.5f, 0.0f, 0.0f, 1.0f, + + 0.5f, 0.5f, -0.5f, 0.0f, 0.0f, -1.0f, + 0.5f, -0.5f, -0.5f, 0.0f, 0.0f, -1.0f, + -0.5f, -0.5f, -0.5f, 0.0f, 0.0f, -1.0f, + 0.5f, 0.5f, -0.5f, 0.0f, 0.0f, -1.0f, + -0.5f, -0.5f, -0.5f, 0.0f, 0.0f, -1.0f, + -0.5f, 0.5f, -0.5f, 0.0f, 0.0f, -1.0f, +}; + +FPSWidget::FPSWidget(QWidget *parent) + : QGLWidget(parent) + , time(new QTime()) + , frameTime(new QTime()) + , timer(new QTimer(this)) + , goAwayTimer(new QTimer(this)) + , xrot(0) + , yrot(0) + , zrot(0) + , frameElapsed(0) + , frameCount(0) + , totalFrameTime(0) +{ + setAttribute(Qt::WA_DeleteOnClose); + setWindowTitle(tr("Generating Frames/Second")); + time->start(); + frameTime->start(); + connect(timer, SIGNAL(timeout()), + this, SLOT(animate())); + timer->start(0); // call the animation as soon as we return to the event loop + goAwayTimer = new QTimer(this); + connect(goAwayTimer, SIGNAL(timeout()), + this, SLOT(close())); + goAwayTimer->start(30000); +} + +FPSWidget::~FPSWidget() +{ + delete time; +} + +#if defined(QT_OPENGL_ES_2) + +void FPSWidget::setupShaders() +{ + QGLShader *vshader = new QGLShader(QGLShader::Vertex, this); + const char *vsrc = { + "attribute highp vec4 vertex;\n" + "attribute mediump vec3 normal;\n" + "uniform mediump mat4 matrix;\n" + "varying mediump float angle;\n" + "void main(void)\n" + "{\n" + " vec3 toLight = normalize(vec3(0.5, 5.0, 7.0));\n" + " angle = max(dot(normal, toLight), 0.0);\n" + " gl_Position = matrix * vertex;\n" + "}\n" + }; + vshader->compileSourceCode(vsrc); + + QGLShader *fshader = new QGLShader(QGLShader::Fragment, this); + const char *fsrc = { + "uniform mediump vec4 material;\n" + "varying mediump float angle;\n" + "void main(void)\n" + "{\n" + " gl_FragColor = material * 0.2 + material * 0.8 * angle;\n" + "}\n" + }; + fshader->compileSourceCode(fsrc); + + program.addShader(vshader); + program.addShader(fshader); + program.link(); + + vertexAttr = program.attributeLocation("vertex"); + normalAttr = program.attributeLocation("normal"); + matrixUniform = program.uniformLocation("matrix"); + materialUniform = program.uniformLocation("material"); + + program.bind(); +} + +#endif + +#ifndef GL_MULTISAMPLE +#define GL_MULTISAMPLE 0x809D +#endif + +void FPSWidget::initializeGL() +{ + glClearColor(0.9f, 0.95f, 0.8f, 1.0f); + glEnable(GL_DEPTH_TEST); + glEnable(GL_CULL_FACE); +#if defined(QT_OPENGL_ES_2) + setupShaders(); +#else + glShadeModel(GL_SMOOTH); + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + glEnable(GL_MULTISAMPLE); + static GLfloat lightPosition[4] = { 0.5, 5.0, 7.0, 1.0 }; + glLightfv(GL_LIGHT0, GL_POSITION, lightPosition); +#endif +} + +void FPSWidget::resizeGL(int w, int h) +{ + glViewport(0, 0, w, h); +#if !defined(QT_OPENGL_ES_2) + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); +#endif + int side = qMin(w, h); + qreal ws = (qreal)w / (qreal)side; + qreal hs = (qreal)h / (qreal)side; +#if defined(QT_OPENGL_ES_2) + projection.setToIdentity(); + projection.ortho(-ws, ws, -hs, hs, -10.0f, 10.0f); +#else + glOrtho(-ws, ws, -hs, hs, -10.0f, 10.0f); +#endif +} + +void FPSWidget::paintGL() +{ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + +#if !defined(QT_OPENGL_ES_2) + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + glRotatef(xrot, 1.0, 0.0, 0.0); + glRotatef(yrot, 0.0, 1.0, 0.0); + glRotatef(zrot, 0.0, 0.0, 1.0); + + glVertexPointer(3, GL_FLOAT, 6 * sizeof(GLfloat), cubeVertices); + glEnableClientState(GL_VERTEX_ARRAY); + glNormalPointer(GL_FLOAT, 6 * sizeof(GLfloat), cubeVertices); + glEnableClientState(GL_NORMAL_ARRAY); + + glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, materialColor); + glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, materialColor); +#else + modelView.setToIdentity(); + modelView.rotate(xrot, 1.0f, 0.0f, 0.0f); + modelView.rotate(yrot, 0.0f, 1.0f, 0.0f); + modelView.rotate(zrot, 0.0f, 0.0f, 1.0f); + program.setUniformValue(matrixUniform, projection * modelView); + + QVector4D mat(materialColor[0], materialColor[1], + materialColor[2], materialColor[3]); + program.setUniformValue(materialUniform, mat); + + program.setAttributeArray(vertexAttr, cubeVertices, 3, 6 * sizeof(GLfloat)); + program.setAttributeArray(normalAttr, cubeVertices+3, 3, 6 * sizeof(GLfloat)); + program.enableAttributeArray(vertexAttr); + program.enableAttributeArray(normalAttr); +#endif + + glDrawArrays(GL_TRIANGLES, 0, 36); + +#if !defined(QT_OPENGL_ES_2) + glDisableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_NORMAL_ARRAY); +#else + program.disableAttributeArray(vertexAttr); + program.disableAttributeArray(normalAttr); +#endif + QString framesPerSecond = QString::fromLatin1("%1 fps").arg(1000.0f / ((qreal)totalFrameTime / (qreal)frameCount)); +} + +void FPSWidget::animate() +{ + int elapsed = time->restart(); + frameElapsed += elapsed; + if (frameElapsed > MAX_ANIM_FREQUENCY) + { + frameElapsed += elapsed; + int adv = frameElapsed / 10; + if (adv > 0) + { + frameCount += 1; + totalFrameTime += frameElapsed; + emit fps(1000.0f / ((qreal)frameTime->elapsed() / (qreal)frameCount)); + xrot = (xrot + adv) % 360; + yrot = (xrot + adv) % 360; + zrot = (xrot + adv) % 360; + update(); + frameElapsed = 0; + } + } +} diff --git a/tools/qt3d/qglinfo/fpswidget.h b/tools/qt3d/qglinfo/fpswidget.h new file mode 100644 index 000000000..b7dac1dd5 --- /dev/null +++ b/tools/qt3d/qglinfo/fpswidget.h @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef FPSWIDGET_H +#define FPSWIDGET_H + +#include <QGLWidget> +#if defined(QT_OPENGL_ES_2) +#include <QtGui/qvector3d.h> +#include <QtGui/qmatrix4x4.h> +#include <QOpenGLShaderProgram> +#endif + +class QTime; +class QTimer; + +class FPSWidget : public QGLWidget +{ + Q_OBJECT +public: + FPSWidget(QWidget *parent = 0); + ~FPSWidget(); + void initializeGL(); + void resizeGL(int, int); + void paintGL(); +protected: + void keyPressEvent(QKeyEvent *) { close(); } + void mousePressEvent(QMouseEvent *) { close(); } +signals: + void fps(int); +private slots: + void animate(); +private: + QTime *time; + QTime *frameTime; + QTimer *timer; + QTimer *goAwayTimer; + int xrot, yrot, zrot; + int frameElapsed; + int frameCount; + int totalFrameTime; +#if defined(QT_OPENGL_ES_2) + void setupShaders(); + + QGLShaderProgram program; + QMatrix4x4 projection; + QMatrix4x4 modelView; + int vertexAttr; + int normalAttr; + int matrixUniform; + int materialUniform; +#endif +}; + +#endif // FPSWIDGET_H diff --git a/tools/qt3d/qglinfo/images/teapot-logo.png b/tools/qt3d/qglinfo/images/teapot-logo.png Binary files differnew file mode 100644 index 000000000..a82c33c1a --- /dev/null +++ b/tools/qt3d/qglinfo/images/teapot-logo.png diff --git a/tools/qt3d/qglinfo/main.cpp b/tools/qt3d/qglinfo/main.cpp new file mode 100644 index 000000000..775dbdc9d --- /dev/null +++ b/tools/qt3d/qglinfo/main.cpp @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QApplication> + +#include "qglinfowindow.h" + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + // for QSettings + QCoreApplication::setOrganizationName("Nokia"); + QCoreApplication::setOrganizationDomain("nokia.com"); + QCoreApplication::setApplicationName("qglinfo"); + + QGLInfoWindow w; + if (QApplication::arguments().contains(QLatin1String("-maximize"))) + w.showMaximized(); + else if (QApplication::arguments().contains(QLatin1String("-fullscreen"))) + w.showFullScreen(); + else + w.show(); + + return app.exec(); +} diff --git a/tools/qt3d/qglinfo/qglinfo.cpp b/tools/qt3d/qglinfo/qglinfo.cpp new file mode 100644 index 000000000..3d8966c36 --- /dev/null +++ b/tools/qt3d/qglinfo/qglinfo.cpp @@ -0,0 +1,344 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qglinfo.h" + +#include <QtOpenGL/qgl.h> +#include <QtOpenGL/qglpixelbuffer.h> +#include <QtOpenGL/qglframebufferobject.h> +#include <QOpenGLShaderProgram> + +#include <QtCore/qtimer.h> +#include <QtCore/qdatetime.h> + +#include <QtCore/qsettings.h> + +#if !defined(QT_NO_EGL) && defined(QT_BUILD_INTERNAL) +#include <QtGui/private/qegl_p.h> +#include <QtGui/private/qeglproperties_p.h> +#endif + +QGLInfo::QGLInfo(QObject *parent) + : QObject(parent) +{ + QTimer::singleShot(0, this, SLOT(initialize())); +} + +static QString nice(const QString &s) +{ + QString r(s); + r.replace(QLatin1String("\n"), QLatin1String("<br>\n")); + r.replace(QLatin1String("true"), QLatin1String("<span style=\"color: green\">true</span>")); + r.replace(QLatin1String("false"), QLatin1String("<span style=\"color: red\">false</span>")); + return r; +} + +void QGLInfo::initialize() +{ + QWidget *win = qobject_cast<QGLWidget *>(parent()); + // We need some kind of GL context to do the querying. + QGLWidget *glWidget = new QGLWidget(win); + glWidget->makeCurrent(); + m_qtGLVersionInfo = reportQtGLVersionInfo(); + m_qtGLFeatures = reportQtGLFeatures(); + m_glVersionInfo = reportGLVersionInfo(); + m_glExtensionInfo = reportGLExtensionInfo(); + m_eglVersionInfo = reportEGLVersionInfo(); + m_eglExtensionInfo = reportEGLExtensionInfo(); + m_eglConfigInfo = reportEGLConfigInfo(); + glWidget->doneCurrent(); + delete glWidget; + + QString welcome; + { + QSettings freshStart; + if (!freshStart.contains(QLatin1String("new_install"))) + { + welcome = QLatin1String("<h1>Welcome to Qt3D!</h1>" + "<p>Try running the FPS test from the " + "View menu above to confirm that Qt3D " + "is installed correctly.</p><hr>"); + } + freshStart.setValue(QLatin1String("new_install"), true); + } + + QString html = tr("<h1>Qt GL Info Report</h1>" + "<p>Generated at: %1</p>" + "<h2>Qt GL Version Info</h2>" + "<p>%2</p>" + "<h2>Qt GL Features</h2>" + "<p>%3</p>" + "<h2>GL Version Info</h2>" + "<p>%4</p>" + "<h2>GL Extension Info</h2>" + "<p>%5</p>") + .arg(QDateTime::currentDateTime().toString()) + .arg(nice(m_qtGLVersionInfo)) + .arg(nice(m_qtGLFeatures)) + .arg(nice(m_glVersionInfo)) + .arg(nice(m_glExtensionInfo)); + if (!welcome.isEmpty()) + html.prepend(welcome); + +#if !defined(QT_NO_EGL) + html += tr("<h2>EGL Version Info</h2>" + "<p>%1</p>" + "<h2>EGL Extension Info</h2>" + "<p>%2</p>" + "<h2>EGL Configurations</h2>" + "<p>%3</p>") + .arg(nice(m_eglVersionInfo)) + .arg(nice(m_eglExtensionInfo)) + .arg(nice(m_eglConfigInfo)); +#endif + emit reportHtml(html); +} + +QString QGLInfo::report() const +{ + QString report; + report += m_qtGLVersionInfo; + report += QLatin1Char('\n'); + report += m_qtGLFeatures; + report += m_glVersionInfo; + report += tr("OpenGL extensions:\n"); + report += m_glExtensionInfo; +#if !defined(QT_NO_EGL) + report += m_eglVersionInfo; + report += tr("EGL extensions:\n"); + report += m_eglExtensionInfo; + report += tr("EGL configurations:\n"); + report += m_eglConfigInfo; +#endif + return report; +} + +QString QGLInfo::reportQtGLVersionInfo() const +{ + // Dump what Qt thinks the version is. + QGLFormat::OpenGLVersionFlags flags = QGLFormat::openGLVersionFlags(); + QByteArray version; + if ((flags & QGLFormat::OpenGL_Version_1_1) != 0) + version += "1.1 "; + if ((flags & QGLFormat::OpenGL_Version_1_2) != 0) + version += "1.2 "; + if ((flags & QGLFormat::OpenGL_Version_1_3) != 0) + version += "1.3 "; + if ((flags & QGLFormat::OpenGL_Version_1_4) != 0) + version += "1.4 "; + if ((flags & QGLFormat::OpenGL_Version_1_5) != 0) + version += "1.5 "; + if ((flags & QGLFormat::OpenGL_Version_2_0) != 0) + version += "2.0 "; + if ((flags & QGLFormat::OpenGL_Version_2_1) != 0) + version += "2.1 "; + if ((flags & QGLFormat::OpenGL_Version_3_0) != 0) + version += "3.0 "; + if ((flags & QGLFormat::OpenGL_Version_3_1) != 0) + version += "3.1 "; + if ((flags & QGLFormat::OpenGL_Version_3_2) != 0) + version += "3.2 "; + if ((flags & QGLFormat::OpenGL_Version_3_3) != 0) + version += "3.3 "; + if ((flags & QGLFormat::OpenGL_Version_4_0) != 0) + version += "4.0 "; + if ((flags & QGLFormat::OpenGL_ES_Common_Version_1_0) != 0) + version += "ES/1.0 "; + if ((flags & QGLFormat::OpenGL_ES_CommonLite_Version_1_0) != 0) + version += "ES/1.0CL "; + if ((flags & QGLFormat::OpenGL_ES_Common_Version_1_1) != 0) + version += "ES/1.1 "; + if ((flags & QGLFormat::OpenGL_ES_CommonLite_Version_1_1) != 0) + version += "ES/1.1CL "; + if ((flags & QGLFormat::OpenGL_ES_Version_2_0) != 0) + version += "ES/2.0 "; + flags &= ~(QGLFormat::OpenGL_Version_1_1 | + QGLFormat::OpenGL_Version_1_2 | + QGLFormat::OpenGL_Version_1_3 | + QGLFormat::OpenGL_Version_1_4 | + QGLFormat::OpenGL_Version_1_5 | + QGLFormat::OpenGL_Version_2_0 | + QGLFormat::OpenGL_Version_2_1 | + QGLFormat::OpenGL_Version_3_0 | + QGLFormat::OpenGL_Version_3_1 | + QGLFormat::OpenGL_Version_3_2 | + QGLFormat::OpenGL_Version_3_3 | + QGLFormat::OpenGL_Version_4_0 | + QGLFormat::OpenGL_ES_Common_Version_1_0 | + QGLFormat::OpenGL_ES_CommonLite_Version_1_0 | + QGLFormat::OpenGL_ES_Common_Version_1_1 | + QGLFormat::OpenGL_ES_CommonLite_Version_1_1 | + QGLFormat::OpenGL_ES_Version_2_0); + if (flags != 0) + version += "Other=0x" + QByteArray::number(int(flags), 16); + return QLatin1String("QGLFormat::openGLVersionFlags: ") + + QString::fromLatin1(version.constData()); +} + +static QString printBool(const char *text, bool value) +{ + return QLatin1String(text) + (value ? QLatin1String("true\n") : QLatin1String("false\n")); +} + +QString QGLInfo::reportQtGLFeatures() const +{ + QString d; + d += printBool("QGLFormat::hasOpenGL: ", QGLFormat::hasOpenGL()); + d += printBool("QGLFormat::hasOpenGLOverlays: ", QGLFormat::hasOpenGLOverlays()); + d += printBool("QGLPixelBuffer::hasOpenGLPbuffers: ", QGLPixelBuffer::hasOpenGLPbuffers()); + d += printBool("QOpenGLFramebufferObject::hasOpenGLFramebufferObjects: ", + QOpenGLFramebufferObject::hasOpenGLFramebufferObjects()); + d += printBool("QOpenGLFramebufferObject::hasOpenGLFramebufferBlit: ", + QOpenGLFramebufferObject::hasOpenGLFramebufferBlit()); + d += printBool("QGLShaderProgram::hasOpenGLShaderPrograms: ", + QGLShaderProgram::hasOpenGLShaderPrograms()); + return d; +} + +QString QGLInfo::reportGLVersionInfo() const +{ + QString d; + d += QLatin1String("OpenGL vendor string: "); + d += QLatin1String(reinterpret_cast<const char *>(glGetString(GL_VENDOR))); + d += QLatin1String("\n"); + d += QLatin1String("OpenGL renderer string: "); + d += QLatin1String(reinterpret_cast<const char *>(glGetString(GL_RENDERER))); + d += QLatin1String("\n"); + d += QLatin1String("OpenGL version string: "); + d += QLatin1String(reinterpret_cast<const char *>(glGetString(GL_VERSION))); + d += QLatin1String("\n"); + return d; +} + +QString QGLInfo::reportGLExtensionInfo() const +{ + QByteArray extString + (reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS))); + return formatExtensions(extString); +} + +QString QGLInfo::formatExtensions(const QByteArray& extString) const +{ + QString d; + QList<QByteArray> extns = extString.split(' '); + qSort(extns); + QByteArray line; + foreach (QByteArray extn, extns) { + if (extn.isEmpty()) + continue; + if (!line.isEmpty() && (line.size() + extn.size() + 1) > 70) { + d += QLatin1String(" ") + + QString::fromLatin1(line.constData()) + + QLatin1String("\n"); + line = QByteArray(); + } + line += extn; + line += char(' '); + } + if (!line.isEmpty()) { + d += QLatin1String(" ") + + QString::fromLatin1(line.constData()) + + QLatin1String("\n"); + } + return d; +} + +QString QGLInfo::reportEGLVersionInfo() const +{ +#if !defined(QT_NO_EGL) && defined(QT_BUILD_INTERNAL) + QString d; + EGLDisplay dpy = eglGetCurrentDisplay(); + d += "EGL vendor string: "; + d += reinterpret_cast<const char *>(eglQueryString(dpy, EGL_VENDOR)); + d += "\n"; + d += "EGL version string: "; + d += reinterpret_cast<const char *>(eglQueryString(dpy, EGL_VERSION)); + d += "\n"; +#ifdef EGL_CLIENT_APIS + d += "EGL client API's: "; + d += reinterpret_cast<const char *>(eglQueryString(dpy, EGL_CLIENT_APIS)); + d += "\n"; +#endif + return d; +#else + return QString(); +#endif +} + +QString QGLInfo::reportEGLExtensionInfo() const +{ +#if !defined(QT_NO_EGL) && defined(QT_BUILD_INTERNAL) + EGLDisplay dpy = eglGetCurrentDisplay(); + QByteArray extString + (reinterpret_cast<const char *>(eglQueryString(dpy, EGL_EXTENSIONS))); + return formatExtensions(extString); +#else + return QString(); +#endif +} + +QString QGLInfo::reportEGLConfigInfo() const +{ +#if !defined(QT_NO_EGL) && defined(QT_BUILD_INTERNAL) + QString d; + QEglProperties props; + EGLint count = 0; + EGLDisplay dpy = eglGetCurrentDisplay(); + EGLContext ctx = eglGetCurrentContext(); + EGLint cfgnum = 0; + if (eglQueryContext(dpy, ctx, EGL_CONFIG_ID, &cfgnum)) { + d += QLatin1String("Window configuration in use: ") + QString::number(cfgnum) + + QLatin1String("\n\n"); + } + if (!eglGetConfigs(dpy, 0, 0, &count) || count < 1) + return d; + EGLConfig *configs = new EGLConfig [count]; + eglGetConfigs(dpy, configs, count, &count); + for (EGLint index = 0; index < count; ++index) { + props = QEglProperties(configs[index]); + d += props.toString() + QLatin1String("\n\n"); + } + delete [] configs; + return d; +#else + return QString(); +#endif +} diff --git a/tools/qt3d/qglinfo/qglinfo.h b/tools/qt3d/qglinfo/qglinfo.h new file mode 100644 index 000000000..6e21de0fc --- /dev/null +++ b/tools/qt3d/qglinfo/qglinfo.h @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QGLINFO_H +#define QGLINFO_H + +#include <QtCore/qstring.h> +#include <QtCore/qobject.h> +#include <QtCore/qbytearray.h> + +class QGLInfo : public QObject +{ + Q_OBJECT +public: + QGLInfo(QObject *parent = 0); + QString report() const; +signals: + void reportHtml(const QString &); +private slots: + void initialize(); +private: + QString reportQtGLVersionInfo() const; + QString reportQtGLFeatures() const; + QString reportGLVersionInfo() const; + QString reportGLExtensionInfo() const; + QString reportEGLVersionInfo() const; + QString reportEGLExtensionInfo() const; + QString reportEGLConfigInfo() const; + QString formatExtensions(const QByteArray& extString) const; + + QString m_qtGLVersionInfo; + QString m_qtGLFeatures; + QString m_glVersionInfo; + QString m_glExtensionInfo; + QString m_eglVersionInfo; + QString m_eglExtensionInfo; + QString m_eglConfigInfo; +}; + +#endif // QGLINFO_H diff --git a/tools/qt3d/qglinfo/qglinfo.pro b/tools/qt3d/qglinfo/qglinfo.pro new file mode 100644 index 000000000..7a01f22e2 --- /dev/null +++ b/tools/qt3d/qglinfo/qglinfo.pro @@ -0,0 +1,27 @@ +TARGET = qglinfo +QT += 3d + +SOURCES += main.cpp \ + qglinfowindow.cpp \ + qglinfo.cpp \ + aboutdialog.cpp \ + fpswidget.cpp + +FORMS += qglinfowindow.ui \ + aboutdialog.ui +HEADERS += qglinfowindow.h \ + qglinfo.h \ + aboutdialog.h \ + fpswidget.h +RESOURCES += qglinfo.qrc + +!contains(QT_CONFIG, egl):DEFINES += QT_NO_EGL + +OTHER_FILES += \ + qglinfo.rc + +RC_FILE = qglinfo.rc + +DESTDIR = $$QT.3d.bins +target.path = $$[QT_INSTALL_BINS] +INSTALLS += target diff --git a/tools/qt3d/qglinfo/qglinfo.qrc b/tools/qt3d/qglinfo/qglinfo.qrc new file mode 100644 index 000000000..1406cc27b --- /dev/null +++ b/tools/qt3d/qglinfo/qglinfo.qrc @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="/images"> + <file alias="teapot">images/teapot-logo.png</file> + </qresource> +</RCC> diff --git a/tools/qt3d/qglinfo/qglinfo.rc b/tools/qt3d/qglinfo/qglinfo.rc new file mode 100644 index 000000000..1b6228c97 --- /dev/null +++ b/tools/qt3d/qglinfo/qglinfo.rc @@ -0,0 +1 @@ +IDI_ICON1 ICON DISCARDABLE "qtquick3d.ico" diff --git a/tools/qt3d/qglinfo/qglinfowindow.cpp b/tools/qt3d/qglinfo/qglinfowindow.cpp new file mode 100644 index 000000000..3bf550054 --- /dev/null +++ b/tools/qt3d/qglinfo/qglinfowindow.cpp @@ -0,0 +1,162 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qglinfowindow.h" +#include "qglinfo.h" +#include "ui_qglinfowindow.h" +#include "aboutdialog.h" +#include "fpswidget.h" + +#include <QtOpenGL/qgl.h> +#include <QtWidgets/qfiledialog.h> +#include <QtGui/qfont.h> +#include <QtCore/qdir.h> +#include <QtCore/qfile.h> +#include <QtCore/QTextStream> + +QGLInfoWindow::QGLInfoWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::QGLInfoWindow) +{ + ui->setupUi(this); + setStatusBar(0); + if (QApplication::arguments().contains(QLatin1String("-maximize")) || + QApplication::arguments().contains(QLatin1String("-fullscreen"))) + { + ui->verticalLayout->setMargin(1); + ui->verticalLayout->setContentsMargins(1, 1, 1, 1); + ui->verticalLayout_2->setMargin(1); + ui->verticalLayout_2->setContentsMargins(1, 1, 1, 1); + ui->menubar->setVisible(false); + connect(ui->quitPushButton, SIGNAL(clicked()), + this, SLOT(on_actionQuit_triggered())); + connect(ui->runFPSTestPushButton, SIGNAL(clicked()), + this, SLOT(on_actionRun_FPS_Test_triggered())); + connect(ui->saveAsPushButton, SIGNAL(clicked()), + this, SLOT(on_action_Save_As_triggered())); + QFont f = font(); + f.setPointSize(f.pointSize() * 1.4); + setFont(f); + } + else + { + ui->buttonsWidget->setVisible(false); + } + info = new QGLInfo(); + connect(info, SIGNAL(reportHtml(QString)), + ui->textBrowser, SLOT(setHtml(QString))); + ui->fpsWidget->setVisible(false); +} + +QGLInfoWindow::~QGLInfoWindow() +{ + delete ui; + delete info; +} + +void QGLInfoWindow::changeEvent(QEvent *e) +{ + QMainWindow::changeEvent(e); + switch (e->type()) { + case QEvent::LanguageChange: + ui->retranslateUi(this); + break; + default: + break; + } +} + +void QGLInfoWindow::on_actionQuit_triggered() +{ + qApp->quit(); +} + +void QGLInfoWindow::on_action_Save_As_triggered() +{ + QString defName = QDir::home().absoluteFilePath(QLatin1String("qglinfo.txt")); + + QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"), + defName, + tr("Text (*.txt)")); + if (!fileName.isEmpty()) + { + QFile saveFile(fileName); + saveFile.open(QFile::WriteOnly); + { + QTextStream s(&saveFile); + s << info->report(); + } + saveFile.close(); + } +} + +void QGLInfoWindow::on_actionAbout_triggered() +{ + AboutDialog *about = new AboutDialog(this); + about->exec(); +} + +void QGLInfoWindow::on_actionRun_FPS_Test_triggered() +{ + fps = new FPSWidget(0); + fps->setGeometry(rect()); + fps->move(this->pos()); + connect(fps, SIGNAL(fps(int)), + ui->fpsLcdNumber, SLOT(display(int))); + ui->fpsWidget->setVisible(true); + fps->show(); +} + +void QGLInfoWindow::on_actionCopy_triggered() +{ + if (ui->textBrowser->textCursor().hasSelection()) { + ui->textBrowser->copy(); + } + else { + ui->textBrowser->selectAll(); + ui->textBrowser->copy(); + + QTextCursor tc(ui->textBrowser->textCursor()); + tc.clearSelection(); + tc.setPosition(0); + ui->textBrowser->setTextCursor(tc); + } +} diff --git a/tools/qt3d/qglinfo/qglinfowindow.h b/tools/qt3d/qglinfo/qglinfowindow.h new file mode 100644 index 000000000..a602ded68 --- /dev/null +++ b/tools/qt3d/qglinfo/qglinfowindow.h @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QGLINFOWINDOW_H +#define QGLINFOWINDOW_H + +#include <QMainWindow> + +namespace Ui { + class QGLInfoWindow; +} + +class QGLInfo; +class FPSWidget; + +class QGLInfoWindow : public QMainWindow { + Q_OBJECT +public: + QGLInfoWindow(QWidget *parent = 0); + ~QGLInfoWindow(); +public slots: + void on_actionQuit_triggered(); + void on_action_Save_As_triggered(); + +protected: + void changeEvent(QEvent *e); + +private: + Ui::QGLInfoWindow *ui; + QGLInfo *info; + FPSWidget *fps; + +private slots: + void on_actionRun_FPS_Test_triggered(); + void on_actionAbout_triggered(); + void on_actionCopy_triggered(); +}; + +#endif // QGLINFOWINDOW_H diff --git a/tools/qt3d/qglinfo/qglinfowindow.ui b/tools/qt3d/qglinfo/qglinfowindow.ui new file mode 100644 index 000000000..67723d35c --- /dev/null +++ b/tools/qt3d/qglinfo/qglinfowindow.ui @@ -0,0 +1,218 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>QGLInfoWindow</class> + <widget class="QMainWindow" name="QGLInfoWindow"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>555</width> + <height>584</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="windowTitle"> + <string>QGLInfo Window</string> + </property> + <widget class="QWidget" name="centralwidget"> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <widget class="QScrollArea" name="scrollArea"> + <property name="widgetResizable"> + <bool>true</bool> + </property> + <widget class="QWidget" name="scrollAreaWidgetContents"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>527</width> + <height>420</height> + </rect> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QTextBrowser" name="textBrowser"/> + </item> + </layout> + </widget> + </widget> + </item> + <item> + <widget class="QWidget" name="fpsWidget" native="true"> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QLabel" name="fpsLabel"> + <property name="text"> + <string>Frames Per Second:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + </item> + <item> + <widget class="QLCDNumber" name="fpsLcdNumber"> + <property name="layoutDirection"> + <enum>Qt::RightToLeft</enum> + </property> + <property name="frameShape"> + <enum>QFrame::Panel</enum> + </property> + <property name="frameShadow"> + <enum>QFrame::Sunken</enum> + </property> + <property name="lineWidth"> + <number>1</number> + </property> + <property name="midLineWidth"> + <number>3</number> + </property> + <property name="segmentStyle"> + <enum>QLCDNumber::Flat</enum> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>301</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QWidget" name="buttonsWidget" native="true"> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <widget class="QPushButton" name="saveAsPushButton"> + <property name="text"> + <string>Save As</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="runFPSTestPushButton"> + <property name="text"> + <string> FPS Test</string> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>241</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="quitPushButton"> + <property name="text"> + <string>Quit</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + </layout> + </widget> + <widget class="QMenuBar" name="menubar"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>555</width> + <height>22</height> + </rect> + </property> + <widget class="QMenu" name="menuFile"> + <property name="title"> + <string>File</string> + </property> + <addaction name="action_Save_As"/> + <addaction name="actionQuit"/> + </widget> + <widget class="QMenu" name="menuEdit"> + <property name="title"> + <string>Edit</string> + </property> + <addaction name="actionCopy"/> + </widget> + <widget class="QMenu" name="menuAbout"> + <property name="title"> + <string>Help</string> + </property> + <addaction name="actionAbout"/> + </widget> + <widget class="QMenu" name="menuView"> + <property name="title"> + <string>View</string> + </property> + <addaction name="actionRun_FPS_Test"/> + </widget> + <addaction name="menuFile"/> + <addaction name="menuEdit"/> + <addaction name="menuView"/> + <addaction name="menuAbout"/> + </widget> + <action name="action_Save_As"> + <property name="text"> + <string>&Save As</string> + </property> + <property name="shortcut"> + <string>Ctrl+S</string> + </property> + </action> + <action name="actionQuit"> + <property name="text"> + <string>&Quit</string> + </property> + <property name="shortcut"> + <string>Ctrl+Q</string> + </property> + </action> + <action name="actionCopy"> + <property name="text"> + <string>&Copy</string> + </property> + <property name="shortcut"> + <string>Ctrl+C</string> + </property> + </action> + <action name="actionAbout"> + <property name="text"> + <string>About</string> + </property> + </action> + <action name="actionRun_FPS_Test"> + <property name="text"> + <string>&Run FPS Test</string> + </property> + <property name="shortcut"> + <string>Ctrl+R</string> + </property> + </action> + </widget> + <resources/> + <connections/> +</ui> diff --git a/tools/qt3d/qglinfo/qtquick3d.ico b/tools/qt3d/qglinfo/qtquick3d.ico Binary files differnew file mode 100644 index 000000000..b3b85e37b --- /dev/null +++ b/tools/qt3d/qglinfo/qtquick3d.ico diff --git a/tools/qt3d/qt3d.pro b/tools/qt3d/qt3d.pro new file mode 100644 index 000000000..4d40584e6 --- /dev/null +++ b/tools/qt3d/qt3d.pro @@ -0,0 +1,2 @@ +TEMPLATE = subdirs +contains(QT_CONFIG, widgets): contains(QT_CONFIG, opengl): SUBDIRS += qglinfo diff --git a/tools/tools.pro b/tools/tools.pro new file mode 100644 index 000000000..481fd5f8f --- /dev/null +++ b/tools/tools.pro @@ -0,0 +1,4 @@ +TEMPLATE = subdirs +SUBDIRS = qt3d +include(../pkg.pri) +!package: SUBDIRS += meshcvt |