<p class="p1">I'm trying to write my own vtkVBO mapper to pass polyData to a vertex buffer object but I'm not sure how to setup the indices array</p><p class="p1">// Indices <span class="s1">vbo<br></span>vtkgl::GenBuffers(1, &VBOIndices<span class="s2">Id</span>);<br>
vtkgl::BindBuffer(vtkgl::ELEMENT_ARRAY_BUFFER, VBOIndices<span class="s2">Id</span>);</p>
<p class="p3"><span class="s3">I found some code in vtkOpenGLPainterDeviceAdapter.cxx</span></p><p class="p3"><span class="s3">
</span></p><p class="p1">// This seems really inefficient for handling vtkIdType when they<br>// are 64 bit, but OpenGL does not handle 64 bit indices. What<br>// else can I do?</p>
<p class="p2"><span class="s2">vtkIdType</span> *oldarray = <span class="s3">static_cast</span><<span class="s2">vtkIdType</span> *>(indices);<br>GLuint *newarray = <span class="s3">new</span> GLuint[count];<br>std::copy(oldarray, oldarray + count, newarray);<br>
glDrawElements(VTK2OpenGLPrimitive[mode], <span class="s3">static_cast</span><GLsizei>(count), GL_UNSIGNED_INT, newarray);</p><p></p><p class="p3"><span class="s3">But, this doesn't seem to help as newarray still contains the tuple data, ie (1, id) resulting in twice the data</span></p>
<p class="p1">For now, I don't really need the indice values stored in each cell as I'm displaying everything and the range 0-count as an array is okay</p><p class="p1"><span class="s1">vtkPolyData</span> *input= <span class="s2">this</span>->GetInput();<br>
<span class="s1">vtkPoints</span> *points = input->GetPoints();<br>vtkCellArray *<span class="s3">verts</span> = input->GetVerts();<br>vtkIdType *pIds = <span class="s3">verts</span>->GetPointer();<br><span class="s2">unsigned</span> <span class="s2">int</span> numPoints = points->GetNumberOfPoints(); </p>
<p class="p1">// For now, display every <span class="s1">indice<br></span><span class="s4">unsigned</span> <span class="s4">int</span> *indices = <span class="s4">new</span> <span class="s4">unsigned</span> <span class="s4">int</span>[numPoints];<br>
<span class="s4">for</span> (<span class="s5">size_t</span> i=0; i < numPoints; i++)<br> indices[i] = i;</p>
<p class="p3">vtkgl::BufferData(vtkgl::ELEMENT_ARRAY_BUFFER, numPoints * <span class="s4">sizeof</span>(<span class="s4">unsigned</span> <span class="s4">int</span>), indices, vtkgl::DYNAMIC_DRAW);</p><p class="p3"><br></p>
<p class="p3">Thanks!<br>Justin</p>