Commit e25f524a authored by Ken Martin's avatar Ken Martin

Fix GLES3

The prior commit was actually built using ES2 so I did not see
these issues until I fixed that build to really use ES 3.0.

Change-Id: I80315f7c665fa43d85a08d2ed4f7f5e528c5588d
parent f91f8efd
......@@ -19,7 +19,7 @@
#include "vtkObjectFactory.h"
#if GL_ES_VERSION_2_0 != 1
#if GL_ES_VERSION_2_0 != 1 || GL_ES_VERSION_3_0 == 1
#include "vtkPixelBufferObject.h"
#endif
......@@ -1273,7 +1273,8 @@ unsigned int vtkTextureObject::GetWrapRMode(int vtktype)
return this->GetWrapSMode(vtktype);
}
#if GL_ES_VERSION_2_0 != 1 || GL_ES_VERSION_3_0 == 1
// 1D textures are not supported in ES 2.0 or 3.0
#if GL_ES_VERSION_2_0 != 1
//----------------------------------------------------------------------------
bool vtkTextureObject::Create1D(int numComps,
......@@ -1332,6 +1333,102 @@ bool vtkTextureObject::Create1D(int numComps,
return true;
}
//----------------------------------------------------------------------------
bool vtkTextureObject::Create1DFromRaw(unsigned int width, 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_1D;
this->Target = target;
this->Components = numComps;
this->Width = width;
this->Height = 1;
this->Depth = 1;
this->NumberOfDimensions = 1;
this->CreateTexture();
this->Bind();
glTexImage1D(this->Target,
0,
this->InternalFormat,
static_cast<GLsizei> (this->Width),
0,
this->Format,
this->Type,
static_cast<const GLvoid *> (data));
vtkOpenGLCheckErrorMacro("failed at glTexImage1D");
this->UnBind();
return true;
}
// ----------------------------------------------------------------------------
// Description:
// Create a 1D alpha texture using a raw pointer.
// This is a blocking call. If you can, use PBO instead.
bool vtkTextureObject::CreateAlphaFromRaw(unsigned int width,
int internalFormat,
int rawType,
void* raw)
{
assert("pre: context_exists" && this->GetContext()!=0);
assert("pre: raw_exists" && raw!=0);
assert("pre: valid_internalFormat" && internalFormat>=0
&& internalFormat<NumberOfAlphaFormats);
// Now, detemine texture parameters using the arguments.
this->GetDataType(rawType);
if (!this->InternalFormat)
{
this->InternalFormat
= OpenGLAlphaInternalFormat[internalFormat];
}
if (!this->InternalFormat || !this->Type)
{
vtkErrorMacro("Failed to detemine texture parameters.");
return false;
}
this->Target = GL_TEXTURE_1D;
this->Format = GL_ALPHA;
this->Width = width;
this->Height = 1;
this->Depth = 1;
this->NumberOfDimensions = 1;
this->Components = 1;
this->CreateTexture();
this->Bind();
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexImage1D(this->Target, 0, static_cast<GLint>(this->InternalFormat),
static_cast<GLsizei>(this->Width), 0,
this->Format, this->Type, raw);
vtkOpenGLCheckErrorMacro("failed at glTexImage1D");
this->UnBind();
return true;
}
#endif // not ES 2.0 or 3.0
#if GL_ES_VERSION_2_0 != 1 || GL_ES_VERSION_3_0 == 1
//----------------------------------------------------------------------------
bool vtkTextureObject::Create2D(unsigned int width, unsigned int height,
int numComps, vtkPixelBufferObject* pbo,
......@@ -1561,48 +1658,6 @@ vtkPixelBufferObject* vtkTextureObject::Download()
return pbo;
}
//----------------------------------------------------------------------------
bool vtkTextureObject::Create1DFromRaw(unsigned int width, 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_1D;
this->Target = target;
this->Components = numComps;
this->Width = width;
this->Height = 1;
this->Depth = 1;
this->NumberOfDimensions = 1;
this->CreateTexture();
this->Bind();
glTexImage1D(this->Target,
0,
this->InternalFormat,
static_cast<GLsizei> (this->Width),
0,
this->Format,
this->Type,
static_cast<const GLvoid *> (data));
vtkOpenGLCheckErrorMacro("failed at glTexImage1D");
this->UnBind();
return true;
}
//----------------------------------------------------------------------------
bool vtkTextureObject::Create3DFromRaw(unsigned int width, unsigned int height,
unsigned int depth, int numComps,
......@@ -1653,55 +1708,6 @@ bool vtkTextureObject::Create3DFromRaw(unsigned int width, unsigned int height,
return true;
}
// ----------------------------------------------------------------------------
// Description:
// Create a 1D alpha texture using a raw pointer.
// This is a blocking call. If you can, use PBO instead.
bool vtkTextureObject::CreateAlphaFromRaw(unsigned int width,
int internalFormat,
int rawType,
void* raw)
{
assert("pre: context_exists" && this->GetContext()!=0);
assert("pre: raw_exists" && raw!=0);
assert("pre: valid_internalFormat" && internalFormat>=0
&& internalFormat<NumberOfAlphaFormats);
// Now, detemine texture parameters using the arguments.
this->GetDataType(rawType);
if (!this->InternalFormat)
{
this->InternalFormat
= OpenGLAlphaInternalFormat[internalFormat];
}
if (!this->InternalFormat || !this->Type)
{
vtkErrorMacro("Failed to detemine texture parameters.");
return false;
}
this->Target = GL_TEXTURE_1D;
this->Format = GL_ALPHA;
this->Width = width;
this->Height = 1;
this->Depth = 1;
this->NumberOfDimensions = 1;
this->Components = 1;
this->CreateTexture();
this->Bind();
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexImage1D(this->Target, 0, static_cast<GLint>(this->InternalFormat),
static_cast<GLsizei>(this->Width), 0,
this->Format, this->Type, raw);
vtkOpenGLCheckErrorMacro("failed at glTexImage1D");
this->UnBind();
return true;
}
#endif
......
......@@ -33,7 +33,7 @@ class VertexArrayObject;
class CellBO;
}
#if GL_ES_VERSION_2_0 != 1
#if GL_ES_VERSION_2_0 != 1 || GL_ES_VERSION_3_0 == 1
class vtkPixelBufferObject;
#endif
......@@ -204,8 +204,8 @@ public:
int internalFormat, int rawType,
void *raw);
// PBO's, 1D and 3D textures are not supported in ES 2.0
#if GL_ES_VERSION_2_0 != 1 || GL_ES_VERSION_3_0 == 1
// 1D textures are not supported in ES 2.0 or 3.0
#if GL_ES_VERSION_2_0 != 1
// Description:
// Create a 1D texture using the PBO.
......@@ -224,6 +224,17 @@ public:
// Create 1D texture from client memory
bool Create1DFromRaw(unsigned int width, int numComps,
int dataType, void *data);
// 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
// PBO's, and 3D textures are not supported in ES 2.0
#if GL_ES_VERSION_2_0 != 1 || GL_ES_VERSION_3_0 == 1
// Description:
// Create a 2D texture using the PBO.
......@@ -265,14 +276,6 @@ 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