qglbuffer.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -
4** Contact: http://www.qt-project.org/legal -
5** -
6** This file is part of the QtOpenGL 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 Digia. For licensing terms and -
14** conditions see http://qt.digia.com/licensing. For further information -
15** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software -
20** Foundation and appearing in the file LICENSE.LGPL included in the -
21** packaging of this file. Please review the following information to -
22** ensure the GNU Lesser General Public License version 2.1 requirements -
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -
24** -
25** In addition, as a special exception, Digia gives you certain additional -
26** rights. These rights are described in the Digia Qt LGPL Exception -
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -
28** -
29** GNU General Public License Usage -
30** Alternatively, this file may be used under the terms of the GNU -
31** General Public License version 3.0 as published by the Free Software -
32** Foundation and appearing in the file LICENSE.GPL included in the -
33** packaging of this file. Please review the following information to -
34** ensure the GNU General Public License version 3.0 requirements will be -
35** met: http://www.gnu.org/copyleft/gpl.html. -
36** -
37** -
38** $QT_END_LICENSE$ -
39** -
40****************************************************************************/ -
41 -
42#include <QtOpenGL/qgl.h> -
43#include <QtOpenGL/private/qgl_p.h> -
44#include <QtOpenGL/private/qglextensions_p.h> -
45#include <QtCore/qatomic.h> -
46#include "qglbuffer.h" -
47 -
48QT_BEGIN_NAMESPACE -
49 -
50/*! -
51 \class QGLBuffer -
52 \inmodule QtOpenGL -
53 \brief The QGLBuffer class provides functions for creating and managing GL buffer objects. -
54 \since 4.7 -
55 \obsolete -
56 \ingroup painting-3D -
57 -
58 Buffer objects are created in the GL server so that the -
59 client application can avoid uploading vertices, indices, -
60 texture image data, etc every time they are needed. -
61 -
62 QGLBuffer objects can be copied around as a reference to the -
63 underlying GL buffer object: -
64 -
65 \code -
66 QGLBuffer buffer1(QGLBuffer::IndexBuffer); -
67 buffer1.create(); -
68 -
69 QGLBuffer buffer2 = buffer1; -
70 \endcode -
71 -
72 QGLBuffer performs a shallow copy when objects are copied in this -
73 manner, but does not implement copy-on-write semantics. The original -
74 object will be affected whenever the copy is modified. -
75 -
76 \note This class has been deprecated in favor of QOpenGLBuffer. -
77*/ -
78 -
79/*! -
80 \enum QGLBuffer::Type -
81 This enum defines the type of GL buffer object to create with QGLBuffer. -
82 -
83 \value VertexBuffer Vertex buffer object for use when specifying -
84 vertex arrays. -
85 \value IndexBuffer Index buffer object for use with \c{glDrawElements()}. -
86 \value PixelPackBuffer Pixel pack buffer object for reading pixel -
87 data from the GL server (for example, with \c{glReadPixels()}). -
88 Not supported under OpenGL/ES. -
89 \value PixelUnpackBuffer Pixel unpack buffer object for writing pixel -
90 data to the GL server (for example, with \c{glTexImage2D()}). -
91 Not supported under OpenGL/ES. -
92*/ -
93 -
94/*! -
95 \enum QGLBuffer::UsagePattern -
96 This enum defines the usage pattern of a QGLBuffer object. -
97 -
98 \value StreamDraw The data will be set once and used a few times -
99 for drawing operations. Under OpenGL/ES 1.1 this is identical -
100 to StaticDraw. -
101 \value StreamRead The data will be set once and used a few times -
102 for reading data back from the GL server. Not supported -
103 under OpenGL/ES. -
104 \value StreamCopy The data will be set once and used a few times -
105 for reading data back from the GL server for use in further -
106 drawing operations. Not supported under OpenGL/ES. -
107 \value StaticDraw The data will be set once and used many times -
108 for drawing operations. -
109 \value StaticRead The data will be set once and used many times -
110 for reading data back from the GL server. Not supported -
111 under OpenGL/ES. -
112 \value StaticCopy The data will be set once and used many times -
113 for reading data back from the GL server for use in further -
114 drawing operations. Not supported under OpenGL/ES. -
115 \value DynamicDraw The data will be modified repeatedly and used -
116 many times for drawing operations. -
117 \value DynamicRead The data will be modified repeatedly and used -
118 many times for reading data back from the GL server. -
119 Not supported under OpenGL/ES. -
120 \value DynamicCopy The data will be modified repeatedly and used -
121 many times for reading data back from the GL server for -
122 use in further drawing operations. Not supported under OpenGL/ES. -
123*/ -
124 -
125/*! -
126 \enum QGLBuffer::Access -
127 This enum defines the access mode for QGLBuffer::map(). -
128 -
129 \value ReadOnly The buffer will be mapped for reading only. -
130 \value WriteOnly The buffer will be mapped for writing only. -
131 \value ReadWrite The buffer will be mapped for reading and writing. -
132*/ -
133 -
134class QGLBufferPrivate -
135{ -
136public: -
137 QGLBufferPrivate(QGLBuffer::Type t) -
138 : ref(1), -
139 type(t), -
140 guard(0), -
141 usagePattern(QGLBuffer::StaticDraw), -
142 actualUsagePattern(QGLBuffer::StaticDraw) -
143 { -
144 }
never executed: }
0
145 -
146 QAtomicInt ref; -
147 QGLBuffer::Type type; -
148 QGLSharedResourceGuardBase *guard; -
149 QGLBuffer::UsagePattern usagePattern; -
150 QGLBuffer::UsagePattern actualUsagePattern; -
151}; -
152 -
153/*! -
154 Constructs a new buffer object of type QGLBuffer::VertexBuffer. -
155 -
156 Note: this constructor just creates the QGLBuffer instance. The actual -
157 buffer object in the GL server is not created until create() is called. -
158 -
159 \sa create() -
160*/ -
161QGLBuffer::QGLBuffer() -
162 : d_ptr(new QGLBufferPrivate(QGLBuffer::VertexBuffer)) -
163{ -
164}
never executed: }
0
165 -
166/*! -
167 Constructs a new buffer object of \a type. -
168 -
169 Note: this constructor just creates the QGLBuffer instance. The actual -
170 buffer object in the GL server is not created until create() is called. -
171 -
172 \sa create() -
173*/ -
174QGLBuffer::QGLBuffer(QGLBuffer::Type type) -
175 : d_ptr(new QGLBufferPrivate(type)) -
176{ -
177}
never executed: }
0
178 -
179/*! -
180 Constructs a shallow copy of \a other. -
181 -
182 Note: QGLBuffer does not implement copy-on-write semantics, -
183 so \a other will be affected whenever the copy is modified. -
184*/ -
185QGLBuffer::QGLBuffer(const QGLBuffer &other) -
186 : d_ptr(other.d_ptr) -
187{ -
188 d_ptr->ref.ref();
never executed (the execution status of this line is deduced): d_ptr->ref.ref();
-
189}
never executed: }
0
190 -
191#define ctx QGLContext::currentContext(); -
192 -
193/*! -
194 Destroys this buffer object, including the storage being -
195 used in the GL server. -
196*/ -
197QGLBuffer::~QGLBuffer() -
198{ -
199 if (!d_ptr->ref.deref()) {
never evaluated: !d_ptr->ref.deref()
0
200 destroy();
never executed (the execution status of this line is deduced): destroy();
-
201 delete d_ptr;
never executed (the execution status of this line is deduced): delete d_ptr;
-
202 }
never executed: }
0
203}
never executed: }
0
204 -
205/*! -
206 Assigns a shallow copy of \a other to this object. -
207 -
208 Note: QGLBuffer does not implement copy-on-write semantics, -
209 so \a other will be affected whenever the copy is modified. -
210*/ -
211QGLBuffer &QGLBuffer::operator=(const QGLBuffer &other) -
212{ -
213 if (d_ptr != other.d_ptr) {
never evaluated: d_ptr != other.d_ptr
0
214 other.d_ptr->ref.ref();
never executed (the execution status of this line is deduced): other.d_ptr->ref.ref();
-
215 if (!d_ptr->ref.deref()) {
never evaluated: !d_ptr->ref.deref()
0
216 destroy();
never executed (the execution status of this line is deduced): destroy();
-
217 delete d_ptr;
never executed (the execution status of this line is deduced): delete d_ptr;
-
218 }
never executed: }
0
219 d_ptr = other.d_ptr;
never executed (the execution status of this line is deduced): d_ptr = other.d_ptr;
-
220 }
never executed: }
0
221 return *this;
never executed: return *this;
0
222} -
223 -
224/*! -
225 Returns the type of buffer represented by this object. -
226*/ -
227QGLBuffer::Type QGLBuffer::type() const -
228{ -
229 Q_D(const QGLBuffer);
never executed (the execution status of this line is deduced): const QGLBufferPrivate * const d = d_func();
-
230 return d->type;
never executed: return d->type;
0
231} -
232 -
233/*! -
234 Returns the usage pattern for this buffer object. -
235 The default value is StaticDraw. -
236 -
237 \sa setUsagePattern() -
238*/ -
239QGLBuffer::UsagePattern QGLBuffer::usagePattern() const -
240{ -
241 Q_D(const QGLBuffer);
never executed (the execution status of this line is deduced): const QGLBufferPrivate * const d = d_func();
-
242 return d->usagePattern;
never executed: return d->usagePattern;
0
243} -
244 -
245/*! -
246 Sets the usage pattern for this buffer object to \a value. -
247 This function must be called before allocate() or write(). -
248 -
249 \sa usagePattern(), allocate(), write() -
250*/ -
251void QGLBuffer::setUsagePattern(QGLBuffer::UsagePattern value) -
252{ -
253 Q_D(QGLBuffer);
never executed (the execution status of this line is deduced): QGLBufferPrivate * const d = d_func();
-
254 d->usagePattern = d->actualUsagePattern = value;
never executed (the execution status of this line is deduced): d->usagePattern = d->actualUsagePattern = value;
-
255}
never executed: }
0
256 -
257#undef ctx -
258 -
259namespace { -
260 void freeBufferFunc(QGLContext *ctx, GLuint id) -
261 { -
262 Q_UNUSED(ctx);
never executed (the execution status of this line is deduced): (void)ctx;;
-
263 glDeleteBuffers(1, &id);
never executed (the execution status of this line is deduced): QGLContextPrivate::extensionFuncs(ctx).qt_glDeleteBuffers(1, &id);
-
264 }
never executed: }
0
265} -
266 -
267/*! -
268 Creates the buffer object in the GL server. Returns true if -
269 the object was created; false otherwise. -
270 -
271 This function must be called with a current QGLContext. -
272 The buffer will be bound to and can only be used in -
273 that context (or any other context that is shared with it). -
274 -
275 This function will return false if the GL implementation -
276 does not support buffers, or there is no current QGLContext. -
277 -
278 \sa isCreated(), allocate(), write(), destroy() -
279*/ -
280bool QGLBuffer::create() -
281{ -
282 Q_D(QGLBuffer);
never executed (the execution status of this line is deduced): QGLBufferPrivate * const d = d_func();
-
283 if (d->guard && d->guard->id())
never evaluated: d->guard
never evaluated: d->guard->id()
0
284 return true;
never executed: return true;
0
285 QGLContext *ctx = const_cast<QGLContext *>(QGLContext::currentContext());
never executed (the execution status of this line is deduced): QGLContext *ctx = const_cast<QGLContext *>(QGLContext::currentContext());
-
286 if (ctx) {
never evaluated: ctx
0
287 if (!qt_resolve_buffer_extensions(ctx))
never evaluated: !qt_resolve_buffer_extensions(ctx)
0
288 return false;
never executed: return false;
0
289 GLuint bufferId = 0;
never executed (the execution status of this line is deduced): GLuint bufferId = 0;
-
290 glGenBuffers(1, &bufferId);
never executed (the execution status of this line is deduced): QGLContextPrivate::extensionFuncs(ctx).qt_glGenBuffers(1, &bufferId);
-
291 if (bufferId) {
never evaluated: bufferId
0
292 if (d->guard)
never evaluated: d->guard
0
293 d->guard->free();
never executed: d->guard->free();
0
294 -
295 d->guard = createSharedResourceGuard(ctx, bufferId, freeBufferFunc);
never executed (the execution status of this line is deduced): d->guard = createSharedResourceGuard(ctx, bufferId, freeBufferFunc);
-
296 return true;
never executed: return true;
0
297 } -
298 }
never executed: }
0
299 return false;
never executed: return false;
0
300} -
301 -
302#define ctx QGLContext::currentContext() -
303 -
304/*! -
305 Returns true if this buffer has been created; false otherwise. -
306 -
307 \sa create(), destroy() -
308*/ -
309bool QGLBuffer::isCreated() const -
310{ -
311 Q_D(const QGLBuffer);
never executed (the execution status of this line is deduced): const QGLBufferPrivate * const d = d_func();
-
312 return d->guard && d->guard->id();
never executed: return d->guard && d->guard->id();
0
313} -
314 -
315/*! -
316 Destroys this buffer object, including the storage being -
317 used in the GL server. All references to the buffer will -
318 become invalid. -
319*/ -
320void QGLBuffer::destroy() -
321{ -
322 Q_D(QGLBuffer);
never executed (the execution status of this line is deduced): QGLBufferPrivate * const d = d_func();
-
323 if (d->guard) {
never evaluated: d->guard
0
324 d->guard->free();
never executed (the execution status of this line is deduced): d->guard->free();
-
325 d->guard = 0;
never executed (the execution status of this line is deduced): d->guard = 0;
-
326 }
never executed: }
0
327}
never executed: }
0
328 -
329/*! -
330 Reads the \a count bytes in this buffer starting at \a offset -
331 into \a data. Returns true on success; false if reading from -
332 the buffer is not supported. Buffer reading is not supported -
333 under OpenGL/ES. -
334 -
335 It is assumed that this buffer has been bound to the current context. -
336 -
337 \sa write(), bind() -
338*/ -
339bool QGLBuffer::read(int offset, void *data, int count) -
340{ -
341#if !defined(QT_OPENGL_ES) -
342 Q_D(QGLBuffer);
never executed (the execution status of this line is deduced): QGLBufferPrivate * const d = d_func();
-
343 if (!glGetBufferSubData || !d->guard->id())
never evaluated: !QGLContextPrivate::extensionFuncs(QGLContext::currentContext()).qt_glGetBufferSubData
never evaluated: !d->guard->id()
0
344 return false;
never executed: return false;
0
345 while (glGetError() != GL_NO_ERROR) ; // Clear error state.
never executed: ;
never evaluated: glGetError() != 0x0
0
346 glGetBufferSubData(d->type, offset, count, data);
never executed (the execution status of this line is deduced): QGLContextPrivate::extensionFuncs(QGLContext::currentContext()).qt_glGetBufferSubData(d->type, offset, count, data);
-
347 return glGetError() == GL_NO_ERROR;
never executed: return glGetError() == 0x0;
0
348#else -
349 Q_UNUSED(offset); -
350 Q_UNUSED(data); -
351 Q_UNUSED(count); -
352 return false; -
353#endif -
354} -
355 -
356/*! -
357 Replaces the \a count bytes of this buffer starting at \a offset -
358 with the contents of \a data. Any other bytes in the buffer -
359 will be left unmodified. -
360 -
361 It is assumed that create() has been called on this buffer and that -
362 it has been bound to the current context. -
363 -
364 \sa create(), read(), allocate() -
365*/ -
366void QGLBuffer::write(int offset, const void *data, int count) -
367{ -
368#ifndef QT_NO_DEBUG -
369 if (!isCreated()) -
370 qWarning("QGLBuffer::allocate(): buffer not created"); -
371#endif -
372 Q_D(QGLBuffer);
never executed (the execution status of this line is deduced): QGLBufferPrivate * const d = d_func();
-
373 if (d->guard && d->guard->id())
never evaluated: d->guard
never evaluated: d->guard->id()
0
374 glBufferSubData(d->type, offset, count, data);
never executed: QGLContextPrivate::extensionFuncs(QGLContext::currentContext()).qt_glBufferSubData(d->type, offset, count, data);
0
375}
never executed: }
0
376 -
377/*! -
378 Allocates \a count bytes of space to the buffer, initialized to -
379 the contents of \a data. Any previous contents will be removed. -
380 -
381 It is assumed that create() has been called on this buffer and that -
382 it has been bound to the current context. -
383 -
384 \sa create(), read(), write() -
385*/ -
386void QGLBuffer::allocate(const void *data, int count) -
387{ -
388#ifndef QT_NO_DEBUG -
389 if (!isCreated()) -
390 qWarning("QGLBuffer::allocate(): buffer not created"); -
391#endif -
392 Q_D(QGLBuffer);
never executed (the execution status of this line is deduced): QGLBufferPrivate * const d = d_func();
-
393 if (d->guard && d->guard->id())
never evaluated: d->guard
never evaluated: d->guard->id()
0
394 glBufferData(d->type, count, data, d->actualUsagePattern);
never executed: QGLContextPrivate::extensionFuncs(QGLContext::currentContext()).qt_glBufferData(d->type, count, data, d->actualUsagePattern);
0
395}
never executed: }
0
396 -
397/*! -
398 \fn void QGLBuffer::allocate(int count) -
399 \overload -
400 -
401 Allocates \a count bytes of space to the buffer. Any previous -
402 contents will be removed. -
403 -
404 It is assumed that create() has been called on this buffer and that -
405 it has been bound to the current context. -
406 -
407 \sa create(), write() -
408*/ -
409 -
410/*! -
411 Binds the buffer associated with this object to the current -
412 GL context. Returns false if binding was not possible, usually because -
413 type() is not supported on this GL implementation. -
414 -
415 The buffer must be bound to the same QGLContext current when create() -
416 was called, or to another QGLContext that is sharing with it. -
417 Otherwise, false will be returned from this function. -
418 -
419 \sa release(), create() -
420*/ -
421bool QGLBuffer::bind() -
422{ -
423#ifndef QT_NO_DEBUG -
424 if (!isCreated()) -
425 qWarning("QGLBuffer::bind(): buffer not created"); -
426#endif -
427 Q_D(const QGLBuffer);
never executed (the execution status of this line is deduced): const QGLBufferPrivate * const d = d_func();
-
428 GLuint bufferId = d->guard ? d->guard->id() : 0;
never evaluated: d->guard
0
429 if (bufferId) {
never evaluated: bufferId
0
430 if (d->guard->group() != QOpenGLContextGroup::currentContextGroup()) {
never evaluated: d->guard->group() != QOpenGLContextGroup::currentContextGroup()
0
431#ifndef QT_NO_DEBUG -
432 qWarning("QGLBuffer::bind: buffer is not valid in the current context"); -
433#endif -
434 return false;
never executed: return false;
0
435 } -
436 glBindBuffer(d->type, bufferId);
never executed (the execution status of this line is deduced): QGLContextPrivate::extensionFuncs(QGLContext::currentContext()).qt_glBindBuffer(d->type, bufferId);
-
437 return true;
never executed: return true;
0
438 } else { -
439 return false;
never executed: return false;
0
440 } -
441} -
442 -
443/*! -
444 Releases the buffer associated with this object from the -
445 current GL context. -
446 -
447 This function must be called with the same QGLContext current -
448 as when bind() was called on the buffer. -
449 -
450 \sa bind() -
451*/ -
452void QGLBuffer::release() -
453{ -
454#ifndef QT_NO_DEBUG -
455 if (!isCreated()) -
456 qWarning("QGLBuffer::release(): buffer not created"); -
457#endif -
458 Q_D(const QGLBuffer);
never executed (the execution status of this line is deduced): const QGLBufferPrivate * const d = d_func();
-
459 if (d->guard && d->guard->id())
never evaluated: d->guard
never evaluated: d->guard->id()
0
460 glBindBuffer(d->type, 0);
never executed: QGLContextPrivate::extensionFuncs(QGLContext::currentContext()).qt_glBindBuffer(d->type, 0);
0
461}
never executed: }
0
462 -
463#undef ctx -
464 -
465/*! -
466 Releases the buffer associated with \a type in the current -
467 QGLContext. -
468 -
469 This function is a direct call to \c{glBindBuffer(type, 0)} -
470 for use when the caller does not know which QGLBuffer has -
471 been bound to the context but wants to make sure that it -
472 is released. -
473 -
474 \code -
475 QGLBuffer::release(QGLBuffer::VertexBuffer); -
476 \endcode -
477*/ -
478void QGLBuffer::release(QGLBuffer::Type type) -
479{ -
480 const QGLContext *ctx = QGLContext::currentContext();
never executed (the execution status of this line is deduced): const QGLContext *ctx = QGLContext::currentContext();
-
481 if (ctx && qt_resolve_buffer_extensions(const_cast<QGLContext *>(ctx)))
never evaluated: ctx
never evaluated: qt_resolve_buffer_extensions(const_cast<QGLContext *>(ctx))
0
482 glBindBuffer(GLenum(type), 0);
never executed: QGLContextPrivate::extensionFuncs(ctx).qt_glBindBuffer(GLenum(type), 0);
0
483}
never executed: }
0
484 -
485#define ctx QGLContext::currentContext() -
486 -
487/*! -
488 Returns the GL identifier associated with this buffer; zero if -
489 the buffer has not been created. -
490 -
491 \sa isCreated() -
492*/ -
493GLuint QGLBuffer::bufferId() const -
494{ -
495 Q_D(const QGLBuffer);
never executed (the execution status of this line is deduced): const QGLBufferPrivate * const d = d_func();
-
496 return d->guard ? d->guard->id() : 0;
never executed: return d->guard ? d->guard->id() : 0;
0
497} -
498 -
499#ifndef GL_BUFFER_SIZE -
500#define GL_BUFFER_SIZE 0x8764 -
501#endif -
502 -
503/*! -
504 Returns the size of the data in this buffer, for reading operations. -
505 Returns -1 if fetching the buffer size is not supported, or the -
506 buffer has not been created. -
507 -
508 It is assumed that this buffer has been bound to the current context. -
509 -
510 \sa isCreated(), bind() -
511*/ -
512int QGLBuffer::size() const -
513{ -
514 Q_D(const QGLBuffer);
never executed (the execution status of this line is deduced): const QGLBufferPrivate * const d = d_func();
-
515 if (!d->guard || !d->guard->id())
never evaluated: !d->guard
never evaluated: !d->guard->id()
0
516 return -1;
never executed: return -1;
0
517 GLint value = -1;
never executed (the execution status of this line is deduced): GLint value = -1;
-
518 glGetBufferParameteriv(d->type, GL_BUFFER_SIZE, &value);
never executed (the execution status of this line is deduced): QGLContextPrivate::extensionFuncs(QGLContext::currentContext()).qt_glGetBufferParameteriv(d->type, 0x8764, &value);
-
519 return value;
never executed: return value;
0
520} -
521 -
522/*! -
523 Maps the contents of this buffer into the application's memory -
524 space and returns a pointer to it. Returns null if memory -
525 mapping is not possible. The \a access parameter indicates the -
526 type of access to be performed. -
527 -
528 It is assumed that create() has been called on this buffer and that -
529 it has been bound to the current context. -
530 -
531 This function is only supported under OpenGL/ES if the -
532 \c{GL_OES_mapbuffer} extension is present. -
533 -
534 \sa unmap(), create(), bind() -
535*/ -
536void *QGLBuffer::map(QGLBuffer::Access access) -
537{ -
538 Q_D(QGLBuffer);
never executed (the execution status of this line is deduced): QGLBufferPrivate * const d = d_func();
-
539#ifndef QT_NO_DEBUG -
540 if (!isCreated()) -
541 qWarning("QGLBuffer::map(): buffer not created"); -
542#endif -
543 if (!d->guard || !d->guard->id())
never evaluated: !d->guard
never evaluated: !d->guard->id()
0
544 return 0;
never executed: return 0;
0
545 if (!glMapBufferARB)
never evaluated: !QGLContextPrivate::extensionFuncs(QGLContext::currentContext()).qt_glMapBufferARB
0
546 return 0;
never executed: return 0;
0
547 return glMapBufferARB(d->type, access);
never executed: return QGLContextPrivate::extensionFuncs(QGLContext::currentContext()).qt_glMapBufferARB(d->type, access);
0
548} -
549 -
550/*! -
551 Unmaps the buffer after it was mapped into the application's -
552 memory space with a previous call to map(). Returns true if -
553 the unmap succeeded; false otherwise. -
554 -
555 It is assumed that this buffer has been bound to the current context, -
556 and that it was previously mapped with map(). -
557 -
558 This function is only supported under OpenGL/ES if the -
559 \c{GL_OES_mapbuffer} extension is present. -
560 -
561 \sa map() -
562*/ -
563bool QGLBuffer::unmap() -
564{ -
565 Q_D(QGLBuffer);
never executed (the execution status of this line is deduced): QGLBufferPrivate * const d = d_func();
-
566#ifndef QT_NO_DEBUG -
567 if (!isCreated()) -
568 qWarning("QGLBuffer::unmap(): buffer not created"); -
569#endif -
570 if (!d->guard || !d->guard->id())
never evaluated: !d->guard
never evaluated: !d->guard->id()
0
571 return false;
never executed: return false;
0
572 if (!glUnmapBufferARB)
never evaluated: !QGLContextPrivate::extensionFuncs(QGLContext::currentContext()).qt_glUnmapBufferARB
0
573 return false;
never executed: return false;
0
574 return glUnmapBufferARB(d->type) == GL_TRUE;
never executed: return QGLContextPrivate::extensionFuncs(QGLContext::currentContext()).qt_glUnmapBufferARB(d->type) == 0x1;
0
575} -
576 -
577QT_END_NAMESPACE -
578 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial