OpenCoverage

qopenglvertexarrayobject.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/opengl/qopenglvertexarrayobject.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2014 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Sean Harmer <sean.harmer@kdab.com>-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the QtGui module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#include "qopenglvertexarrayobject.h"-
41-
42#include <QtCore/private/qobject_p.h>-
43#include <QtGui/qopenglcontext.h>-
44#include <QtGui/qoffscreensurface.h>-
45-
46#include <QtGui/qopenglfunctions_3_0.h>-
47#include <QtGui/qopenglfunctions_3_2_core.h>-
48-
49#include <private/qopenglextensions_p.h>-
50#include <private/qopenglvertexarrayobject_p.h>-
51-
52QT_BEGIN_NAMESPACE-
53-
54class QOpenGLFunctions_3_0;-
55class QOpenGLFunctions_3_2_Core;-
56-
57void qtInitializeVertexArrayObjectHelper(QOpenGLVertexArrayObjectHelper *helper, QOpenGLContext *context)-
58{-
59 Q_ASSERT(helper);-
60 Q_ASSERT(context);-
61-
62 bool tryARB = true;-
63-
64 if (context->isOpenGLES()) {
context->isOpenGLES()Description
TRUEnever evaluated
FALSEnever evaluated
0
65 if (context->format().majorVersion() >= 3) {
context->forma...Version() >= 3Description
TRUEnever evaluated
FALSEnever evaluated
0
66 QOpenGLExtraFunctionsPrivate *extra = static_cast<QOpenGLExtensions *>(context->extraFunctions())->d();-
67 helper->GenVertexArrays = extra->f.GenVertexArrays;-
68 helper->DeleteVertexArrays = extra->f.DeleteVertexArrays;-
69 helper->BindVertexArray = extra->f.BindVertexArray;-
70 helper->IsVertexArray = extra->f.IsVertexArray;-
71 tryARB = false;-
72 } else if (context->hasExtension(QByteArrayLiteral("GL_OES_vertex_array_object"))) {
never executed: end of block
never executed: return ba;
context->hasEx...turn ba; }()))Description
TRUEnever evaluated
FALSEnever evaluated
0
73 helper->GenVertexArrays = reinterpret_cast<QOpenGLVertexArrayObjectHelper::qt_GenVertexArrays_t>(context->getProcAddress("glGenVertexArraysOES"));-
74 helper->DeleteVertexArrays = reinterpret_cast<QOpenGLVertexArrayObjectHelper::qt_DeleteVertexArrays_t>(context->getProcAddress("glDeleteVertexArraysOES"));-
75 helper->BindVertexArray = reinterpret_cast<QOpenGLVertexArrayObjectHelper::qt_BindVertexArray_t>(context->getProcAddress("glBindVertexArrayOES"));-
76 helper->IsVertexArray = reinterpret_cast<QOpenGLVertexArrayObjectHelper::qt_IsVertexArray_t>(context->getProcAddress("glIsVertexArrayOES"));-
77 tryARB = false;-
78 }
never executed: end of block
0
79 } else if (context->hasExtension(QByteArrayLiteral("GL_APPLE_vertex_array_object")) &&
never executed: end of block
never executed: return ba;
context->hasEx...turn ba; }()))Description
TRUEnever evaluated
FALSEnever evaluated
0
80 !context->hasExtension(QByteArrayLiteral("GL_ARB_vertex_array_object"))) {
never executed: return ba;
!context->hasE...turn ba; }()))Description
TRUEnever evaluated
FALSEnever evaluated
0
81 helper->GenVertexArrays = reinterpret_cast<QOpenGLVertexArrayObjectHelper::qt_GenVertexArrays_t>(context->getProcAddress("glGenVertexArraysAPPLE"));-
82 helper->DeleteVertexArrays = reinterpret_cast<QOpenGLVertexArrayObjectHelper::qt_DeleteVertexArrays_t>(context->getProcAddress("glDeleteVertexArraysAPPLE"));-
83 helper->BindVertexArray = reinterpret_cast<QOpenGLVertexArrayObjectHelper::qt_BindVertexArray_t>(context->getProcAddress("glBindVertexArrayAPPLE"));-
84 helper->IsVertexArray = reinterpret_cast<QOpenGLVertexArrayObjectHelper::qt_IsVertexArray_t>(context->getProcAddress("glIsVertexArrayAPPLE"));-
85 tryARB = false;-
86 }
never executed: end of block
0
87-
88 if (tryARB && context->hasExtension(QByteArrayLiteral("GL_ARB_vertex_array_object"))) {
never executed: return ba;
tryARBDescription
TRUEnever evaluated
FALSEnever evaluated
context->hasEx...turn ba; }()))Description
TRUEnever evaluated
FALSEnever evaluated
0
89 helper->GenVertexArrays = reinterpret_cast<QOpenGLVertexArrayObjectHelper::qt_GenVertexArrays_t>(context->getProcAddress("glGenVertexArrays"));-
90 helper->DeleteVertexArrays = reinterpret_cast<QOpenGLVertexArrayObjectHelper::qt_DeleteVertexArrays_t>(context->getProcAddress("glDeleteVertexArrays"));-
91 helper->BindVertexArray = reinterpret_cast<QOpenGLVertexArrayObjectHelper::qt_BindVertexArray_t>(context->getProcAddress("glBindVertexArray"));-
92 helper->IsVertexArray = reinterpret_cast<QOpenGLVertexArrayObjectHelper::qt_IsVertexArray_t>(context->getProcAddress("glIsVertexArray"));-
93 }
never executed: end of block
0
94}
never executed: end of block
0
95-
96class QOpenGLVertexArrayObjectPrivate : public QObjectPrivate-
97{-
98public:-
99 QOpenGLVertexArrayObjectPrivate()-
100 : vao(0)-
101 , vaoFuncsType(NotSupported)-
102 , context(0)-
103 {-
104 }
never executed: end of block
0
105-
106 ~QOpenGLVertexArrayObjectPrivate()-
107 {-
108 if (vaoFuncsType == ARB || vaoFuncsType == APPLE || vaoFuncsType == OES)
vaoFuncsType == ARBDescription
TRUEnever evaluated
FALSEnever evaluated
vaoFuncsType == APPLEDescription
TRUEnever evaluated
FALSEnever evaluated
vaoFuncsType == OESDescription
TRUEnever evaluated
FALSEnever evaluated
0
109 delete vaoFuncs.helper;
never executed: delete vaoFuncs.helper;
0
110 }
never executed: end of block
0
111-
112 bool create();-
113 void destroy();-
114 void bind();-
115 void release();-
116 void _q_contextAboutToBeDestroyed();-
117-
118 Q_DECLARE_PUBLIC(QOpenGLVertexArrayObject)-
119-
120 GLuint vao;-
121-
122 union {-
123 QOpenGLFunctions_3_0 *core_3_0;-
124 QOpenGLFunctions_3_2_Core *core_3_2;-
125 QOpenGLVertexArrayObjectHelper *helper;-
126 } vaoFuncs;-
127 enum {-
128 NotSupported,-
129 Core_3_0,-
130 Core_3_2,-
131 ARB,-
132 APPLE,-
133 OES-
134 } vaoFuncsType;-
135-
136 QOpenGLContext *context;-
137};-
138-
139bool QOpenGLVertexArrayObjectPrivate::create()-
140{-
141 if (vao) {
vaoDescription
TRUEnever evaluated
FALSEnever evaluated
0
142 qWarning("QOpenGLVertexArrayObject::create() VAO is already created");-
143 return false;
never executed: return false;
0
144 }-
145-
146 Q_Q(QOpenGLVertexArrayObject);-
147-
148 QOpenGLContext *ctx = QOpenGLContext::currentContext();-
149 if (!ctx) {
!ctxDescription
TRUEnever evaluated
FALSEnever evaluated
0
150 qWarning("QOpenGLVertexArrayObject::create() requires a valid current OpenGL context");-
151 return false;
never executed: return false;
0
152 }-
153-
154 //Fail early, if context is the same as ctx, it means we have tried to initialize for this context and failed-
155 if (ctx == context)
ctx == contextDescription
TRUEnever evaluated
FALSEnever evaluated
0
156 return false;
never executed: return false;
0
157-
158 context = ctx;-
159 QObject::connect(context, SIGNAL(aboutToBeDestroyed()), q, SLOT(_q_contextAboutToBeDestroyed()));-
160-
161 if (ctx->isOpenGLES()) {
ctx->isOpenGLES()Description
TRUEnever evaluated
FALSEnever evaluated
0
162 if (ctx->format().majorVersion() >= 3 || ctx->hasExtension(QByteArrayLiteral("GL_OES_vertex_array_object"))) {
never executed: return ba;
ctx->format()....Version() >= 3Description
TRUEnever evaluated
FALSEnever evaluated
ctx->hasExtens...turn ba; }()))Description
TRUEnever evaluated
FALSEnever evaluated
0
163 vaoFuncs.helper = new QOpenGLVertexArrayObjectHelper(ctx);-
164 vaoFuncsType = OES;-
165 vaoFuncs.helper->glGenVertexArrays(1, &vao);-
166 }
never executed: end of block
0
167 } else {
never executed: end of block
0
168 vaoFuncs.core_3_0 = 0;-
169 vaoFuncsType = NotSupported;-
170 QSurfaceFormat format = ctx->format();-
171#ifndef QT_OPENGL_ES_2-
172 if (format.version() >= qMakePair<int, int>(3,2)) {
format.version...int, int>(3,2)Description
TRUEnever evaluated
FALSEnever evaluated
0
173 vaoFuncs.core_3_2 = ctx->versionFunctions<QOpenGLFunctions_3_2_Core>();-
174 vaoFuncsType = Core_3_2;-
175 vaoFuncs.core_3_2->glGenVertexArrays(1, &vao);-
176 } else if (format.majorVersion() >= 3) {
never executed: end of block
format.majorVersion() >= 3Description
TRUEnever evaluated
FALSEnever evaluated
0
177 vaoFuncs.core_3_0 = ctx->versionFunctions<QOpenGLFunctions_3_0>();-
178 vaoFuncsType = Core_3_0;-
179 vaoFuncs.core_3_0->glGenVertexArrays(1, &vao);-
180 } else
never executed: end of block
0
181#endif-
182 if (ctx->hasExtension(QByteArrayLiteral("GL_ARB_vertex_array_object"))) {
never executed: return ba;
ctx->hasExtens...turn ba; }()))Description
TRUEnever evaluated
FALSEnever evaluated
0
183 vaoFuncs.helper = new QOpenGLVertexArrayObjectHelper(ctx);-
184 vaoFuncsType = ARB;-
185 vaoFuncs.helper->glGenVertexArrays(1, &vao);-
186 } else if (ctx->hasExtension(QByteArrayLiteral("GL_APPLE_vertex_array_object"))) {
never executed: end of block
never executed: return ba;
ctx->hasExtens...turn ba; }()))Description
TRUEnever evaluated
FALSEnever evaluated
0
187 vaoFuncs.helper = new QOpenGLVertexArrayObjectHelper(ctx);-
188 vaoFuncsType = APPLE;-
189 vaoFuncs.helper->glGenVertexArrays(1, &vao);-
190 }
never executed: end of block
0
191 }
never executed: end of block
0
192-
193 return (vao != 0);
never executed: return (vao != 0);
0
194}-
195-
196void QOpenGLVertexArrayObjectPrivate::destroy()-
197{-
198 Q_Q(QOpenGLVertexArrayObject);-
199-
200 if (context) {
contextDescription
TRUEnever evaluated
FALSEnever evaluated
0
201 QObject::disconnect(context, SIGNAL(aboutToBeDestroyed()), q, SLOT(_q_contextAboutToBeDestroyed()));-
202 context = 0;-
203 }
never executed: end of block
0
204-
205 if (!vao)
!vaoDescription
TRUEnever evaluated
FALSEnever evaluated
0
206 return;
never executed: return;
0
207-
208 switch (vaoFuncsType) {-
209#ifndef QT_OPENGL_ES_2-
210 case Core_3_2:
never executed: case Core_3_2:
0
211 vaoFuncs.core_3_2->glDeleteVertexArrays(1, &vao);-
212 break;
never executed: break;
0
213 case Core_3_0:
never executed: case Core_3_0:
0
214 vaoFuncs.core_3_0->glDeleteVertexArrays(1, &vao);-
215 break;
never executed: break;
0
216#endif-
217 case ARB:
never executed: case ARB:
0
218 case APPLE:
never executed: case APPLE:
0
219 case OES:
never executed: case OES:
0
220 vaoFuncs.helper->glDeleteVertexArrays(1, &vao);-
221 break;
never executed: break;
0
222 default:
never executed: default:
0
223 break;
never executed: break;
0
224 }-
225-
226 vao = 0;-
227}
never executed: end of block
0
228-
229/*!-
230 \internal-
231*/-
232void QOpenGLVertexArrayObjectPrivate::_q_contextAboutToBeDestroyed()-
233{-
234 destroy();-
235}
never executed: end of block
0
236-
237void QOpenGLVertexArrayObjectPrivate::bind()-
238{-
239 switch (vaoFuncsType) {-
240#ifndef QT_OPENGL_ES_2-
241 case Core_3_2:
never executed: case Core_3_2:
0
242 vaoFuncs.core_3_2->glBindVertexArray(vao);-
243 break;
never executed: break;
0
244 case Core_3_0:
never executed: case Core_3_0:
0
245 vaoFuncs.core_3_0->glBindVertexArray(vao);-
246 break;
never executed: break;
0
247#endif-
248 case ARB:
never executed: case ARB:
0
249 case APPLE:
never executed: case APPLE:
0
250 case OES:
never executed: case OES:
0
251 vaoFuncs.helper->glBindVertexArray(vao);-
252 break;
never executed: break;
0
253 default:
never executed: default:
0
254 break;
never executed: break;
0
255 }-
256}-
257-
258void QOpenGLVertexArrayObjectPrivate::release()-
259{-
260 switch (vaoFuncsType) {-
261#ifndef QT_OPENGL_ES_2-
262 case Core_3_2:
never executed: case Core_3_2:
0
263 vaoFuncs.core_3_2->glBindVertexArray(0);-
264 break;
never executed: break;
0
265 case Core_3_0:
never executed: case Core_3_0:
0
266 vaoFuncs.core_3_0->glBindVertexArray(0);-
267 break;
never executed: break;
0
268#endif-
269 case ARB:
never executed: case ARB:
0
270 case APPLE:
never executed: case APPLE:
0
271 case OES:
never executed: case OES:
0
272 vaoFuncs.helper->glBindVertexArray(0);-
273 break;
never executed: break;
0
274 default:
never executed: default:
0
275 break;
never executed: break;
0
276 }-
277}-
278-
279-
280/*!-
281 \class QOpenGLVertexArrayObject-
282 \brief The QOpenGLVertexArrayObject class wraps an OpenGL Vertex Array Object.-
283 \inmodule QtGui-
284 \since 5.1-
285 \ingroup painting-3D-
286-
287 A Vertex Array Object (VAO) is an OpenGL container object that encapsulates-
288 the state needed to specify per-vertex attribute data to the OpenGL pipeline.-
289 To put it another way, a VAO remembers the states of buffer objects (see-
290 QOpenGLBuffer) and their associated state (e.g. vertex attribute divisors).-
291 This allows a very easy and efficient method of switching between OpenGL buffer-
292 states for rendering different "objects" in a scene. The QOpenGLVertexArrayObject-
293 class is a thin wrapper around an OpenGL VAO.-
294-
295 For the desktop, VAOs are supported as a core feature in OpenGL 3.0 or newer and by the-
296 GL_ARB_vertex_array_object for older versions. On OpenGL ES 2, VAOs are provided by-
297 the optional GL_OES_vertex_array_object extension. You can check the version of-
298 OpenGL with QOpenGLContext::surfaceFormat() and check for the presence of extensions-
299 with QOpenGLContext::hasExtension().-
300-
301 As with the other Qt OpenGL classes, QOpenGLVertexArrayObject has a create()-
302 function to create the underlying OpenGL object. This is to allow the developer to-
303 ensure that there is a valid current OpenGL context at the time.-
304-
305 Once you have successfully created a VAO the typical usage pattern is:-
306-
307 \list-
308 \li In scene initialization function, for each visual object:-
309 \list-
310 \li Bind the VAO-
311 \li Set vertex data state for this visual object (vertices, normals, texture coordinates etc.)-
312 \li Unbind (release()) the VAO-
313 \endlist-
314 \li In render function, for each visual object:-
315 \list-
316 \li Bind the VAO (and shader program if needed)-
317 \li Call a glDraw*() function-
318 \li Unbind (release()) the VAO-
319 \endlist-
320 \endlist-
321-
322 The act of binding the VAO in the render function has the effect of restoring-
323 all of the vertex data state setup in the initialization phase. In this way we can-
324 set a great deal of state when setting up a VAO and efficiently switch between-
325 state sets of objects to be rendered. Using VAOs also allows the OpenGL driver-
326 to amortise the validation checks of the vertex data.-
327-
328 \note Vertex Array Objects, like all other OpenGL container objects, are specific-
329 to the context for which they were created and cannot be shared amongst a-
330 context group.-
331-
332 \sa QOpenGLVertexArrayObject::Binder, QOpenGLBuffer-
333*/-
334-
335/*!-
336 Creates a QOpenGLVertexArrayObject with the given \a parent. You must call create()-
337 with a valid OpenGL context before using.-
338*/-
339QOpenGLVertexArrayObject::QOpenGLVertexArrayObject(QObject* parent)-
340 : QObject(*new QOpenGLVertexArrayObjectPrivate, parent)-
341{-
342}
never executed: end of block
0
343-
344/*!-
345 \internal-
346*/-
347QOpenGLVertexArrayObject::QOpenGLVertexArrayObject(QOpenGLVertexArrayObjectPrivate &dd)-
348 : QObject(dd)-
349{-
350}
never executed: end of block
0
351-
352/*!-
353 Destroys the QOpenGLVertexArrayObject and the underlying OpenGL resource.-
354*/-
355QOpenGLVertexArrayObject::~QOpenGLVertexArrayObject()-
356{-
357 QOpenGLContext* ctx = QOpenGLContext::currentContext();-
358-
359 Q_D(QOpenGLVertexArrayObject);-
360 QOpenGLContext *oldContext = 0;-
361 QSurface *oldContextSurface = 0;-
362 QScopedPointer<QOffscreenSurface> offscreenSurface;-
363 if (d->context && ctx && d->context != ctx) {
d->contextDescription
TRUEnever evaluated
FALSEnever evaluated
ctxDescription
TRUEnever evaluated
FALSEnever evaluated
d->context != ctxDescription
TRUEnever evaluated
FALSEnever evaluated
0
364 oldContext = ctx;-
365 oldContextSurface = ctx->surface();-
366 // Cannot just make the current surface current again with another context.-
367 // The format may be incompatible and some platforms (iOS) may impose-
368 // restrictions on using a window with different contexts. Create an-
369 // offscreen surface (a pbuffer or a hidden window) instead to be safe.-
370 offscreenSurface.reset(new QOffscreenSurface);-
371 offscreenSurface->setFormat(d->context->format());-
372 offscreenSurface->create();-
373 if (d->context->makeCurrent(offscreenSurface.data())) {
d->context->ma...urface.data())Description
TRUEnever evaluated
FALSEnever evaluated
0
374 ctx = d->context;-
375 } else {
never executed: end of block
0
376 qWarning("QOpenGLVertexArrayObject::~QOpenGLVertexArrayObject() failed to make VAO's context current");-
377 ctx = 0;-
378 }
never executed: end of block
0
379 }-
380-
381 if (ctx)
ctxDescription
TRUEnever evaluated
FALSEnever evaluated
0
382 destroy();
never executed: destroy();
0
383-
384 if (oldContext) {
oldContextDescription
TRUEnever evaluated
FALSEnever evaluated
0
385 if (!oldContext->makeCurrent(oldContextSurface))
!oldContext->m...ontextSurface)Description
TRUEnever evaluated
FALSEnever evaluated
0
386 qWarning("QOpenGLVertexArrayObject::~QOpenGLVertexArrayObject() failed to restore current context");
never executed: QMessageLogger(__FILE__, 386, __PRETTY_FUNCTION__).warning("QOpenGLVertexArrayObject::~QOpenGLVertexArrayObject() failed to restore current context");
0
387 }
never executed: end of block
0
388}
never executed: end of block
0
389-
390/*!-
391 Creates the underlying OpenGL vertex array object. There must be a valid OpenGL context-
392 that supports vertex array objects current for this function to succeed.-
393-
394 Returns \c true if the OpenGL vertex array object was successfully created.-
395-
396 When the return value is \c false, vertex array object support is not available. This-
397 is not an error: on systems with OpenGL 2.x or OpenGL ES 2.0 vertex array objects may-
398 not be supported. The application is free to continue execution in this case, but it-
399 then has to be prepared to operate in a VAO-less manner too. This means that instead-
400 of merely calling bind(), the value of isCreated() must be checked and the vertex-
401 arrays has to be initialized in the traditional way when there is no vertex array-
402 object present.-
403-
404 \sa isCreated()-
405*/-
406bool QOpenGLVertexArrayObject::create()-
407{-
408 Q_D(QOpenGLVertexArrayObject);-
409 return d->create();
never executed: return d->create();
0
410}-
411-
412/*!-
413 Destroys the underlying OpenGL vertex array object. There must be a valid OpenGL context-
414 that supports vertex array objects current for this function to succeed.-
415*/-
416void QOpenGLVertexArrayObject::destroy()-
417{-
418 Q_D(QOpenGLVertexArrayObject);-
419 d->destroy();-
420}
never executed: end of block
0
421-
422/*!-
423 Returns \c true is the underlying OpenGL vertex array object has been created. If this-
424 returns \c true and the associated OpenGL context is current, then you are able to bind()-
425 this object.-
426*/-
427bool QOpenGLVertexArrayObject::isCreated() const-
428{-
429 Q_D(const QOpenGLVertexArrayObject);-
430 return (d->vao != 0);
never executed: return (d->vao != 0);
0
431}-
432-
433/*!-
434 Returns the id of the underlying OpenGL vertex array object.-
435*/-
436GLuint QOpenGLVertexArrayObject::objectId() const-
437{-
438 Q_D(const QOpenGLVertexArrayObject);-
439 return d->vao;
never executed: return d->vao;
0
440}-
441-
442/*!-
443 Binds this vertex array object to the OpenGL binding point. From this point on-
444 and until release() is called or another vertex array object is bound, any-
445 modifications made to vertex data state are stored inside this vertex array object.-
446-
447 If another vertex array object is then bound you can later restore the set of-
448 state associated with this object by calling bind() on this object once again.-
449 This allows efficient changes between vertex data states in rendering functions.-
450*/-
451void QOpenGLVertexArrayObject::bind()-
452{-
453 Q_D(QOpenGLVertexArrayObject);-
454 d->bind();-
455}
never executed: end of block
0
456-
457/*!-
458 Unbinds this vertex array object by binding the default vertex array object (id = 0).-
459*/-
460void QOpenGLVertexArrayObject::release()-
461{-
462 Q_D(QOpenGLVertexArrayObject);-
463 d->release();-
464}
never executed: end of block
0
465-
466-
467/*!-
468 \class QOpenGLVertexArrayObject::Binder-
469 \brief The QOpenGLVertexArrayObject::Binder class is a convenience class to help-
470 with the binding and releasing of OpenGL Vertex Array Objects.-
471 \inmodule QtGui-
472 \reentrant-
473 \since 5.1-
474 \ingroup painting-3D-
475-
476 QOpenGLVertexArrayObject::Binder is a simple convenience class that can be used-
477 to assist with the binding and releasing of QOpenGLVertexArrayObject instances.-
478 This class is to QOpenGLVertexArrayObject as QMutexLocker is to QMutex.-
479-
480 This class implements the RAII principle which helps to ensure behavior in-
481 complex code or in the presence of exceptions.-
482-
483 The constructor of this class accepts a QOpenGLVertexArrayObject (VAO) as an-
484 argument and attempts to bind the VAO, calling QOpenGLVertexArrayObject::create()-
485 if necessary. The destructor of this class calls QOpenGLVertexArrayObject::release()-
486 which unbinds the VAO.-
487-
488 If needed the VAO can be temporarily unbound with the release() function and bound-
489 once more with rebind().-
490-
491 \sa QOpenGLVertexArrayObject-
492*/-
493-
494/*!-
495 \fn QOpenGLVertexArrayObject::Binder::Binder(QOpenGLVertexArrayObject *v)-
496-
497 Creates a QOpenGLVertexArrayObject::Binder object and binds \a v by calling-
498 QOpenGLVertexArrayObject::bind(). If necessary it first calls-
499 QOpenGLVertexArrayObject::create().-
500*/-
501-
502/*!-
503 \fn QOpenGLVertexArrayObject::Binder::~Binder()-
504-
505 Destroys the QOpenGLVertexArrayObject::Binder and releases the associated vertex array object.-
506*/-
507-
508/*!-
509 \fn QOpenGLVertexArrayObject::Binder::release()-
510-
511 Can be used to temporarily release the associated vertex array object.-
512-
513 \sa rebind()-
514*/-
515-
516/*!-
517 \fn QOpenGLVertexArrayObject::Binder::rebind()-
518-
519 Can be used to rebind the associated vertex array object.-
520-
521 \sa release()-
522*/-
523-
524QT_END_NAMESPACE-
525-
526#include "moc_qopenglvertexarrayobject.cpp"-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9