Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-21 10:11:21

0001 // Copyright (C) 2016 The Qt Company Ltd.
0002 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
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, // GL_ARRAY_BUFFER
0024         IndexBuffer         = 0x8893, // GL_ELEMENT_ARRAY_BUFFER
0025         PixelPackBuffer     = 0x88EB, // GL_PIXEL_PACK_BUFFER
0026         PixelUnpackBuffer   = 0x88EC  // GL_PIXEL_UNPACK_BUFFER
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, // GL_STREAM_DRAW
0045         StreamRead          = 0x88E1, // GL_STREAM_READ
0046         StreamCopy          = 0x88E2, // GL_STREAM_COPY
0047         StaticDraw          = 0x88E4, // GL_STATIC_DRAW
0048         StaticRead          = 0x88E5, // GL_STATIC_READ
0049         StaticCopy          = 0x88E6, // GL_STATIC_COPY
0050         DynamicDraw         = 0x88E8, // GL_DYNAMIC_DRAW
0051         DynamicRead         = 0x88E9, // GL_DYNAMIC_READ
0052         DynamicCopy         = 0x88EA  // GL_DYNAMIC_COPY
0053     };
0054 
0055     enum Access
0056     {
0057         ReadOnly            = 0x88B8, // GL_READ_ONLY
0058         WriteOnly           = 0x88B9, // GL_WRITE_ONLY
0059         ReadWrite           = 0x88BA  // GL_READ_WRITE
0060     };
0061 
0062     enum RangeAccessFlag
0063     {
0064         RangeRead             = 0x0001, // GL_MAP_READ_BIT
0065         RangeWrite            = 0x0002, // GL_MAP_WRITE_BIT
0066         RangeInvalidate       = 0x0004, // GL_MAP_INVALIDATE_RANGE_BIT
0067         RangeInvalidateBuffer = 0x0008, // GL_MAP_INVALIDATE_BUFFER_BIT
0068         RangeFlushExplicit    = 0x0010, // GL_MAP_FLUSH_EXPLICIT_BIT
0069         RangeUnsynchronized   = 0x0020  // GL_MAP_UNSYNCHRONIZED_BIT
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 // QT_NO_OPENGL
0114 
0115 #endif