Commit 4fe9da1f authored by Jeff Baumes's avatar Jeff Baumes
Browse files

ENH: Adding edge clamping to vtkTexture. Geovis image sources now clamp to...

ENH: Adding edge clamping to vtkTexture. Geovis image sources now clamp to texture edges to eliminate seams between image patches.
parent 5cd90bc1
......@@ -33,7 +33,7 @@
#include <assert.h>
vtkCxxRevisionMacro(vtkGeoAlignedImageSource, "1.8");
vtkCxxRevisionMacro(vtkGeoAlignedImageSource, "1.9");
vtkStandardNewMacro(vtkGeoAlignedImageSource);
vtkCxxSetObjectMacro(vtkGeoAlignedImageSource, Image, vtkImageData);
......@@ -199,6 +199,8 @@ 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();
root->SetLevel(-1);
root->SetLatitudeRange(-270, 90);
......@@ -380,6 +382,8 @@ void vtkGeoAlignedImageSource::CropImageForNode(vtkGeoImageNode* node, vtkImageD
tex->SetTransform(texTrans);
tex->SetInput(cropped);
tex->InterpolateOn();
tex->RepeatOff();
tex->EdgeClampOn();
node->SetTexture(tex);
}
......
......@@ -37,7 +37,7 @@
#include <vtksys/stl/utility>
vtkStandardNewMacro(vtkGeoFileImageSource);
vtkCxxRevisionMacro(vtkGeoFileImageSource, "1.2");
vtkCxxRevisionMacro(vtkGeoFileImageSource, "1.3");
//----------------------------------------------------------------------------
vtkGeoFileImageSource::vtkGeoFileImageSource()
{
......@@ -180,6 +180,7 @@ bool vtkGeoFileImageSource::ReadImage(int level, int id, vtkGeoImageNode* node)
texture->SetTransform(texTrans);
texture->RepeatOff();
texture->InterpolateOn();
texture->EdgeClampOn();
node->SetTexture(texture);
return true;
}
......
......@@ -31,7 +31,7 @@
#include <math.h>
#ifndef VTK_IMPLEMENT_MESA_CXX
vtkCxxRevisionMacro(vtkOpenGLTexture, "1.73");
vtkCxxRevisionMacro(vtkOpenGLTexture, "1.74");
vtkStandardNewMacro(vtkOpenGLTexture);
#endif
......@@ -351,8 +351,19 @@ void vtkOpenGLTexture::Load(vtkRenderer *ren)
}
else
{
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
vtkOpenGLExtensionManager* manager = renWin->GetExtensionManager();
if (this->EdgeClamp &&
(manager->ExtensionSupported("GL_VERSION_1_2") ||
manager->ExtensionSupported("GL_EXT_texture_edge_clamp")))
{
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, vtkgl::CLAMP_TO_EDGE );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, vtkgl::CLAMP_TO_EDGE );
}
else
{
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
}
}
int internalFormat = bytesPerPixel;
switch (bytesPerPixel)
......
......@@ -23,7 +23,7 @@
#include "vtkRenderWindow.h"
#include "vtkTransform.h"
vtkCxxRevisionMacro(vtkTexture, "1.58");
vtkCxxRevisionMacro(vtkTexture, "1.59");
vtkCxxSetObjectMacro(vtkTexture, LookupTable, vtkScalarsToColors);
//----------------------------------------------------------------------------
// Needed when we don't use the vtkStandardNewMacro.
......@@ -35,6 +35,7 @@ vtkTexture::vtkTexture()
{
this->Repeat = 1;
this->Interpolate = 0;
this->EdgeClamp = 0;
this->Quality = VTK_TEXTURE_QUALITY_DEFAULT;
this->LookupTable = NULL;
......@@ -121,6 +122,7 @@ void vtkTexture::PrintSelf(ostream& os, vtkIndent 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 << "Quality: ";
switch (this->Quality)
{
......
......@@ -87,6 +87,15 @@ public:
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);
// Description:
// Turn on/off linear interpolation of the texture map when rendering.
vtkGetMacro(Interpolate,int);
......@@ -166,6 +175,7 @@ protected:
~vtkTexture();
int Repeat;
int EdgeClamp;
int Interpolate;
int Quality;
int MapColorScalarsThroughLookupTable;
......
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