summaryrefslogtreecommitdiffstats
path: root/src/gui/opengl/qopenglvertexarrayobject_p.h
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2014-07-29 12:36:30 +0200
committerGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2014-07-30 20:01:49 +0200
commit12867bb8e2bf56e9397ee6b6014e176fdab6e86f (patch)
tree212181a5d4c5cbe6d0a143a4462e896fc709c5ad /src/gui/opengl/qopenglvertexarrayobject_p.h
parent7616586691cf99e63d2b7c0f1fde27791a6a8f24 (diff)
QOpenGLVAO: refactor the helper class and export it
It is useful in other places, for instance in QtQuick, to avoid duplicating the same resolver logic. Change-Id: I9748a420a0abeb07cc84f948965b1e0321a95ca2 Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
Diffstat (limited to 'src/gui/opengl/qopenglvertexarrayobject_p.h')
-rw-r--r--src/gui/opengl/qopenglvertexarrayobject_p.h119
1 files changed, 119 insertions, 0 deletions
diff --git a/src/gui/opengl/qopenglvertexarrayobject_p.h b/src/gui/opengl/qopenglvertexarrayobject_p.h
new file mode 100644
index 0000000000..161a388b1a
--- /dev/null
+++ b/src/gui/opengl/qopenglvertexarrayobject_p.h
@@ -0,0 +1,119 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Sean Harmer <sean.harmer@kdab.com>
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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, Digia gives you certain additional
+** rights. These rights are described in the Digia 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QOPENGLVERTEXARRAYOBJECT_P_H
+#define QOPENGLVERTEXARRAYOBJECT_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of the Qt OpenGL classes. This header file may change from
+// version to version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qglobal.h>
+
+#ifndef QT_NO_OPENGL
+
+#include <QtGui/qopengl.h>
+
+QT_BEGIN_NAMESPACE
+
+class QOpenGLVertexArrayObjectHelper;
+class QOpenGLContext;
+
+void Q_GUI_EXPORT qtInitializeVertexArrayObjectHelper(QOpenGLVertexArrayObjectHelper *helper, QOpenGLContext *context);
+
+class QOpenGLVertexArrayObjectHelper
+{
+ Q_DISABLE_COPY(QOpenGLVertexArrayObjectHelper)
+
+public:
+ explicit inline QOpenGLVertexArrayObjectHelper(QOpenGLContext *context)
+ : GenVertexArrays(Q_NULLPTR)
+ , DeleteVertexArrays(Q_NULLPTR)
+ , BindVertexArray(Q_NULLPTR)
+ {
+ qtInitializeVertexArrayObjectHelper(this, context);
+ }
+
+ inline bool isValid() const
+ {
+ return GenVertexArrays && DeleteVertexArrays && BindVertexArray;
+ }
+
+ inline void glGenVertexArrays(GLsizei n, GLuint *arrays) const
+ {
+ GenVertexArrays(n, arrays);
+ }
+
+ inline void glDeleteVertexArrays(GLsizei n, const GLuint *arrays) const
+ {
+ DeleteVertexArrays(n, arrays);
+ }
+
+ inline void glBindVertexArray(GLuint array) const
+ {
+ BindVertexArray(array);
+ }
+
+private:
+ friend void Q_GUI_EXPORT qtInitializeVertexArrayObjectHelper(QOpenGLVertexArrayObjectHelper *helper, QOpenGLContext *context);
+
+ // Function signatures are equivalent between desktop core, ARB, APPLE, ES 3 and ES 2 extensions
+ typedef void (QOPENGLF_APIENTRYP qt_GenVertexArrays_t)(GLsizei n, GLuint *arrays);
+ typedef void (QOPENGLF_APIENTRYP qt_DeleteVertexArrays_t)(GLsizei n, const GLuint *arrays);
+ typedef void (QOPENGLF_APIENTRYP qt_BindVertexArray_t)(GLuint array);
+
+ qt_GenVertexArrays_t GenVertexArrays;
+ qt_DeleteVertexArrays_t DeleteVertexArrays;
+ qt_BindVertexArray_t BindVertexArray;
+};
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_OPENGL
+
+#endif // QOPENGLVERTEXARRAYOBJECT_P_H