Commit 3ed3f22d authored by Aashish Chaudhary's avatar Aashish Chaudhary

Added ability to set depth mode formats

Change-Id: I805a563c8bf128409e705a3ae3a74160fb03ca8a
parent 2dfab112
......@@ -224,6 +224,7 @@ vtkTextureObject::vtkTextureObject()
this->MaxLevel = 0;
this->DepthTextureCompare = false;
this->DepthTextureCompareFunction = Lequal;
this->DepthTextureMode = DepthLuminance;
this->GenerateMipmap = false;
this->ShaderProgram = NULL;
this->BorderColor[0] = 0.0f;
......@@ -403,6 +404,12 @@ void vtkTextureObject::CreateTexture()
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
#endif
if (this->Depth)
{
glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE,
this->GetDepthTextureModeFormat(this->DepthTextureMode));
}
glBindTexture(this->Target, 0);
}
}
......@@ -933,6 +940,7 @@ unsigned int vtkTextureObject::GetInternalFormat(int vtktype, int numComps,
#endif
//----------------------------------------------------------------------------
unsigned int vtkTextureObject::GetFormat(int vtktype, int numComps,
bool shaderSupportsTextureInt)
{
......@@ -1044,6 +1052,21 @@ int vtkTextureObject::GetDataType()
return ::vtkGetVTKType(this->Type);
}
//----------------------------------------------------------------------------
unsigned int vtkTextureObject::GetDepthTextureModeFormat(int vtktype)
{
switch (vtktype)
{
case DepthAlpha:
return GL_ALPHA;
case DepthLuminance:
return GL_LUMINANCE;
case DepthIntensity:
return GL_INTENSITY;
default:
return GL_LUMINANCE;
}
}
#if GL_ES_VERSION_2_0 != 1
......
......@@ -110,6 +110,15 @@ public:
NumberOfAlphaFormats
};
// Depth mode formats
enum
{
DepthAlpha=0,
DepthLuminance,
DepthIntensity,
NumberOfDepthModeFormats
};
static vtkTextureObject* New();
vtkTypeMacro(vtkTextureObject, vtkObject);
void PrintSelf(ostream& os, vtkIndent indent);
......@@ -299,6 +308,7 @@ public:
bool shaderSupportsTextureInt);
unsigned int GetFormat(int vtktype, int numComps,
bool shaderSupportsTextureInt);
unsigned int GetDepthTextureModeFormat(int vtktype);
// Description:
// Optional, require support for floating point depth buffer
......@@ -463,6 +473,16 @@ public:
vtkGetMacro(DepthTextureCompareFunction,int);
vtkSetMacro(DepthTextureCompareFunction,int);
// Description:
// Magnification filter mode.
// Valid values are:
// - DepthAlpha
// - DepthIntensity
// - DepthLuminance
// Initial value is Luminance
vtkGetMacro(DepthTextureMode, int);
vtkSetMacro(DepthTextureMode, int);
// Description:
// Tells the hardware to generate mipmap textures from the first texture
// image at BaseLevel.
......@@ -584,6 +604,7 @@ protected:
bool DepthTextureCompare;
int DepthTextureCompareFunction;
int DepthTextureMode;
bool GenerateMipmap;
......
......@@ -1050,19 +1050,17 @@ void vtkOpenGLGPUVolumeRayCastMapper::vtkInternal::UpdateDepthTexture(
this->DepthTextureObject = vtkTextureObject::New();
this->DepthTextureObject->SetContext(vtkOpenGLRenderWindow::SafeDownCast(
ren->GetRenderWindow()));
this->DepthTextureObject->AllocateDepth(this->WindowSize[0],
this->WindowSize[1],
4);
this->DepthTextureObject->Activate();
// First set the parameters
this->DepthTextureObject->SetWrapS(vtkTextureObject::ClampToEdge);
this->DepthTextureObject->SetWrapT(vtkTextureObject::ClampToEdge);
this->DepthTextureObject->SetMagnificationFilter(vtkTextureObject::Linear);
this->DepthTextureObject->SetMinificationFilter(vtkTextureObject::Linear);
this->DepthTextureObject->AllocateDepth(this->WindowSize[0],
this->WindowSize[1],
4);
}
this->DepthTextureObject->Activate();
glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_LUMINANCE);
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0 , 0,
this->WindowLowerLeft[0], this->WindowLowerLeft[1],
this->WindowSize[0], this->WindowSize[1]);
......
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