aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2017-02-09 14:42:15 +0100
committerLiang Qi <liang.qi@qt.io>2017-02-15 12:35:46 +0000
commitd0ec9f6aa22b203d22f5a23e8404ab764f77cf2a (patch)
tree2e1f65238104995028c01c3c660292f9a3225428
parent1c9637a766a9ab9fc93259f2d19a6c11dd81121d (diff)
Add QOpenGLBuffer to typesystem
Task-number: PYSIDE-459 Change-Id: I6aebe33f440ca43f37aa5f591eeffc9395774593 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
-rw-r--r--PySide2/QtGui/CMakeLists.txt1
-rw-r--r--PySide2/QtGui/typesystem_gui_common.xml6
-rw-r--r--tests/QtGui/CMakeLists.txt1
-rw-r--r--tests/QtGui/qopenglbuffer_test.py93
4 files changed, 101 insertions, 0 deletions
diff --git a/PySide2/QtGui/CMakeLists.txt b/PySide2/QtGui/CMakeLists.txt
index 490db0ad..47967e5c 100644
--- a/PySide2/QtGui/CMakeLists.txt
+++ b/PySide2/QtGui/CMakeLists.txt
@@ -96,6 +96,7 @@ ${QtGui_GEN_DIR}/qstandarditem_wrapper.cpp
${QtGui_GEN_DIR}/qstandarditemmodel_wrapper.cpp
${QtGui_GEN_DIR}/qstatustipevent_wrapper.cpp
${QtGui_GEN_DIR}/qstringlistmodel_wrapper.cpp
+${QtGui_GEN_DIR}/qopenglbuffer_wrapper.cpp
${QtGui_GEN_DIR}/qopenglcontext_wrapper.cpp
${QtGui_GEN_DIR}/qaccessible_wrapper.cpp
${QtGui_GEN_DIR}/qaccessible_state_wrapper.cpp
diff --git a/PySide2/QtGui/typesystem_gui_common.xml b/PySide2/QtGui/typesystem_gui_common.xml
index 5a670a4d..cb5c6579 100644
--- a/PySide2/QtGui/typesystem_gui_common.xml
+++ b/PySide2/QtGui/typesystem_gui_common.xml
@@ -3241,6 +3241,12 @@
</value-type>
<object-type name="QAccessibleInterface">
</object-type>
+ <object-type name="QOpenGLBuffer" since="5.0">
+ <enum-type name="Access" />
+ <enum-type name="RangeAccessFlag" flags="RangeAccessFlags" />
+ <enum-type name="Type" />
+ <enum-type name="UsagePattern" />
+ </object-type>
<object-type name="QOpenGLContext">
<enum-type name="OpenGLModuleType" />
</object-type>
diff --git a/tests/QtGui/CMakeLists.txt b/tests/QtGui/CMakeLists.txt
index 69b011db..843e597f 100644
--- a/tests/QtGui/CMakeLists.txt
+++ b/tests/QtGui/CMakeLists.txt
@@ -26,6 +26,7 @@ PYSIDE_TEST(qfontmetrics_test.py)
PYSIDE_TEST(qicon_test.py)
PYSIDE_TEST(qitemselection_test.py)
PYSIDE_TEST(qmatrix_test.py)
+PYSIDE_TEST(qopenglbuffer_test.py)
PYSIDE_TEST(qpainter_test.py)
PYSIDE_TEST(qpixmap_test.py)
PYSIDE_TEST(qpixmapcache_test.py)
diff --git a/tests/QtGui/qopenglbuffer_test.py b/tests/QtGui/qopenglbuffer_test.py
new file mode 100644
index 00000000..cae789ac
--- /dev/null
+++ b/tests/QtGui/qopenglbuffer_test.py
@@ -0,0 +1,93 @@
+#############################################################################
+##
+## Copyright (C) 2017 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## 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 The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+'''Unit tests for QOpenGLBuffer'''
+
+import unittest
+import ctypes
+import sys
+
+from helper import UsesQApplication
+from PySide2.QtGui import QOpenGLBuffer
+from PySide2 import QtGui
+
+def createSurface(surfaceClass):
+ if surfaceClass == QtGui.QSurface.Window:
+ window = QtGui.QWindow()
+ window.setSurfaceType(QtGui.QWindow.OpenGLSurface)
+ window.setGeometry(0, 0, 10, 10)
+ window.create()
+ return window
+ elif surfaceClass == QtGui.QSurface.Offscreen:
+ # Create a window and get the format from that. For example, if an EGL
+ # implementation provides 565 and 888 configs for PBUFFER_BIT but only
+ # 888 for WINDOW_BIT, we may end up with a pbuffer surface that is
+ # incompatible with the context since it could choose the 565 while the
+ # window and the context uses a config with 888.
+ format = QtGui.QSurfaceFormat
+ if format.redBufferSize() == -1:
+ window = QtGui.QWindow()
+ window.setSurfaceType(QtGui.QWindow.OpenGLSurface)
+ window.setGeometry(0, 0, 10, 10)
+ window.create()
+ format = window.format()
+ offscreenSurface = QtGui.QOffscreenSurface()
+ offscreenSurface.setFormat(format)
+ offscreenSurface.create()
+ return offscreenSurface
+ return 0
+
+class QOpenGLBuffer(UsesQApplication):
+ def testBufferCreate(self):
+ surface = createSurface(QtGui.QSurface.Window)
+ ctx = QtGui.QOpenGLContext()
+ ctx.create()
+ ctx.makeCurrent(surface)
+
+ buf = QtGui.QOpenGLBuffer()
+
+ self.assertTrue(not buf.isCreated())
+
+ self.assertTrue(buf.create())
+ self.assertTrue(buf.isCreated())
+
+ self.assertEqual(buf.type(), QtGui.QOpenGLBuffer.VertexBuffer)
+
+ buf.bind()
+ buf.allocate(128)
+ self.assertEqual(buf.size(), 128)
+
+ buf.release()
+
+ buf.destroy()
+ self.assertTrue(not buf.isCreated())
+
+ ctx.doneCurrent()
+
+if __name__ == '__main__':
+ unittest.main()