[vtkusers] What's the best/correct way to pass vtkIdType to a glBufferData call?
Justin Rosen
jmylesrosen at gmail.com
Thu Mar 22 04:28:31 EDT 2012
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
// Indices vbo
vtkgl::GenBuffers(1, &VBOIndicesId);
vtkgl::BindBuffer(vtkgl::ELEMENT_ARRAY_BUFFER, VBOIndicesId);
I found some code in vtkOpenGLPainterDeviceAdapter.cxx
// This seems really inefficient for handling vtkIdType when they
// are 64 bit, but OpenGL does not handle 64 bit indices. What
// else can I do?
vtkIdType *oldarray = static_cast<vtkIdType *>(indices);
GLuint *newarray = new GLuint[count];
std::copy(oldarray, oldarray + count, newarray);
glDrawElements(VTK2OpenGLPrimitive[mode], static_cast<GLsizei>(count),
GL_UNSIGNED_INT,
newarray);
But, this doesn't seem to help as newarray still contains the tuple data,
ie (1, id) resulting in twice the data
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
vtkPolyData *input= this->GetInput();
vtkPoints *points = input->GetPoints();
vtkCellArray *verts = input->GetVerts();
vtkIdType *pIds = verts->GetPointer();
unsigned int numPoints = points->GetNumberOfPoints();
// For now, display every indice
unsigned int *indices = new unsigned int[numPoints];
for (size_t i=0; i < numPoints; i++)
indices[i] = i;
vtkgl::BufferData(vtkgl::ELEMENT_ARRAY_BUFFER, numPoints * sizeof(unsigned
int), indices, vtkgl::DYNAMIC_DRAW);
Thanks!
Justin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120322/66eb59ec/attachment.htm>
More information about the vtkusers
mailing list