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