Commit f97f9dfb authored by Ken Martin's avatar Ken Martin
Browse files

handle wireframe tstrips

Change-Id: I79f9f2415c0b88aa4761da8f5c27b1d0057d019f
parent 42ccec96
......@@ -844,7 +844,6 @@ void vtkOpenGLPolyDataMapper::RenderPieceDraw(vtkRenderer* ren, vtkActor *actor)
GL_UNSIGNED_INT,
reinterpret_cast<const GLvoid *>(NULL));
}
// TODO fix wireframe
if (actor->GetProperty()->GetRepresentation() == VTK_WIREFRAME)
{
for (size_t eCount = 0;
......@@ -1058,26 +1057,29 @@ void vtkOpenGLPolyDataMapper::UpdateVBO(vtkActor *act)
this->lines.indexCount = CreateMultiIndexBuffer(prims[1],
this->lines.ibo,
this->lines.offsetArray,
this->lines.elementsArray);
this->lines.elementsArray, false);
if (act->GetProperty()->GetRepresentation() == VTK_WIREFRAME)
{
this->tris.indexCount = CreateMultiIndexBuffer(prims[2],
this->tris.ibo,
this->tris.offsetArray,
this->tris.elementsArray);
this->tris.elementsArray, false);
this->triStrips.indexCount = CreateMultiIndexBuffer(prims[3],
this->triStrips.ibo,
this->triStrips.offsetArray,
this->triStrips.elementsArray, true);
}
else // SURFACE
{
this->tris.indexCount = CreateTriangleIndexBuffer(prims[2],
this->tris.ibo,
poly->GetPoints());
}
this->triStrips.indexCount = CreateMultiIndexBuffer(prims[3],
this->triStrips.indexCount = CreateMultiIndexBuffer(prims[3],
this->triStrips.ibo,
this->triStrips.offsetArray,
this->triStrips.elementsArray);
this->triStrips.elementsArray, false);
}
}
// free up new cell arrays
......
......@@ -495,14 +495,14 @@ void vtkOpenGLPolyDataMapper2D::UpdateVBO(vtkActor2D *act, vtkViewport *viewport
this->Internal->lines.indexCount = CreateMultiIndexBuffer(prims[1],
this->Internal->lines.ibo,
this->Internal->lines.offsetArray,
this->Internal->lines.elementsArray);
this->Internal->lines.elementsArray, false);
this->Internal->tris.indexCount = CreateTriangleIndexBuffer(prims[2],
this->Internal->tris.ibo,
poly->GetPoints());
this->Internal->triStrips.indexCount = CreateMultiIndexBuffer(prims[3],
this->Internal->triStrips.ibo,
this->Internal->triStrips.offsetArray,
this->Internal->triStrips.elementsArray);
this->Internal->triStrips.elementsArray, false);
// free up new cell arrays
if (cellScalars)
......
......@@ -358,7 +358,8 @@ size_t CreatePointIndexBuffer(vtkCellArray *cells, BufferObject &indexBuffer)
// used to create an IBO for stripped primatives such as lines and triangle strips
size_t CreateMultiIndexBuffer(vtkCellArray *cells, BufferObject &indexBuffer,
std::vector<GLintptr> &memoryOffsetArray,
std::vector<unsigned int> &elementCountArray)
std::vector<unsigned int> &elementCountArray,
bool wireframeTriStrips)
{
vtkIdType *pts = 0;
vtkIdType npts = 0;
......@@ -370,12 +371,26 @@ size_t CreateMultiIndexBuffer(vtkCellArray *cells, BufferObject &indexBuffer,
for (cells->InitTraversal(); cells->GetNextCell(npts,pts); )
{
memoryOffsetArray.push_back(count*sizeof(unsigned int));
elementCountArray.push_back(npts);
for (int j = 0; j < npts; ++j)
{
indexArray.push_back(static_cast<unsigned int>(pts[j]));
count++;
}
if (wireframeTriStrips)
{
for (int j = (npts-1)/2; j >= 0; j--)
{
indexArray.push_back(static_cast<unsigned int>(pts[j*2]));
count++;
}
for (int j = 1; j < (npts/2)*2; j += 2)
{
indexArray.push_back(static_cast<unsigned int>(pts[j]));
count++;
}
npts *= 2;
}
elementCountArray.push_back(npts);
}
indexBuffer.Upload(indexArray, vtkgl::BufferObject::ElementArrayBuffer);
return indexArray.size();
......
......@@ -48,7 +48,8 @@ size_t CreatePointIndexBuffer(vtkCellArray *cells, BufferObject &indexBuffer);
// used to create an IBO for line strips and triangle strips
size_t CreateMultiIndexBuffer(vtkCellArray *cells, BufferObject &indexBuffer,
std::vector<GLintptr> &memoryOffsetArray,
std::vector<unsigned int> &elementCountArray);
std::vector<unsigned int> &elementCountArray,
bool wireframeTriStrips);
// Store the shaders, program, and ibo in a common struct.
struct CellBO
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment