Renamed instance of variables called format to pixelFormat to make a

clearer distinction between pixelFormat and internalTextureFormat.
This commit is contained in:
Robert Osfield 2003-09-22 09:13:22 +00:00
parent 6aac0f4e95
commit c2b02608d1
2 changed files with 18 additions and 18 deletions

View File

@ -81,11 +81,11 @@ class SG_EXPORT Image : public Object
/* allocated a pixel block of specified size and type.*/ /* allocated a pixel block of specified size and type.*/
void allocateImage(int s,int t,int r, void allocateImage(int s,int t,int r,
GLenum format,GLenum type, GLenum pixelFormat,GLenum type,
int packing=1); int packing=1);
/** set the image data and format. /** set the image data and pixelFormat.
* note, when the packing value is negative (the default is -1) this method assumes * note, when the packing value is negative (the default is -1) this method assumes
* a _packing width of 1 if the width is not a multiple of 4, * a _packing width of 1 if the width is not a multiple of 4,
* otherwise automatically sets to _packing to 4. If a positive * otherwise automatically sets to _packing to 4. If a positive
@ -93,7 +93,7 @@ class SG_EXPORT Image : public Object
*/ */
void setImage(int s,int t,int r, void setImage(int s,int t,int r,
GLint internalTextureformat, GLint internalTextureformat,
GLenum format,GLenum type, GLenum pixelFormat,GLenum type,
unsigned char *data, unsigned char *data,
AllocationMode mode, AllocationMode mode,
int packing=1); int packing=1);
@ -101,10 +101,10 @@ class SG_EXPORT Image : public Object
/** readPixels from screen at specified position and size, using glReadPixels. /** readPixels from screen at specified position and size, using glReadPixels.
* Create memory for storage if required, reuse existing pixel coords if possible.*/ * Create memory for storage if required, reuse existing pixel coords if possible.*/
void readPixels(int x,int y,int width,int height, void readPixels(int x,int y,int width,int height,
GLenum format,GLenum type); GLenum pixelFormat,GLenum type);
/** read the contents of the current bound texture, handling compressed formats if present. /** read the contents of the current bound texture, handling compressed pixelFormats if present.
* Create memory for storage if required, reuse existing pixel coords if possible.*/ * Create memory for storage if required, reuse existing pixel coords if possible.*/
void readImageFromCurrentTexture(unsigned int contextID=0); void readImageFromCurrentTexture(unsigned int contextID=0);
@ -136,7 +136,7 @@ class SG_EXPORT Image : public Object
void setInternalTextureFormat(GLint internalFormat); void setInternalTextureFormat(GLint internalFormat);
inline GLint getInternalTextureFormat() const { return _internalTextureFormat; } inline GLint getInternalTextureFormat() const { return _internalTextureFormat; }
void setPixelFormat(GLenum format); void setPixelFormat(GLenum pixelFormat);
inline GLenum getPixelFormat() const { return _pixelFormat; } inline GLenum getPixelFormat() const { return _pixelFormat; }
inline GLenum getDataType() const { return _dataType; } inline GLenum getDataType() const { return _dataType; }
@ -201,9 +201,9 @@ class SG_EXPORT Image : public Object
static bool isPackedType(GLenum type); static bool isPackedType(GLenum type);
static unsigned int computeNumComponents(GLenum format); static unsigned int computeNumComponents(GLenum pixelFormat);
static unsigned int computePixelSizeInBits(GLenum format,GLenum type); static unsigned int computePixelSizeInBits(GLenum pixelFormat,GLenum type);
static unsigned int computeRowWidthInBytes(int width,GLenum format,GLenum type,int packing); static unsigned int computeRowWidthInBytes(int width,GLenum pixelFormat,GLenum type,int packing);
static int computeNearestPowerOfTwo(int s,float bias=0.5f); static int computeNearestPowerOfTwo(int s,float bias=0.5f);
// precomputed mipmaps stuff; // precomputed mipmaps stuff;

View File

@ -137,9 +137,9 @@ bool Image::isPackedType(GLenum type)
} }
} }
unsigned int Image::computeNumComponents(GLenum format) unsigned int Image::computeNumComponents(GLenum pixelFormat)
{ {
switch(format) switch(pixelFormat)
{ {
case(GL_COMPRESSED_RGB_S3TC_DXT1_EXT): return 3; case(GL_COMPRESSED_RGB_S3TC_DXT1_EXT): return 3;
case(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT): return 4; case(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT): return 4;
@ -160,7 +160,7 @@ unsigned int Image::computeNumComponents(GLenum format)
case(GL_LUMINANCE_ALPHA): return 2; case(GL_LUMINANCE_ALPHA): return 2;
default: default:
{ {
notify(WARN)<<"error format = "<<std::hex<<format<<std::endl; notify(WARN)<<"error pixelFormat = "<<std::hex<<pixelFormat<<std::endl;
return 0; return 0;
} }
} }
@ -215,9 +215,9 @@ unsigned int Image::computePixelSizeInBits(GLenum format,GLenum type)
} }
unsigned int Image::computeRowWidthInBytes(int width,GLenum format,GLenum type,int packing) unsigned int Image::computeRowWidthInBytes(int width,GLenum pixelFormat,GLenum type,int packing)
{ {
unsigned int pixelSize = computePixelSizeInBits(format,type); unsigned int pixelSize = computePixelSizeInBits(pixelFormat,type);
int widthInBits = width*pixelSize; int widthInBits = width*pixelSize;
int packingInBits = packing*8; int packingInBits = packing*8;
//notify(INFO) << "width="<<width<<" pixelSize="<<pixelSize<<" width in bit="<<widthInBits<<" packingInBits="<<packingInBits<<" widthInBits%packingInBits="<<widthInBits%packingInBits<<std::endl; //notify(INFO) << "width="<<width<<" pixelSize="<<pixelSize<<" width in bit="<<widthInBits<<" packingInBits="<<packingInBits<<" widthInBits%packingInBits="<<widthInBits%packingInBits<<std::endl;
@ -280,15 +280,15 @@ void Image::setInternalTextureFormat(GLint internalFormat)
_internalTextureFormat = internalFormat; _internalTextureFormat = internalFormat;
} }
void Image::setPixelFormat(GLenum format) void Image::setPixelFormat(GLenum pixelFormat)
{ {
if (_pixelFormat==format) return; // do nothing if the same. if (_pixelFormat==pixelFormat) return; // do nothing if the same.
if (computeNumComponents(_pixelFormat)==computeNumComponents(format)) if (computeNumComponents(_pixelFormat)==computeNumComponents(pixelFormat))
{ {
// if the two formats have the same number of componets then // if the two formats have the same number of componets then
// we can do a straight swap. // we can do a straight swap.
_pixelFormat = format; _pixelFormat = pixelFormat;
} }
else else
{ {