Commit 7b424819 authored by Ken Martin's avatar Ken Martin

some bug fixes

Change-Id: I834e94a505fdb209dc29793931a9c68b0e676111
parent 4b3da320
......@@ -92,7 +92,11 @@ int TestPDBBallAndStick(int argc, char *argv[])
double elapsed = timer->GetElapsedTime();
cerr << "interactive render time: " << elapsed / numRenders << endl;
ren->GetActiveCamera()->SetPosition(0,0,1);
ren->GetActiveCamera()->SetFocalPoint(0,0,0);
ren->GetActiveCamera()->SetViewUp(0,1,0);
ren->ResetCamera();
ren->GetActiveCamera()->Zoom(1.7);
win->Render();
......
......@@ -313,6 +313,7 @@ void vtkRectilinearWipeRepresentation::BuildRepresentation()
p3[2] + s*(p2[2]-p3[2]));
this->Points->SetPoint(7, p0[0] + t*(p3[0]-p0[0]), p0[1] + t*(p3[1]-p0[1]),
p0[2] + t*(p3[2]-p0[2]));
this->Points->Modified();
// Define the lines
......
......@@ -67,11 +67,16 @@ vtkStandardNewMacro(vtkOpenGL2PolyDataMapper2D);
vtkOpenGL2PolyDataMapper2D::vtkOpenGL2PolyDataMapper2D()
: Internal(new Private)
{
this->TransformedPoints = NULL;
}
//-----------------------------------------------------------------------------
vtkOpenGL2PolyDataMapper2D::~vtkOpenGL2PolyDataMapper2D()
{
if (this->TransformedPoints)
{
this->TransformedPoints->UnRegister(this);
}
delete this->Internal;
}
......@@ -319,8 +324,12 @@ void vtkOpenGL2PolyDataMapper2D::SetCameraShaderParameters(
//-------------------------------------------------------------------------
void vtkOpenGL2PolyDataMapper2D::UpdateVBO(vtkActor2D *act)
void vtkOpenGL2PolyDataMapper2D::UpdateVBO(vtkActor2D *act, vtkViewport *viewport)
{
vtkPoints *p, *displayPts;
int numPts;
int j;
vtkPolyData *poly = this->GetInput();
if (poly == NULL)
{
......@@ -366,10 +375,37 @@ void vtkOpenGL2PolyDataMapper2D::UpdateVBO(vtkActor2D *act)
haveTextures = (ta->GetTexture() != NULL);
}
// Transform the points, if necessary
p = poly->GetPoints();
if ( this->TransformCoordinate )
{
numPts = p->GetNumberOfPoints();
if (!this->TransformedPoints)
{
this->TransformedPoints = vtkPoints::New();
}
this->TransformedPoints->SetNumberOfPoints(numPts);
for ( j=0; j < numPts; j++ )
{
this->TransformCoordinate->SetValue(p->GetPoint(j));
if (this->TransformCoordinateUseDouble)
{
double* dtmp = this->TransformCoordinate->GetComputedDoubleViewportValue(viewport);
this->TransformedPoints->SetPoint(j,dtmp[0], dtmp[1], 0.0);
}
else
{
int* itmp = this->TransformCoordinate->GetComputedViewportValue(viewport);
this->TransformedPoints->SetPoint(j,itmp[0], itmp[1], 0.0);
}
}
p = this->TransformedPoints;
}
// Iterate through all of the different types in the polydata, building VBOs
// and IBOs as appropriate for each type.
this->Internal->layout =
CreateVBO(poly->GetPoints(),
CreateVBO(p,
cellPointMap.size() > 0 ? cellPointMap.size() : poly->GetPoints()->GetNumberOfPoints(),
NULL,
haveTextures ? poly->GetPointData()->GetTCoords() : NULL,
......@@ -402,7 +438,6 @@ void vtkOpenGL2PolyDataMapper2D::UpdateVBO(vtkActor2D *act)
prims[primType]->UnRegister(this);
}
}
}
......@@ -410,10 +445,8 @@ void vtkOpenGL2PolyDataMapper2D::RenderOverlay(vtkViewport* viewport,
vtkActor2D* actor)
{
vtkOpenGLClearErrorMacro();
int numPts;
int numPts;
vtkPolyData *input=static_cast<vtkPolyData *>(this->GetInput());
int j;
vtkPoints *p, *displayPts;
vtkDebugMacro (<< "vtkOpenGL2PolyDataMapper2D::Render");
......@@ -439,43 +472,6 @@ void vtkOpenGL2PolyDataMapper2D::RenderOverlay(vtkViewport* viewport,
this->CreateDefaultLookupTable();
}
// Transform the points, if necessary
p = input->GetPoints();
if ( this->TransformCoordinate )
{
numPts = p->GetNumberOfPoints();
displayPts = vtkPoints::New();
displayPts->SetNumberOfPoints(numPts);
for ( j=0; j < numPts; j++ )
{
this->TransformCoordinate->SetValue(p->GetPoint(j));
if (this->TransformCoordinateUseDouble)
{
double* dtmp = this->TransformCoordinate->GetComputedDoubleViewportValue(viewport);
displayPts->SetPoint(j,dtmp[0], dtmp[1], 0.0);
}
else
{
int* itmp = this->TransformCoordinate->GetComputedViewportValue(viewport);
displayPts->SetPoint(j,itmp[0], itmp[1], 0.0);
}
}
p = displayPts;
}
if ( this->TransformCoordinate )
{
p->Delete();
}
// push a 2D matrix on the stack
if(viewport->GetIsPicking())
{
vtkgluPickMatrix(viewport->GetPickX(), viewport->GetPickY(),
viewport->GetPickWidth(),
viewport->GetPickHeight(),
viewport->GetOrigin(), viewport->GetSize());
}
// Assume we want to do Zbuffering for now.
// we may turn this off later
glDepthMask(GL_TRUE);
......@@ -485,7 +481,7 @@ void vtkOpenGL2PolyDataMapper2D::RenderOverlay(vtkViewport* viewport,
this->VBOUpdateTime < actor->GetMTime() ||
this->VBOUpdateTime < input->GetMTime() )
{
this->UpdateVBO(actor);
this->UpdateVBO(actor, viewport);
this->VBOUpdateTime.Modified();
}
......
......@@ -28,6 +28,7 @@
#include "vtkPolyDataMapper2D.h"
class vtkRenderer;
class vtkPoints;
namespace vtkgl {struct CellBO; }
......@@ -64,12 +65,13 @@ protected:
// Description:
// Update the scene when necessary.
void UpdateVBO(vtkActor2D *act);
void UpdateVBO(vtkActor2D *act, vtkViewport *viewport);
class Private;
Private *Internal;
vtkTimeStamp VBOUpdateTime; // When was the VBO updated?
vtkPoints *TransformedPoints;
private:
vtkOpenGL2PolyDataMapper2D(const vtkOpenGL2PolyDataMapper2D&); // Not implemented.
......
......@@ -249,7 +249,14 @@ void vtkOpenGL2Renderer::Clear(void)
clear_mask |= GL_COLOR_BUFFER_BIT;
}
if (!this->GetPreserveDepthBuffer())
{
glClearDepth(static_cast<GLclampf>(1.0));
clear_mask |= GL_DEPTH_BUFFER_BIT;
}
vtkDebugMacro(<< "glClear\n");
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glClear(clear_mask);
// If gradient background is turned on, draw it now.
......@@ -336,12 +343,6 @@ void vtkOpenGL2Renderer::Clear(void)
actor->RenderOverlay(this);
}
if (!this->GetPreserveDepthBuffer())
{
glClearDepth(static_cast<GLclampf>(1.0));
glClear(GL_DEPTH_BUFFER_BIT);
}
glEnable(GL_DEPTH_TEST);
vtkOpenGLCheckErrorMacro("failed after Clear");
......
......@@ -356,11 +356,6 @@ void vtkOpenGL2Texture::Load(vtkRenderer *ren)
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, this->Index);
// don't accept fragments if they have zero opacity. this will stop the
// zbuffer from be blocked by totally transparent texture fragments.
glAlphaFunc(GL_GREATER, static_cast<GLclampf>(0.f));
glEnable(GL_ALPHA_TEST);
if (this->PremultipliedAlpha)
{
// save the blend function.
......
......@@ -363,6 +363,8 @@ size_t CreateMultiIndexBuffer(vtkCellArray *cells, BufferObject &indexBuffer,
vtkIdType *pts = 0;
vtkIdType npts = 0;
std::vector<unsigned int> indexArray;
memoryOffsetArray.clear();
elementCountArray.clear();
unsigned int count = 0;
indexArray.reserve(cells->GetData()->GetSize());
for (cells->InitTraversal(); cells->GetNextCell(npts,pts); )
......
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