Commit 69bafcd8 authored by Ken Martin's avatar Ken Martin

Fix some coverity issues

Fix a bunch of issues reported by coverity that seemed
fairly stright forward and related to rendering
parent bfbdc62b
Pipeline #3419 passed with stage
......@@ -963,14 +963,20 @@ void vtkBrokenLineWidget::Spin( double *p1, double *p2, double *vpn )
if ( this->ProjectToPlane )
{
if ( this->ProjectionNormal == VTK_PROJECTION_OBLIQUE && \
this->PlaneSource != NULL )
if ( this->ProjectionNormal == VTK_PROJECTION_OBLIQUE)
{
double* normal = this->PlaneSource->GetNormal();
axis[0] = normal[0];
axis[1] = normal[1];
axis[2] = normal[2];
vtkMath::Normalize( axis );
if (this->PlaneSource != NULL )
{
double* normal = this->PlaneSource->GetNormal();
axis[0] = normal[0];
axis[1] = normal[1];
axis[2] = normal[2];
vtkMath::Normalize( axis );
}
else
{
axis[0] = 1.;
}
}
else
{
......
......@@ -458,18 +458,24 @@ void vtkCurveRepresentation::Spin(double *p1, double *p2, double *vpn)
if ( this->ProjectToPlane )
{
if ( this->ProjectionNormal == VTK_PROJECTION_OBLIQUE && \
this->PlaneSource != NULL )
if ( this->ProjectionNormal == VTK_PROJECTION_OBLIQUE)
{
double* normal = this->PlaneSource->GetNormal();
axis[0] = normal[0];
axis[1] = normal[1];
axis[2] = normal[2];
vtkMath::Normalize(axis);
if (this->PlaneSource != NULL )
{
double* normal = this->PlaneSource->GetNormal();
axis[0] = normal[0];
axis[1] = normal[1];
axis[2] = normal[2];
vtkMath::Normalize( axis );
}
else
{
axis[0] = 1.;
}
}
else
{
axis[ this->ProjectionNormal ] = 1.0;
axis[ this->ProjectionNormal ] = 1.;
}
}
else
......
......@@ -360,7 +360,7 @@ void vtkRenderWindow::Render()
{
p1 = this->AccumulationBuffer;
unsigned char *p2;
unsigned char *p3;
unsigned char *p3 = NULL;
if (this->ResultFrame)
{
p2 = this->ResultFrame;
......@@ -368,8 +368,8 @@ void vtkRenderWindow::Render()
else
{
p2 = this->GetPixelData(0,0,size[0]-1,size[1]-1,!this->DoubleBuffer);
p3 = p2;
}
p3 = p2;
for (y = 0; y < size[1]; y++)
{
for (x = 0; x < size[0]; x++)
......@@ -379,7 +379,10 @@ void vtkRenderWindow::Render()
*p1 += *p2; p1++; p2++;
}
}
delete [] p3;
if (p3)
{
delete [] p3;
}
}
// if this is the last sub frame then convert back into unsigned char
......
......@@ -502,6 +502,8 @@ void vtkTextMapper::UpdateQuad(vtkActor2D *actor, int dpi)
else
{
vtkErrorMacro(<<"Could not locate vtkTextRenderer object.");
text_bbox[0] = 0;
text_bbox[2] = 0;
}
double x = static_cast<double>(text_bbox[0]);
......
......@@ -59,17 +59,20 @@ public:
vtkMath::HSVToRGB(inputHSV,diffuseColor);
cellBO->Program->SetUniform3f("diffuseColorUniform", diffuseColor);
inputHSV[0] = sin(twopi*fmod(theTime,5.0)/5.0)/4.0 + 0.75;
inputHSV[1] = sin(twopi*fmod(theTime,7.0)/7.0)/2.0 + 0.5;
inputHSV[2] = 0.5*(sin(twopi*fmod(theTime,17.0)/17.0)/2.0 + 0.5);
vtkMath::HSVToRGB(inputHSV,diffuseColor);
this->Renderer->SetBackground(diffuseColor[0], diffuseColor[1], diffuseColor[2]);
inputHSV[0] = sin(twopi*fmod(theTime,11.0)/11.0)/2.0+0.5;
inputHSV[1] = sin(twopi*fmod(theTime,13.0)/13.0)/2.0 + 0.5;
inputHSV[2] = 0.5*(sin(twopi*fmod(theTime,17.0)/17.0)/2.0 + 0.5);
vtkMath::HSVToRGB(inputHSV,diffuseColor);
this->Renderer->SetBackground2(diffuseColor[0], diffuseColor[1], diffuseColor[2]);
if (this->Renderer)
{
inputHSV[0] = sin(twopi*fmod(theTime,5.0)/5.0)/4.0 + 0.75;
inputHSV[1] = sin(twopi*fmod(theTime,7.0)/7.0)/2.0 + 0.5;
inputHSV[2] = 0.5*(sin(twopi*fmod(theTime,17.0)/17.0)/2.0 + 0.5);
vtkMath::HSVToRGB(inputHSV,diffuseColor);
this->Renderer->SetBackground(diffuseColor[0], diffuseColor[1], diffuseColor[2]);
inputHSV[0] = sin(twopi*fmod(theTime,11.0)/11.0)/2.0+0.5;
inputHSV[1] = sin(twopi*fmod(theTime,13.0)/13.0)/2.0 + 0.5;
inputHSV[2] = 0.5*(sin(twopi*fmod(theTime,17.0)/17.0)/2.0 + 0.5);
vtkMath::HSVToRGB(inputHSV,diffuseColor);
this->Renderer->SetBackground2(diffuseColor[0], diffuseColor[1], diffuseColor[2]);
}
#else
diffuseColor[0] = 0.4;
diffuseColor[1] = 0.7;
......@@ -78,7 +81,7 @@ public:
#endif
}
vtkShaderCallback() {}
vtkShaderCallback() { this->Renderer = 0; }
};
//----------------------------------------------------------------------------
......
......@@ -47,6 +47,9 @@ vtkStandardNewMacro(vtkCompositePolyDataMapper2);
vtkCompositePolyDataMapper2::vtkCompositePolyDataMapper2()
{
this->UseGeneric = true;
this->MaximumFlatIndex = 0;
this->CanUseTextureMapForColoringSet = false;
this->CanUseTextureMapForColoringValue = false;
}
//----------------------------------------------------------------------------
......
......@@ -63,6 +63,12 @@ vtkDepthPeelingPass::vtkDepthPeelingPass()
this->OpaqueRGBATexture = NULL;
this->TranslucentRGBATexture = NULL;
this->CurrentRGBATexture = NULL;
this->ViewportX = 0;
this->ViewportY = 0;
this->ViewportWidth = 100;
this->ViewportHeight = 100;
}
// ----------------------------------------------------------------------------
......@@ -370,7 +376,7 @@ void vtkDepthPeelingPass::Render(const vtkRenderState *s)
}
// create textures we need if not done already
if (this->OpaqueZTexture == NULL)
if (this->OpaqueRGBATexture == NULL)
{
this->OpaqueZTexture = vtkDepthPeelingPassCreateTextureObject(
renWin, this->ViewportWidth, this->ViewportHeight, 1, true, NULL);
......
......@@ -131,11 +131,6 @@ public:
int ViewportWidth;
int ViewportHeight;
// Description:
// Actual depth format: vtkgl::DEPTH_COMPONENT16_ARB
// or vtkgl::DEPTH_COMPONENT24_ARB
unsigned int DepthFormat;
// Description:
// In case of use of depth peeling technique for rendering translucent
// material, define the threshold under which the algorithm stops to
......
......@@ -92,6 +92,8 @@ vtkEDLShading::vtkEDLShading()
this->EDLNeighbours[c][3] = 0.;
}
this->EDLLowResFactor = 2;
this->Zn = 0.1;
this->Zf = 1.0;
}
// ----------------------------------------------------------------------------
......@@ -392,8 +394,8 @@ bool vtkEDLShading::EDLShadeHigh(
prog->SetUniformf("SY", SY);
prog->SetUniform3f("L", L);
prog->SetUniform4fv("N", 8, this->EDLNeighbours);
prog->SetUniformf("Znear", Zn);
prog->SetUniformf("Zfar", Zf);
prog->SetUniformf("Znear", this->Zn);
prog->SetUniformf("Zfar", this->Zf);
// compute the scene bounding box, and set the scene size to the diagonal of it.
double bb[6];
......@@ -480,8 +482,8 @@ bool vtkEDLShading::EDLShadeLow(
prog->SetUniformf("SY", SY);
prog->SetUniform3f("L", L);
prog->SetUniform4fv("N", 8, this->EDLNeighbours); // USELESS, ALREADY DEFINED IN FULL RES
prog->SetUniformf("Znear", Zn);
prog->SetUniformf("Zfar", Zf);
prog->SetUniformf("Znear", this->Zn);
prog->SetUniformf("Zfar", this->Zf);
// RENDER AND FREE ALL
//
......@@ -592,10 +594,6 @@ bool vtkEDLShading::EDLCompose(const vtkRenderState *,
this->ProjectionDepthTexture->Activate();
prog->SetUniformi("s2_Z", this->ProjectionDepthTexture->GetTextureUnit());
//
//prog->SetUniformf("Zn",Zn);
//prog->SetUniformf("Zf",Zf);
// DRAW CONTEXT - prepare blitting
//
// Prepare blitting
......
......@@ -300,7 +300,6 @@ protected:
unsigned int FBOIndex;
unsigned int PreviousDrawFBO;
unsigned int PreviousReadFBO;
unsigned int DepthBuffer;
unsigned int PreviousDrawBuffer;
unsigned int PreviousReadBuffer;
......
......@@ -55,7 +55,13 @@ public:
int LastTCoordComponents;
protected:
vtkCompositeMapperHelper() {};
vtkCompositeMapperHelper()
{
this->Parent = 0;
this->LastColorCoordinates = 0;
this->LastNormalsOffset = 0;
this->LastTCoordComponents = 0;
};
~vtkCompositeMapperHelper() {};
// Description:
......@@ -215,6 +221,8 @@ vtkStandardNewMacro(vtkGenericCompositePolyDataMapper2);
vtkGenericCompositePolyDataMapper2::vtkGenericCompositePolyDataMapper2()
{
this->LastOpaqueCheckTime = 0;
this->CurrentFlatIndex = 0;
this->LastOpaqueCheckValue = true;
}
//----------------------------------------------------------------------------
......
......@@ -33,6 +33,7 @@ vtkInformationKeyMacro(vtkLightingMapPass, RENDER_NORMALS, Integer);
// ----------------------------------------------------------------------------
vtkLightingMapPass::vtkLightingMapPass()
{
this->RenderType = LUMINANCE;
}
// ----------------------------------------------------------------------------
......
......@@ -42,6 +42,7 @@ struct vtkOpenGLBufferObject::Private
Private()
{
this->Handle = 0;
this->Type = GL_ARRAY_BUFFER;
}
GLenum Type;
GLuint Handle;
......
......@@ -68,6 +68,7 @@ public:
this->Mapper->SetInputData(ss);
ss->Delete();
this->Mapper->SetPopulateSelectionSettings(0);
this->NumberOfPoints = 0;
};
~vtkOpenGLGlyph3DMapperEntry()
{
......@@ -129,13 +130,14 @@ vtkOpenGLGlyph3DMapper::~vtkOpenGLGlyph3DMapper()
{
this->ColorMapper->Delete();
delete this->GlyphValues;
if (this->LastWindow)
{
this->ReleaseGraphicsResources(this->LastWindow);
this->LastWindow = 0;
}
delete this->GlyphValues;
this->GlyphValues = 0;
}
// ---------------------------------------------------------------------------
......@@ -725,13 +727,16 @@ void vtkOpenGLGlyph3DMapper::RebuildStructures(
// Release any graphics resources that are being consumed by this mapper.
void vtkOpenGLGlyph3DMapper::ReleaseGraphicsResources(vtkWindow *window)
{
std::map<const vtkDataSet *, vtkOpenGLGlyph3DMapper::vtkOpenGLGlyph3DMapperSubArray *>::iterator miter = this->GlyphValues->Entries.begin();
for (;miter != this->GlyphValues->Entries.end(); miter++)
if (this->GlyphValues)
{
std::map<size_t, vtkOpenGLGlyph3DMapper::vtkOpenGLGlyph3DMapperEntry *>::iterator miter2 = miter->second->Entries.begin();
for (;miter2 != miter->second->Entries.end(); miter2++)
std::map<const vtkDataSet *, vtkOpenGLGlyph3DMapper::vtkOpenGLGlyph3DMapperSubArray *>::iterator miter = this->GlyphValues->Entries.begin();
for (;miter != this->GlyphValues->Entries.end(); miter++)
{
miter2->second->Mapper->ReleaseGraphicsResources(window);
std::map<size_t, vtkOpenGLGlyph3DMapper::vtkOpenGLGlyph3DMapperEntry *>::iterator miter2 = miter->second->Entries.begin();
for (;miter2 != miter->second->Entries.end(); miter2++)
{
miter2->second->Mapper->ReleaseGraphicsResources(window);
}
}
}
}
......
......@@ -120,6 +120,12 @@ vtkOpenGLPointGaussianMapperHelper::vtkOpenGLPointGaussianMapperHelper()
this->Owner = NULL;
this->OpacityTable = 0;
this->ScaleTable = 0;
this->UsingPoints = false;
this->OpacityScale = 1.0;
this->ScaleScale = 1.0;
this->OpacityOffset = 0.0;
this->ScaleOffset = 0.0;
this->TriangleScale = 0.0;
}
......
......@@ -80,6 +80,8 @@ vtkOpenGLPolyDataMapper::vtkOpenGLPolyDataMapper()
this->DrawingEdges = false;
this->ForceTextureCoordinates = false;
this->PrimitiveIDOffset = 0;
this->CellScalarTexture = NULL;
this->CellScalarBuffer = NULL;
this->CellNormalTexture = NULL;
......@@ -2866,7 +2868,6 @@ void vtkOpenGLPolyDataMapper::BuildBufferObjects(vtkRenderer *ren, vtkActor *act
// for coloring with a point attribute.
// fixme ... make the existence of the coordinate array the signal.
vtkDataArray *tcoords = NULL;
this->TextureComponents = 4;
if (haveTextures)
{
if (this->InterpolateScalarsBeforeMapping && this->ColorCoordinates)
......@@ -3018,7 +3019,7 @@ void vtkOpenGLPolyDataMapper::BuildIBO(
vtkDebugMacro(<< "Currently only 1d edge flags are supported.");
ef = NULL;
}
if (!ef->IsA("vtkUnsignedCharArray"))
else if (!ef->IsA("vtkUnsignedCharArray"))
{
vtkDebugMacro(<< "Currently only unsigned char edge flags are suported.");
ef = NULL;
......
......@@ -344,8 +344,6 @@ protected:
char* ProcessIdArrayName;
char* CompositeIdArrayName;
int TextureComponents;
class ReplacementSpec
{
public:
......
......@@ -57,6 +57,10 @@ vtkOpenGLPolyDataMapper2D::vtkOpenGLPolyDataMapper2D()
this->CellScalarBuffer = NULL;
this->VBO = vtkOpenGLVertexBufferObject::New();
this->AppleBugPrimIDBuffer = 0;
this->HaveAppleBug = false;
this->LastBoundBO = 0;
this->HaveCellScalars = false;
this->PrimitiveIDOffset = 0;
}
//-----------------------------------------------------------------------------
......
......@@ -61,6 +61,7 @@ void vtkOpenGLRenderUtilities::RenderTriangles(
if (!program || !vao || !verts)
{
vtkGenericWarningMacro(<< "Error must have verts, program and vao");
return;
}
vtkNew<vtkOpenGLBufferObject> vbo;
......
......@@ -464,7 +464,6 @@ unsigned char *vtkOpenGLTexture::ResampleToPowerOfTwo(int &xs,
void vtkOpenGLTexture::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os,indent);
os << indent << "Index: " << this->Index << endl;
}
// ----------------------------------------------------------------------------
......
......@@ -55,10 +55,6 @@ public:
// render windows is NOT currently supported.
void ReleaseGraphicsResources(vtkWindow*);
// Description:
// Get the openGL texture name to which this texture is bound.
vtkGetMacro(Index, long);
// Description
// copy the renderers read buffer into this texture
void CopyTexImage(int x, int y, int width, int height);
......@@ -92,7 +88,6 @@ protected:
~vtkOpenGLTexture();
vtkTimeStamp LoadTime;
unsigned int Index; // actually GLuint
vtkWeakPointer<vtkRenderWindow> RenderWindow; // RenderWindow used for previous render
bool ExternalTextureObject;
......
......@@ -633,7 +633,6 @@ protected:
int WrapR;
int MinificationFilter;
int MagnificationFilter;
bool LinearMagnification;
float MinLOD;
float MaxLOD;
......
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