6#include <QtCore/private/qobject_p.h>
7#include <QtCore/qthread.h>
8#include <QtGui/qopenglcontext.h>
9#include <QtGui/qoffscreensurface.h>
10#include <QtGui/qguiapplication.h>
12#include <QtOpenGL/QOpenGLVersionFunctionsFactory>
14#if !QT_CONFIG(opengles2)
15# include <QtOpenGL/qopenglfunctions_3_0.h>
16# include <QtOpenGL/qopenglfunctions_3_2_core.h>
19#include <private/qopenglcontext_p.h>
20#include <private/qopenglextensions_p.h>
21#include <private/qopenglvertexarrayobject_p.h>
38 auto &vaoHelper = contextPrivate->vaoHelper;
55 if (
context->format().majorVersion() >= 3) {
63 GenVertexArrays =
reinterpret_cast<QOpenGLVertexArrayObjectHelper::qt_GenVertexArrays_t
>(
context->getProcAddress(
"glGenVertexArraysOES"));
64 DeleteVertexArrays =
reinterpret_cast<QOpenGLVertexArrayObjectHelper::qt_DeleteVertexArrays_t
>(
context->getProcAddress(
"glDeleteVertexArraysOES"));
65 BindVertexArray =
reinterpret_cast<QOpenGLVertexArrayObjectHelper::qt_BindVertexArray_t
>(
context->getProcAddress(
"glBindVertexArrayOES"));
66 IsVertexArray =
reinterpret_cast<QOpenGLVertexArrayObjectHelper::qt_IsVertexArray_t
>(
context->getProcAddress(
"glIsVertexArrayOES"));
71 GenVertexArrays =
reinterpret_cast<QOpenGLVertexArrayObjectHelper::qt_GenVertexArrays_t
>(
context->getProcAddress(
"glGenVertexArraysAPPLE"));
72 DeleteVertexArrays =
reinterpret_cast<QOpenGLVertexArrayObjectHelper::qt_DeleteVertexArrays_t
>(
context->getProcAddress(
"glDeleteVertexArraysAPPLE"));
73 BindVertexArray =
reinterpret_cast<QOpenGLVertexArrayObjectHelper::qt_BindVertexArray_t
>(
context->getProcAddress(
"glBindVertexArrayAPPLE"));
74 IsVertexArray =
reinterpret_cast<QOpenGLVertexArrayObjectHelper::qt_IsVertexArray_t
>(
context->getProcAddress(
"glIsVertexArrayAPPLE"));
79 GenVertexArrays =
reinterpret_cast<QOpenGLVertexArrayObjectHelper::qt_GenVertexArrays_t
>(
context->getProcAddress(
"glGenVertexArrays"));
80 DeleteVertexArrays =
reinterpret_cast<QOpenGLVertexArrayObjectHelper::qt_DeleteVertexArrays_t
>(
context->getProcAddress(
"glDeleteVertexArrays"));
81 BindVertexArray =
reinterpret_cast<QOpenGLVertexArrayObjectHelper::qt_BindVertexArray_t
>(
context->getProcAddress(
"glBindVertexArray"));
82 IsVertexArray =
reinterpret_cast<QOpenGLVertexArrayObjectHelper::qt_IsVertexArray_t
>(
context->getProcAddress(
"glIsVertexArray"));
128 qWarning(
"QOpenGLVertexArrayObject::create() VAO is already created");
136 qWarning(
"QOpenGLVertexArrayObject::create() requires a valid current OpenGL context");
149 if (
ctx->isOpenGLES()) {
159#if !QT_CONFIG(opengles2)
161 vaoFuncs.core_3_2 = QOpenGLVersionFunctionsFactory::get<QOpenGLFunctions_3_2_Core>(
ctx);
164 }
else if (
format.majorVersion() >= 3) {
165 vaoFuncs.core_3_0 = QOpenGLVersionFunctionsFactory::get<QOpenGLFunctions_3_0>(
ctx);
190 QSurface *oldContextSurface =
nullptr;
194 oldContextSurface =
ctx ?
ctx->surface() :
nullptr;
207 offscreenSurface->create();
211 qWarning(
"QOpenGLVertexArrayObject::destroy() failed to make VAO's context current");
224#if !QT_CONFIG(opengles2)
244 if (oldContext && oldContextSurface && oldContextSurface->
surfaceHandle()) {
246 qWarning(
"QOpenGLVertexArrayObject::destroy() failed to restore current context");
261#if !QT_CONFIG(opengles2)
282#if !QT_CONFIG(opengles2)
284 vaoFuncs.core_3_2->glBindVertexArray(0);
287 vaoFuncs.core_3_0->glBindVertexArray(0);
293 vaoFuncs.helper->glBindVertexArray(0);
421 return (
d->vao != 0);
517#include "moc_qopenglvertexarrayobject.cpp"
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
\threadsafe
static QOpenGLContextPrivate * get(QOpenGLContext *context)
bool makeCurrent(QSurface *surface)
Makes the context current in the current thread, against the given surface.
QSurfaceFormat format() const
Returns the format of the underlying platform context, if create() has been called.
static QOpenGLContext * currentContext()
Returns the last context which called makeCurrent in the current thread, or \nullptr,...
qt_BindVertexArray_t BindVertexArray
static Q_OPENGL_EXPORT QOpenGLVertexArrayObjectHelper * vertexArrayObjectHelperForContext(QOpenGLContext *context)
qt_DeleteVertexArrays_t DeleteVertexArrays
qt_IsVertexArray_t IsVertexArray
qt_GenVertexArrays_t GenVertexArrays
QOpenGLVertexArrayObjectHelper * helper
enum QOpenGLVertexArrayObjectPrivate::@414 vaoFuncsType
QOpenGLFunctions_3_0 * core_3_0
void _q_contextAboutToBeDestroyed()
union QOpenGLVertexArrayObjectPrivate::@413 vaoFuncs
QOpenGLFunctions_3_2_Core * core_3_2
QOpenGLVertexArrayObjectPrivate()
The QOpenGLVertexArrayObject class wraps an OpenGL Vertex Array Object.
void destroy()
Destroys the underlying OpenGL vertex array object.
QOpenGLVertexArrayObject(QObject *parent=nullptr)
Creates a QOpenGLVertexArrayObject with the given parent.
void release()
Unbinds this vertex array object by binding the default vertex array object (id = 0).
~QOpenGLVertexArrayObject()
Destroys the QOpenGLVertexArrayObject and the underlying OpenGL resource.
bool create()
Creates the underlying OpenGL vertex array object.
bool isCreated() const
Returns true is the underlying OpenGL vertex array object has been created.
void bind()
Binds this vertex array object to the OpenGL binding point.
GLuint objectId() const
Returns the id of the underlying OpenGL vertex array object.
T * data() const noexcept
Returns the value of the pointer referenced by this object.
void reset(T *other=nullptr) noexcept(noexcept(Cleanup::cleanup(std::declval< T * >())))
Deletes the existing object it is pointing to (if any), and sets its pointer to other.
virtual QPlatformSurface * surfaceHandle() const =0
Returns a handle to the platform-specific implementation of the surface.
static QThread * currentThread()
Combined button and popup list for selecting options.
#define QByteArrayLiteral(str)
GLint GLsizei GLsizei GLenum format
GLdouble GLdouble GLdouble GLdouble q
static void vertexArrayObjectHelperDestroyCallback(QOpenGLVertexArrayObjectHelper *vaoHelper)
constexpr decltype(auto) qMakePair(T1 &&value1, T2 &&value2) noexcept(noexcept(std::make_pair(std::forward< T1 >(value1), std::forward< T2 >(value2))))
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent