Commit ca6c800d authored by Aashish Chaudhary's avatar Aashish Chaudhary

Fixed when mappers try to reuse the same texture

This would happen if a mapper reuses a texture and input
has changed. Since the context remains the same the texture
is not destroyed and the texture object uses the same parameters
as the last one (format and type).

Change-Id: I628b1a112966afbc6666412def69ae23031d64fa
parent 84113485
......@@ -160,6 +160,7 @@ void vtkOpenGLTexture::Load(vtkRenderer *ren)
{
this->TextureObject = vtkTextureObject::New();
}
this->TextureObject->ResetFormatAndType();
this->TextureObject->SetContext(renWin);
// Get the scalars the user choose to color with.
......
......@@ -209,9 +209,6 @@ vtkTextureObject::vtkTextureObject()
this->Handle = 0;
this->NumberOfDimensions = 0;
this->Target = 0;
this->Format = 0;
this->InternalFormat = 0;
this->Type = 0;
this->Components = 0;
this->Width = 0;
this->Height = 0;
......@@ -241,6 +238,8 @@ vtkTextureObject::vtkTextureObject()
this->BorderColor[1] = 0.0f;
this->BorderColor[2] = 0.0f;
this->BorderColor[3] = 0.0f;
this->ResetFormatAndType();
}
//----------------------------------------------------------------------------
......@@ -372,12 +371,10 @@ void vtkTextureObject::DestroyTexture()
}
this->Handle = 0;
this->NumberOfDimensions = 0;
this->Target =0;
this->Format = 0;
this->InternalFormat = 0;
this->Type = 0;
this->Target = 0;
this->Components = 0;
this->Width = this->Height = this->Depth = 0;
this->ResetFormatAndType();
}
//----------------------------------------------------------------------------
......@@ -1103,6 +1100,14 @@ void vtkTextureObject::SetFormat(unsigned int glFormat)
}
}
//----------------------------------------------------------------------------
void vtkTextureObject::ResetFormatAndType()
{
this->Format = 0;
this->InternalFormat = 0;
this->Type = 0;
}
//----------------------------------------------------------------------------
static GLenum vtkGetType(int vtk_scalar_type)
{
......
......@@ -310,14 +310,31 @@ public:
int GetDataType(int vtk_scalar_type);
void SetDataType(unsigned int glType);
// Description:
// Get/Set internal format (OpenGL internal format) that should
// be used.
// (https://www.opengl.org/sdk/docs/man2/xhtml/glTexImage2D.xml)
unsigned int GetInternalFormat(int vtktype, int numComps,
bool shaderSupportsTextureInt);
void SetInternalFormat(unsigned int glInternalFormat);
// Description:
// Get/Set format (OpenGL internal format) that should
// be used.
// (https://www.opengl.org/sdk/docs/man2/xhtml/glTexImage2D.xml)
unsigned int GetFormat(int vtktype, int numComps,
bool shaderSupportsTextureInt);
void SetFormat(unsigned int glFormat);
// Description:
// Reset format, internal format, and type of the texture.
//
// This method is useful when a texture is reused in a
// context same as the previous render call. In such
// cases, texture destruction does not happen and therefore
// previous set values are used.
void ResetFormatAndType();
unsigned int GetDepthTextureModeFormat(int vtktype);
unsigned int GetMinificationFilterMode(int vtktype);
unsigned int GetMagnificationFilterMode(int vtktype);
......
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