From c01c52224863ef91c6ba28831b53552b8e60bf1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 19 Nov 2012 16:54:22 +0100 Subject: [PATCH] Mention Native Client buffer requirements. Allow more convenient target hint setting. --- doc/best-practices.dox | 9 +++++++++ src/Buffer.h | 4 +++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/doc/best-practices.dox b/doc/best-practices.dox index 7883be334..2c06f6ce7 100644 --- a/doc/best-practices.dox +++ b/doc/best-practices.dox @@ -29,5 +29,14 @@ information. - [Best practices for 3D graphics](https://developers.google.com/native-client/beta/devguide/coding/3D-graphics#best-practices) +@subsubsection best-practices-nacl-buffer-types Native Client requires unique buffer binding + +As noted in the above link, buffers in NaCl implementation need to be bound +only to one unique target, i.e., Buffer bound to @ref Buffer::Target "Target::Array" +cannot be later rebound to @ref Buffer::Target "Target::Element". However, +%Magnum by default uses any sufficient target when binding the buffer +internally (e.g. for setting data or copying). To avoid this, set target hint +to desired target, either in constructor or using Buffer::setTargetHint(). + */ } diff --git a/src/Buffer.h b/src/Buffer.h index 7473543ff..ff7dcc1a4 100644 --- a/src/Buffer.h +++ b/src/Buffer.h @@ -305,11 +305,13 @@ class MAGNUM_EXPORT Buffer { /** * @brief Constructor + * @param targetHint Target hint, see setTargetHint() for more + * information * * Generates new OpenGL buffer. * @see @fn_gl{GenBuffers} */ - inline Buffer(): _targetHint(Target::Array) { + inline Buffer(Target targetHint = Target::Array): _targetHint(targetHint) { glGenBuffers(1, &_id); }