Commit 62a7ecd8 authored by Alexis Girault's avatar Alexis Girault

Update texture wrapping modes

TODO
parent 228a0396
...@@ -202,8 +202,7 @@ bool vtkGeoAlignedImageSource::FetchRoot(vtkGeoTreeNode* r) ...@@ -202,8 +202,7 @@ bool vtkGeoAlignedImageSource::FetchRoot(vtkGeoTreeNode* r)
texTrans->Scale(1.0/360.0, 1.0/180.0, 1.0); // to [0,1] texTrans->Scale(1.0/360.0, 1.0/180.0, 1.0); // to [0,1]
texture->SetTransform(texTrans); texture->SetTransform(texTrans);
texture->InterpolateOn(); texture->InterpolateOn();
texture->RepeatOff(); texture->SetWrapMode(vtkTexture::VTKTextureWrapMode::ClampToEdge);
texture->EdgeClampOn();
root->SetLevel(-1); root->SetLevel(-1);
root->SetLatitudeRange(-270, 90); root->SetLatitudeRange(-270, 90);
...@@ -396,8 +395,7 @@ void vtkGeoAlignedImageSource::CropImageForNode(vtkGeoImageNode* node, vtkImageD ...@@ -396,8 +395,7 @@ void vtkGeoAlignedImageSource::CropImageForNode(vtkGeoImageNode* node, vtkImageD
tex->SetTransform(texTrans); tex->SetTransform(texTrans);
tex->SetInputData(cropped); tex->SetInputData(cropped);
tex->InterpolateOn(); tex->InterpolateOn();
tex->RepeatOff(); tex->SetWrapMode(vtkTexture::VTKTextureWrapMode::ClampToEdge);
tex->EdgeClampOn();
node->SetTexture(tex); node->SetTexture(tex);
} }
......
...@@ -177,9 +177,8 @@ bool vtkGeoFileImageSource::ReadImage(int level, int id, vtkGeoImageNode* node) ...@@ -177,9 +177,8 @@ bool vtkGeoFileImageSource::ReadImage(int level, int id, vtkGeoImageNode* node)
texture->SetInputConnection(reader->GetOutputPort()); texture->SetInputConnection(reader->GetOutputPort());
texture->SetTransform(texTrans); texture->SetTransform(texTrans);
texture->RepeatOff(); texture->SetWrapMode(vtkTexture::VTKTextureWrapMode::ClampToEdge);
texture->InterpolateOn(); texture->InterpolateOn();
texture->EdgeClampOn();
node->SetTexture(texture); node->SetTexture(texture);
return true; return true;
} }
......
...@@ -1211,7 +1211,15 @@ void vtkRIBExporter::WriteTexture (vtkTexture *aTexture) ...@@ -1211,7 +1211,15 @@ void vtkRIBExporter::WriteTexture (vtkTexture *aTexture)
// RiBoxFilter, // RiBoxFilter,
// 1, 1, // 1, 1,
// RI_NULL); // RI_NULL);
const char *wrap = aTexture->GetRepeat () ? "periodic" : "clamp"; const char *wrap;
if(aTexture->GetWrapMode() == vtkTexture::VTKTextureWrapMode::Repeat)
{
wrap = "periodic";
}
else
{
"clamp";
}
fprintf (this->FilePtr, "MakeTexture \"%s\" ", this->GetTIFFName (aTexture)); fprintf (this->FilePtr, "MakeTexture \"%s\" ", this->GetTIFFName (aTexture));
fprintf (this->FilePtr, "\"%s\" ", this->GetTextureName (aTexture)); fprintf (this->FilePtr, "\"%s\" ", this->GetTextureName (aTexture));
fprintf (this->FilePtr, "\"%s\" \"%s\" ", wrap, wrap); fprintf (this->FilePtr, "\"%s\" \"%s\" ", wrap, wrap);
......
...@@ -649,7 +649,7 @@ void vtkVRMLExporter::WriteShapeBegin( vtkActor* actor, FILE *fileP, ...@@ -649,7 +649,7 @@ void vtkVRMLExporter::WriteShapeBegin( vtkActor* actor, FILE *fileP,
fprintf(fileP," "); fprintf(fileP," ");
} }
} }
if (!(aTexture->GetRepeat())) if (aTexture->GetWrapMode() != vtkTexture::VTKTextureWrapMode::Repeat)
{ {
fprintf(fileP," repeatS FALSE\n"); fprintf(fileP," repeatS FALSE\n");
fprintf(fileP," repeatT FALSE\n"); fprintf(fileP," repeatT FALSE\n");
......
...@@ -857,7 +857,7 @@ void vtkX3DExporter::WriteATexture(vtkActor *anActor, ...@@ -857,7 +857,7 @@ void vtkX3DExporter::WriteATexture(vtkActor *anActor,
writer->StartNode(PixelTexture); writer->StartNode(PixelTexture);
writer->SetField(image, &(imageDataVec.front()), imageDataVec.size(), true); writer->SetField(image, &(imageDataVec.front()), imageDataVec.size(), true);
if (!(aTexture->GetRepeat())) if (aTexture->GetWrapMode() != vtkTexture::VTKTextureWrapMode::Repeat)
{ {
writer->SetField(repeatS, false); writer->SetField(repeatS, false);
writer->SetField(repeatT, false); writer->SetField(repeatT, false);
......
...@@ -2746,7 +2746,7 @@ void vtkImagePlaneWidget::GenerateTexturePlane() ...@@ -2746,7 +2746,7 @@ void vtkImagePlaneWidget::GenerateTexturePlane()
this->Texture->SetQualityTo32Bit(); this->Texture->SetQualityTo32Bit();
this->Texture->MapColorScalarsThroughLookupTableOff(); this->Texture->MapColorScalarsThroughLookupTableOff();
this->Texture->SetInterpolate(this->TextureInterpolate); this->Texture->SetInterpolate(this->TextureInterpolate);
this->Texture->RepeatOff(); this->Texture->SetWrapMode(vtkTexture::VTKTextureWrapMode::ClampToEdge);
this->Texture->SetLookupTable(this->LookupTable); this->Texture->SetLookupTable(this->LookupTable);
this->TexturePlaneActor->SetMapper(texturePlaneMapper); this->TexturePlaneActor->SetMapper(texturePlaneMapper);
......
...@@ -109,7 +109,7 @@ vtkResliceCursorRepresentation::vtkResliceCursorRepresentation() ...@@ -109,7 +109,7 @@ vtkResliceCursorRepresentation::vtkResliceCursorRepresentation()
this->Texture->SetQualityTo32Bit(); this->Texture->SetQualityTo32Bit();
this->Texture->MapColorScalarsThroughLookupTableOff(); this->Texture->MapColorScalarsThroughLookupTableOff();
this->Texture->SetInterpolate(1); this->Texture->SetInterpolate(1);
this->Texture->RepeatOff(); this->Texture->SetWrapMode(vtkTexture::VTKTextureWrapMode::ClampToEdge);
this->Texture->SetLookupTable(this->LookupTable); this->Texture->SetLookupTable(this->LookupTable);
this->TexturePlaneActor->SetMapper(texturePlaneMapper); this->TexturePlaneActor->SetMapper(texturePlaneMapper);
......
...@@ -238,7 +238,7 @@ vtkScalarBarActor::vtkScalarBarActor() ...@@ -238,7 +238,7 @@ vtkScalarBarActor::vtkScalarBarActor()
this->Texture = vtkTexture::New(); this->Texture = vtkTexture::New();
this->Texture->SetInputData(image); this->Texture->SetInputData(image);
this->Texture->RepeatOn(); this->Texture->SetWrapMode(vtkTexture::VTKTextureWrapMode::Repeat);
this->TextureActor->SetTexture(this->Texture); this->TextureActor->SetTexture(this->Texture);
image->Delete(); image->Delete();
......
...@@ -1122,8 +1122,15 @@ void vtkOpenGLContextDevice2D::DrawPointSprites(vtkImageData *sprite, ...@@ -1122,8 +1122,15 @@ void vtkOpenGLContextDevice2D::DrawPointSprites(vtkImageData *sprite,
} }
int properties = this->Brush->GetTextureProperties(); int properties = this->Brush->GetTextureProperties();
this->Storage->SpriteTexture->SetInputData(sprite); this->Storage->SpriteTexture->SetInputData(sprite);
this->Storage->SpriteTexture->SetRepeat(properties & vtkContextDevice2D::Repeat);
this->Storage->SpriteTexture->SetInterpolate(properties & vtkContextDevice2D::Linear); this->Storage->SpriteTexture->SetInterpolate(properties & vtkContextDevice2D::Linear);
if (properties & vtkContextDevice2D::Repeat)
{
this->Storage->SpriteTexture->SetWrapMode(vtkTexture::VTKTextureWrapMode::Repeat);
}
else
{
this->Storage->SpriteTexture->SetWrapMode(vtkTexture::VTKTextureWrapMode::ClampToEdge);
}
this->Storage->SpriteTexture->Render(this->Renderer); this->Storage->SpriteTexture->Render(this->Renderer);
int tunit = vtkOpenGLTexture::SafeDownCast( int tunit = vtkOpenGLTexture::SafeDownCast(
this->Storage->SpriteTexture)->GetTextureUnit(); this->Storage->SpriteTexture)->GetTextureUnit();
...@@ -2045,9 +2052,15 @@ void vtkOpenGLContextDevice2D::SetTexture(vtkImageData* image, int properties) ...@@ -2045,9 +2052,15 @@ void vtkOpenGLContextDevice2D::SetTexture(vtkImageData* image, int properties)
} }
this->Storage->Texture->SetInputData(image); this->Storage->Texture->SetInputData(image);
this->Storage->TextureProperties = properties; this->Storage->TextureProperties = properties;
this->Storage->Texture->SetRepeat(properties & vtkContextDevice2D::Repeat);
this->Storage->Texture->SetInterpolate(properties & vtkContextDevice2D::Linear); this->Storage->Texture->SetInterpolate(properties & vtkContextDevice2D::Linear);
this->Storage->Texture->EdgeClampOn(); if (properties & vtkContextDevice2D::Repeat)
{
this->Storage->Texture->SetWrapMode(vtkTexture::VTKTextureWrapMode::Repeat);
}
else
{
this->Storage->Texture->SetWrapMode(vtkTexture::VTKTextureWrapMode::ClampToEdge);
}
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
......
...@@ -35,9 +35,8 @@ vtkAbstractObjectFactoryNewMacro(vtkTexture) ...@@ -35,9 +35,8 @@ vtkAbstractObjectFactoryNewMacro(vtkTexture)
// Construct object and initialize. // Construct object and initialize.
vtkTexture::vtkTexture() vtkTexture::vtkTexture()
{ {
this->Repeat = 1; this->WrapMode = VTKTextureWrapMode::Repeat;
this->Interpolate = 0; this->Interpolate = 0;
this->EdgeClamp = 0;
this->Quality = VTK_TEXTURE_QUALITY_DEFAULT; this->Quality = VTK_TEXTURE_QUALITY_DEFAULT;
this->PremultipliedAlpha = false; this->PremultipliedAlpha = false;
...@@ -117,8 +116,7 @@ void vtkTexture::PrintSelf(ostream& os, vtkIndent indent) ...@@ -117,8 +116,7 @@ void vtkTexture::PrintSelf(ostream& os, vtkIndent indent)
this->Superclass::PrintSelf(os,indent); this->Superclass::PrintSelf(os,indent);
os << indent << "Interpolate: " << (this->Interpolate ? "On\n" : "Off\n"); os << indent << "Interpolate: " << (this->Interpolate ? "On\n" : "Off\n");
os << indent << "Repeat: " << (this->Repeat ? "On\n" : "Off\n"); os << indent << "Wrap Mode: " << this->WrapMode << "\n";
os << indent << "EdgeClamp: " << (this->EdgeClamp ? "On\n" : "Off\n");
os << indent << "Quality: "; os << indent << "Quality: ";
switch (this->Quality) switch (this->Quality)
{ {
......
...@@ -90,18 +90,15 @@ public: ...@@ -90,18 +90,15 @@ public:
// Description: // Description:
// Turn on/off the repetition of the texture map when the texture // Turn on/off the repetition of the texture map when the texture
// coords extend beyond the [0,1] range. // coords extend beyond the [0,1] range.
vtkGetMacro(Repeat, int); enum VTKTextureWrapMode
vtkSetMacro(Repeat, int); {
vtkBooleanMacro(Repeat, int); ClampToEdge=0,
Repeat,
// Description: MirroredRepeat,
// Turn on/off the clamping of the texture map when the texture ClampToBorder
// coords extend beyond the [0,1] range. };
// Only used when Repeat is off, and edge clamping is supported by vtkGetMacro(WrapMode, VTKTextureWrapMode);
// the graphics card. vtkSetMacro(WrapMode, VTKTextureWrapMode);
vtkGetMacro(EdgeClamp, int);
vtkSetMacro(EdgeClamp, int);
vtkBooleanMacro(EdgeClamp, int);
// Description: // Description:
// Turn on/off linear interpolation of the texture map when rendering. // Turn on/off linear interpolation of the texture map when rendering.
...@@ -214,8 +211,7 @@ protected: ...@@ -214,8 +211,7 @@ protected:
{ {
} }
int Repeat; VTKTextureWrapMode WrapMode;
int EdgeClamp;
int Interpolate; int Interpolate;
int Quality; int Quality;
int MapColorScalarsThroughLookupTable; int MapColorScalarsThroughLookupTable;
......
...@@ -799,7 +799,7 @@ void vtkCompositePolyDataMapper2::AppendOneBufferObject( ...@@ -799,7 +799,7 @@ void vtkCompositePolyDataMapper2::AppendOneBufferObject(
if (this->InternalColorTexture == 0) if (this->InternalColorTexture == 0)
{ {
this->InternalColorTexture = vtkOpenGLTexture::New(); this->InternalColorTexture = vtkOpenGLTexture::New();
this->InternalColorTexture->RepeatOff(); this->InternalColorTexture->SetWrapMode(vtkTexture::VTKTextureWrapMode::ClampToEdge);
} }
this->InternalColorTexture->SetInputData(this->ColorTextureMap); this->InternalColorTexture->SetInputData(this->ColorTextureMap);
} }
......
...@@ -70,7 +70,7 @@ vtkOpenGLImageMapper::vtkOpenGLImageMapper() ...@@ -70,7 +70,7 @@ vtkOpenGLImageMapper::vtkOpenGLImageMapper()
this->Actor->SetMapper(mapper.Get()); this->Actor->SetMapper(mapper.Get());
vtkNew<vtkTexture> texture; vtkNew<vtkTexture> texture;
texture->RepeatOff(); texture->SetWrapMode(vtkTexture::VTKTextureWrapMode::ClampToEdge);
this->Actor->SetTexture(texture.Get()); this->Actor->SetTexture(texture.Get());
vtkNew<vtkFloatArray> tcoords; vtkNew<vtkFloatArray> tcoords;
......
...@@ -79,7 +79,7 @@ vtkOpenGLImageSliceMapper::vtkOpenGLImageSliceMapper() ...@@ -79,7 +79,7 @@ vtkOpenGLImageSliceMapper::vtkOpenGLImageSliceMapper()
this->PolyDataActor = vtkActor::New(); this->PolyDataActor = vtkActor::New();
this->PolyDataActor->SetMapper(polyDataMapper.Get()); this->PolyDataActor->SetMapper(polyDataMapper.Get());
vtkNew<vtkTexture> texture; vtkNew<vtkTexture> texture;
texture->RepeatOff(); texture->SetWrapMode(vtkTexture::VTKTextureWrapMode::ClampToEdge);
this->PolyDataActor->SetTexture(texture.Get()); this->PolyDataActor->SetTexture(texture.Get());
} }
...@@ -336,11 +336,11 @@ void vtkOpenGLImageSliceMapper::RenderTexturedPolygon( ...@@ -336,11 +336,11 @@ void vtkOpenGLImageSliceMapper::RenderTexturedPolygon(
if (this->UseClampToEdge) if (this->UseClampToEdge)
{ {
this->PolyDataActor->GetTexture()->EdgeClampOn(); this->PolyDataActor->GetTexture()->SetWrapMode(vtkTexture::VTKTextureWrapMode::ClampToEdge);
} }
else else
{ {
this->PolyDataActor->GetTexture()->EdgeClampOff(); this->PolyDataActor->GetTexture()->SetWrapMode(vtkTexture::VTKTextureWrapMode::Repeat);
} }
// modify the load time to the current time // modify the load time to the current time
......
...@@ -2970,7 +2970,7 @@ void vtkOpenGLPolyDataMapper::BuildBufferObjects(vtkRenderer *ren, vtkActor *act ...@@ -2970,7 +2970,7 @@ void vtkOpenGLPolyDataMapper::BuildBufferObjects(vtkRenderer *ren, vtkActor *act
if (this->InternalColorTexture == 0) if (this->InternalColorTexture == 0)
{ {
this->InternalColorTexture = vtkOpenGLTexture::New(); this->InternalColorTexture = vtkOpenGLTexture::New();
this->InternalColorTexture->RepeatOff(); this->InternalColorTexture->SetWrapMode(vtkTexture::VTKTextureWrapMode::ClampToEdge);
} }
this->InternalColorTexture->SetInputData(this->ColorTextureMap); this->InternalColorTexture->SetInputData(this->ColorTextureMap);
} }
......
...@@ -276,17 +276,28 @@ void vtkOpenGLTexture::Load(vtkRenderer *ren) ...@@ -276,17 +276,28 @@ void vtkOpenGLTexture::Load(vtkRenderer *ren)
this->TextureObject->SetMinificationFilter(vtkTextureObject::Nearest); this->TextureObject->SetMinificationFilter(vtkTextureObject::Nearest);
this->TextureObject->SetMagnificationFilter(vtkTextureObject::Nearest); this->TextureObject->SetMagnificationFilter(vtkTextureObject::Nearest);
} }
if (this->Repeat) switch(this->GetWrapMode())
{ {
this->TextureObject->SetWrapS(vtkTextureObject::Repeat); case VTKTextureWrapMode::Repeat:
this->TextureObject->SetWrapT(vtkTextureObject::Repeat); this->TextureObject->SetWrapS(vtkTextureObject::Repeat);
this->TextureObject->SetWrapR(vtkTextureObject::Repeat); this->TextureObject->SetWrapT(vtkTextureObject::Repeat);
} this->TextureObject->SetWrapR(vtkTextureObject::Repeat);
else break;
{ case VTKTextureWrapMode::MirroredRepeat:
this->TextureObject->SetWrapS(vtkTextureObject::ClampToEdge); this->TextureObject->SetWrapS(vtkTextureObject::MirroredRepeat);
this->TextureObject->SetWrapT(vtkTextureObject::ClampToEdge); this->TextureObject->SetWrapT(vtkTextureObject::MirroredRepeat);
this->TextureObject->SetWrapR(vtkTextureObject::ClampToEdge); this->TextureObject->SetWrapR(vtkTextureObject::MirroredRepeat);
break;
case VTKTextureWrapMode::ClampToEdge:
this->TextureObject->SetWrapS(vtkTextureObject::ClampToEdge);
this->TextureObject->SetWrapT(vtkTextureObject::ClampToEdge);
this->TextureObject->SetWrapR(vtkTextureObject::ClampToEdge);
break;
case VTKTextureWrapMode::ClampToBorder:
this->TextureObject->SetWrapS(vtkTextureObject::ClampToBorder);
this->TextureObject->SetWrapT(vtkTextureObject::ClampToBorder);
this->TextureObject->SetWrapR(vtkTextureObject::ClampToBorder);
break;
} }
// modify the load time to the current time // modify the load time to the current time
......
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