# Filling a OpenGLVertexBufferObject with a custom DataArray

**URL:** https://discourse.vtk.org/t/filling-a-openglvertexbufferobject-with-a-custom-dataarray/2548
**Category:** Support
**Created:** [February 5, 2020, 9:51am UTC](https://discourse.vtk.org/t/filling-a-openglvertexbufferobject-with-a-custom-dataarray/2548 "2020-02-05T09:51:20Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![BotellaA](https://discourse.vtk.org/user_avatar/discourse.vtk.org/botellaa/32/1243_2.png) [@BotellaA](https://discourse.vtk.org/u/BotellaA)
#### Post date: [February 5, 2020, 9:51am UTC](https://discourse.vtk.org/t/filling-a-openglvertexbufferobject-with-a-custom-dataarray/2548/1 "2020-02-05T09:51:20Z")

</div>

Hello!

I am trying to provide a custom C++ object to a `PolyData` by overriding its `DataArray`. For example, I would like to give a custom DataArray (made of a struct of double) to the PolyData Points.

I have an issue when the `OpenGLVertexBufferObjec`t is filled. I would like to use the [`vtkAppendVBOWorker`](https://gitlab.kitware.com/vtk/vtk/blob/v8.2.0/Rendering/OpenGL2/vtkOpenGLVertexBufferObject.cxx#L240) for my array so I could use the `vtkDataArrayAccessor`. However, it does not seem possible since the [`Dispatcher`](https://gitlab.kitware.com/vtk/vtk/blob/v8.2.0/Rendering/OpenGL2/vtkOpenGLVertexBufferObject.cxx#L385) only looks at `vtkAOSDataArrayTemplate`.

Is there a way to use custom range iteration to fill the `vtkOpenGLVertexBufferObject`?

Thanks for your help

---

<div class="post-metadata">

### Author: ![Michael](https://discourse.vtk.org/user_avatar/discourse.vtk.org/michael/32/16_2.png) [@Michael](https://discourse.vtk.org/u/Michael)
#### Post date: [February 6, 2020, 4:54pm UTC](https://discourse.vtk.org/t/filling-a-openglvertexbufferobject-with-a-custom-dataarray/2548/2 "2020-02-06T16:54:57Z")

</div>

IIRC, you are looking for `vtkPolyDataMapper::MapDataArrayToVertexAttribute`.  
You will be able to access this array in the shader.

---

<div class="post-metadata">

### Author: ![AllisonVacanti](https://discourse.vtk.org/user_avatar/discourse.vtk.org/allisonvacanti/32/2396_2.png) [@AllisonVacanti](https://discourse.vtk.org/u/AllisonVacanti)
#### Post date: [February 13, 2020, 1:27pm UTC](https://discourse.vtk.org/t/filling-a-openglvertexbufferobject-with-a-custom-dataarray/2548/3 "2020-02-13T13:27:35Z")

</div>

You’re in uncharted territory at the moment – I don’t think anyone has actually tried to use a custom dataarray type in VTK with the default dispatchers yet. But the good news is that there are some CMake hooks that can help you build a version of VTK that does what you want.

Take a look at the documentation here: [https://gitlab.kitware.com/vtk/vtk/blob/master/Common/Core/vtkCreateArrayDispatchArrayList.cmake](https://gitlab.kitware.com/vtk/vtk/blob/master/Common/Core/vtkCreateArrayDispatchArrayList.cmake)

Those describe how to configure VTK to build with a custom array type in its default dispatch list. I don’t think this has been widely used, so you may run into some rough edges, but hopefully this will help you get a little farther.
