# Deprecated VboMesh Functionality

**URL:** <https://discourse.libcinder.org/t/deprecated-vbomesh-functionality/795>\
**Category:** Using Cinder\
**Created:** [July 19, 2017, 1:55am UTC](https://discourse.libcinder.org/t/deprecated-vbomesh-functionality/795 "2017-07-19T01:55:09Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![paul.houx](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/paul.houx/32/31_2.png) [@paul.houx](https://discourse.libcinder.org/u/paul.houx)\
**Post date:** [July 19, 2017, 6:59pm UTC](https://discourse.libcinder.org/t/deprecated-vbomesh-functionality/795/6 "2017-07-19T18:59:46Z")

</div>

Hi,

just to briefly summarize how to use the `VboMesh` class: it’s simply a set of arrays, describing the position of every vertex, as well as other vertex attributes like color, texture coordinate, normal, tangent, etc. The data is initialized and constructed on the CPU, then sent to GPU memory.

If the mesh does not change, you only have to send it once and then you can draw it an infinite amount of times. If the mesh does change, however, you can replace the data with a new copy, or iterate over the existing data to update it using the `mapAttrib*()` functions. The latter is more efficient, especially when using the `orphanExisting = true` flag. Because when this flag is set to true, the GPU allocates a second buffer for the new data, so that it can keep using the original buffer while the data is being updated. Updating the data usually takes a while and this way the GPU does not have to wait at all. For more in-depth info, see [this presentation](http://gamedevs.org/uploads/efficient-buffer-management.pdf).

Cinder defines a bunch of default attributes: COLOR, TEX\_COORD\_0 / 1 / 2 / 3, NORMAL, TANGENT, BITANGENT, BONE\_INDEX and BONE\_WEIGHT. All of these are optional. Additionally, you can add up to 10 custom attributes using the CUSTOM\_0 to CUSTOM\_9 enums. Each attribute can store up to 4 floats (e.g. `float`, `vec2`, `vec3`, `vec4`).

You can then access those attributes in your vertex shader:

```auto
in vec4 ciPosition;
in vec4 ciColor;
in vec2 ciTexCoord0;
in vec3 ciNormal;
in vec3 ciTangent;
in vec3 ciBitangent;
in ivec4 ciBoneIndex;
in vec4 ciBoneWeight;

```

_Edit: since the custom attributes can be used for anything at all, Cinder does not provide an automatic_ `ciCustom0` _mapping. Instead, specify the name either in_ `gl::GlslProg::Format().attrib( geom::CUSTOM_0, "myAttributeName" )` _or when creating the batch:_ `auto batch = gl::Batch::create( mesh, glsl, { { geom::CUSTOM_0, "myAttributeName" } } );`

To learn more about how to setup a mesh, have a look at [this sample](https://github.com/paulhoux/Cinder-Samples/blob/master/SmoothDisplacementMapping/src/SmoothDisplacementMappingApp.cpp#L367-L422). The sample uses a vertex shader to update the mesh, which is slightly more advanced. But to learn how to update from the CPU, see [this Cinder sample](https://github.com/cinder/Cinder/blob/3fc0c0f8ae268fa0589e412d19c7372951cef447/samples/_opengl/VboMesh/src/VboMeshApp.cpp#L62-L76). _Edit: to see a use case of custom attributes, check out_ [this](https://github.com/paulhoux/Cinder-Samples/blob/198ad7e352f5c7a6e8cf87d77a69e7c5270f2c02/HexagonMirror/src/HexagonMirrorApp.cpp#L222-L231) _sample._

-Paul

---

_[View the full topic](https://discourse.libcinder.org/t/deprecated-vbomesh-functionality/795)._
