File indexing completed on 2025-02-21 10:11:21
0001
0002
0003
0004 #ifndef QOPENGLBUFFER_H
0005 #define QOPENGLBUFFER_H
0006
0007 #include <QtOpenGL/qtopenglglobal.h>
0008
0009 #ifndef QT_NO_OPENGL
0010
0011 #include <QtGui/qopengl.h>
0012
0013 QT_BEGIN_NAMESPACE
0014
0015
0016 class QOpenGLBufferPrivate;
0017
0018 class Q_OPENGL_EXPORT QOpenGLBuffer
0019 {
0020 public:
0021 enum Type
0022 {
0023 VertexBuffer = 0x8892,
0024 IndexBuffer = 0x8893,
0025 PixelPackBuffer = 0x88EB,
0026 PixelUnpackBuffer = 0x88EC
0027 };
0028
0029 QOpenGLBuffer();
0030 explicit QOpenGLBuffer(QOpenGLBuffer::Type type);
0031 QOpenGLBuffer(const QOpenGLBuffer &other);
0032 QOpenGLBuffer(QOpenGLBuffer &&other) noexcept
0033 : d_ptr{std::exchange(other.d_ptr, nullptr)} {}
0034 ~QOpenGLBuffer();
0035
0036 QOpenGLBuffer &operator=(const QOpenGLBuffer &other);
0037 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QOpenGLBuffer)
0038
0039 void swap(QOpenGLBuffer &other) noexcept
0040 { return qt_ptr_swap(d_ptr, other.d_ptr); }
0041
0042 enum UsagePattern
0043 {
0044 StreamDraw = 0x88E0,
0045 StreamRead = 0x88E1,
0046 StreamCopy = 0x88E2,
0047 StaticDraw = 0x88E4,
0048 StaticRead = 0x88E5,
0049 StaticCopy = 0x88E6,
0050 DynamicDraw = 0x88E8,
0051 DynamicRead = 0x88E9,
0052 DynamicCopy = 0x88EA
0053 };
0054
0055 enum Access
0056 {
0057 ReadOnly = 0x88B8,
0058 WriteOnly = 0x88B9,
0059 ReadWrite = 0x88BA
0060 };
0061
0062 enum RangeAccessFlag
0063 {
0064 RangeRead = 0x0001,
0065 RangeWrite = 0x0002,
0066 RangeInvalidate = 0x0004,
0067 RangeInvalidateBuffer = 0x0008,
0068 RangeFlushExplicit = 0x0010,
0069 RangeUnsynchronized = 0x0020
0070 };
0071 Q_DECLARE_FLAGS(RangeAccessFlags, RangeAccessFlag)
0072
0073 QOpenGLBuffer::Type type() const;
0074
0075 QOpenGLBuffer::UsagePattern usagePattern() const;
0076 void setUsagePattern(QOpenGLBuffer::UsagePattern value);
0077
0078 bool create();
0079 bool isCreated() const;
0080
0081 void destroy();
0082
0083 bool bind();
0084 void release();
0085
0086 static void release(QOpenGLBuffer::Type type);
0087
0088 GLuint bufferId() const;
0089
0090 int size() const;
0091
0092 bool read(int offset, void *data, int count);
0093 void write(int offset, const void *data, int count);
0094
0095 void allocate(const void *data, int count);
0096 inline void allocate(int count) { allocate(nullptr, count); }
0097
0098 void *map(QOpenGLBuffer::Access access);
0099 void *mapRange(int offset, int count, QOpenGLBuffer::RangeAccessFlags access);
0100 bool unmap();
0101
0102 private:
0103 QOpenGLBufferPrivate *d_ptr;
0104
0105 Q_DECLARE_PRIVATE(QOpenGLBuffer)
0106 };
0107 Q_DECLARE_SHARED(QOpenGLBuffer)
0108
0109 Q_DECLARE_OPERATORS_FOR_FLAGS(QOpenGLBuffer::RangeAccessFlags)
0110
0111 QT_END_NAMESPACE
0112
0113 #endif
0114
0115 #endif