Commit ea26fe1c authored by Ken Martin's avatar Ken Martin

Fix compile issues for es2

Change-Id: I586da88a419372b04ac1c05febb25f051f7441f4
parent 6a100d34
......@@ -93,6 +93,17 @@ static const char *DepthTextureCompareFunctionAsString[8]=
"MirroredRepeat",
"ClampToBorder"
};
//----------------------------------------------------------------------------
static GLenum OpenGLAlphaInternalFormat[5]=
{
GL_ALPHA,
GL_ALPHA4,
GL_ALPHA8,
GL_ALPHA12,
GL_ALPHA16
};
#else
//--------------------------------------------------------------------------
static GLint OpenGLWrap[3]=
......@@ -109,6 +120,17 @@ static const char *DepthTextureCompareFunctionAsString[8]=
"Repeat",
"MirroredRepeat"
};
//----------------------------------------------------------------------------
static GLenum OpenGLAlphaInternalFormat[5]=
{
GL_ALPHA,
GL_ALPHA,
GL_ALPHA,
GL_ALPHA,
GL_ALPHA
};
#endif
// Mapping MinificationFilter values to OpenGL values.
......@@ -189,16 +211,6 @@ static const char *DepthInternalFormatFilterAsString[6]=
};
*/
//----------------------------------------------------------------------------
static GLenum OpenGLAlphaInternalFormat[5]=
{
GL_ALPHA,
GL_ALPHA4,
GL_ALPHA8,
GL_ALPHA12,
GL_ALPHA16
};
//----------------------------------------------------------------------------
vtkStandardNewMacro(vtkTextureObject);
......@@ -408,11 +420,13 @@ void vtkTextureObject::CreateTexture()
glTexParameteri(this->Target, GL_TEXTURE_WRAP_T,
this->GetWrapTMode(this->WrapT));
#if defined(GL_TEXTURE_3D)
if (this->Target == GL_TEXTURE_3D)
{
glTexParameteri(this->Target, GL_TEXTURE_WRAP_R,
this->GetWrapRMode(this->WrapR));
}
#endif
#ifdef GL_TEXTURE_BASE_LEVEL
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
......@@ -1236,8 +1250,10 @@ unsigned int vtkTextureObject::GetWrapSMode(int vtktype)
return GL_CLAMP_TO_EDGE;
case Repeat:
return GL_REPEAT;
#ifdef GL_CLAMP_TO_BORDER
case ClampToBorder:
return GL_CLAMP_TO_BORDER;
#endif
case MirroredRepeat:
return GL_MIRRORED_REPEAT;
default:
......@@ -1545,8 +1561,6 @@ vtkPixelBufferObject* vtkTextureObject::Download()
return pbo;
}
#endif
//----------------------------------------------------------------------------
bool vtkTextureObject::Create1DFromRaw(unsigned int width, int numComps,
int dataType, void *data)
......@@ -1589,53 +1603,6 @@ bool vtkTextureObject::Create1DFromRaw(unsigned int width, int numComps,
return true;
}
//----------------------------------------------------------------------------
bool vtkTextureObject::Create2DFromRaw(unsigned int width, unsigned int height,
int numComps, int dataType, void *data)
{
assert(this->Context);
// Now determine the texture parameters using the arguments.
this->GetDataType(dataType);
this->GetInternalFormat(dataType, numComps, false);
this->GetFormat(dataType, numComps, false);
if (!this->InternalFormat || !this->Format || !this->Type)
{
vtkErrorMacro("Failed to determine texture parameters.");
return false;
}
GLenum target = GL_TEXTURE_2D;
this->Target = target;
this->Components = numComps;
this->Width = width;
this->Height = height;
this->Depth = 1;
this->NumberOfDimensions = 2;
this->CreateTexture();
this->Bind();
// Source texture data from the PBO.
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexImage2D(
this->Target,
0,
this->InternalFormat,
static_cast<GLsizei>(this->Width),
static_cast<GLsizei>(this->Height),
0,
this->Format,
this->Type,
static_cast<const GLvoid *>(data));
vtkOpenGLCheckErrorMacro("failed at glTexImage2D");
this->UnBind();
return true;
}
//----------------------------------------------------------------------------
bool vtkTextureObject::Create3DFromRaw(unsigned int width, unsigned int height,
unsigned int depth, int numComps,
......@@ -1736,6 +1703,55 @@ bool vtkTextureObject::CreateAlphaFromRaw(unsigned int width,
return true;
}
#endif
//----------------------------------------------------------------------------
bool vtkTextureObject::Create2DFromRaw(unsigned int width, unsigned int height,
int numComps, int dataType, void *data)
{
assert(this->Context);
// Now determine the texture parameters using the arguments.
this->GetDataType(dataType);
this->GetInternalFormat(dataType, numComps, false);
this->GetFormat(dataType, numComps, false);
if (!this->InternalFormat || !this->Format || !this->Type)
{
vtkErrorMacro("Failed to determine texture parameters.");
return false;
}
GLenum target = GL_TEXTURE_2D;
this->Target = target;
this->Components = numComps;
this->Width = width;
this->Height = height;
this->Depth = 1;
this->NumberOfDimensions = 2;
this->CreateTexture();
this->Bind();
// Source texture data from the PBO.
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexImage2D(
this->Target,
0,
this->InternalFormat,
static_cast<GLsizei>(this->Width),
static_cast<GLsizei>(this->Height),
0,
this->Format,
this->Type,
static_cast<const GLvoid *>(data));
vtkOpenGLCheckErrorMacro("failed at glTexImage2D");
this->UnBind();
return true;
}
// ----------------------------------------------------------------------------
// Description:
// Create a 2D depth texture using a raw pointer.
......
......@@ -191,24 +191,12 @@ public:
vtkSetMacro(AutoParameters, int);
vtkGetMacro(AutoParameters, int);
// Description:
// Create 1D texture from client memory
bool Create1DFromRaw(unsigned int width, int numComps,
int dataType, void *data);
// Description:
// Create a 2D texture from client memory
// numComps must be in [1-4].
bool Create2DFromRaw(unsigned int width, unsigned int height,
int numComps, int dataType, void *data);
// Description:
// Create a 3D texture from client memory
// numComps must be in [1-4].
bool Create3DFromRaw(unsigned int width, unsigned int height,
unsigned int depth, int numComps,
int dataType, void *data);
// Description:
// Create a 2D depth texture using a raw pointer.
// This is a blocking call. If you can, use PBO instead.
......@@ -216,15 +204,7 @@ public:
int internalFormat, int rawType,
void *raw);
// Description:
// Create a 1D alpha texture using a raw pointer.
// This is a blocking call. If you can, use PBO instead.
bool CreateAlphaFromRaw(unsigned int width,
int internalFormat,
int rawType,
void *raw);
// PBO's are not supported in ES 2.0
// PBO's, 1D and 3D textures are not supported in ES 2.0
#if GL_ES_VERSION_2_0 != 1
// Description:
......@@ -240,6 +220,11 @@ public:
vtkPixelBufferObject *pbo,
bool shaderSupportsTextureInt);
// Description:
// Create 1D texture from client memory
bool Create1DFromRaw(unsigned int width, int numComps,
int dataType, void *data);
// Description:
// Create a 2D texture using the PBO.
// Eventually we may start supporting creating a texture from subset of data
......@@ -257,6 +242,14 @@ public:
bool Create3D(unsigned int width, unsigned int height, unsigned int depth,
int numComps, vtkPixelBufferObject *pbo,
bool shaderSupportsTextureInt);
// Description:
// Create a 3D texture from client memory
// numComps must be in [1-4].
bool Create3DFromRaw(unsigned int width, unsigned int height,
unsigned int depth, int numComps,
int dataType, void *data);
// Description:
// This is used to download raw data from the texture into a pixel bufer. The
// pixel buffer API can then be used to download the pixel buffer data to CPU
......@@ -272,6 +265,14 @@ public:
int internalFormat,
vtkPixelBufferObject *pbo);
// Description:
// Create a 1D alpha texture using a raw pointer.
// This is a blocking call. If you can, use PBO instead.
bool CreateAlphaFromRaw(unsigned int width,
int internalFormat,
int rawType,
void *raw);
#endif
// Description:
......
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