Commit 0d0a8a15 authored by Robert Menzel's avatar Robert Menzel
Browse files

added function to get the number of channels from a texture format enum

parent a729fe77
......@@ -49,7 +49,6 @@ public:
GLsizei getDepth (void) const { return depth; }
GLenum getFormat (void) const { return format; }
GLenum getType (void) const { return type; }
// ========================================================================================================= \/
// ================================================================================================= SETTERS \/
// ========================================================================================================= \/
......
......@@ -40,6 +40,30 @@ inline GLint getGLTypeSize ( GLenum _type )
return 0;
}
inline GLuint getNumberOfChannels( GLenum _format )
{
if (_format == GL_R || _format == GL_R8I || _format == GL_R16I || _format == GL_R32I
|| _format == GL_R8UI || _format == GL_R16UI || _format == GL_R32UI
|| _format == GL_R16F || _format == GL_R32F ) return 1;
if (_format == GL_RED_INTEGER || _format == GL_GREEN_INTEGER || _format == GL_BLUE_INTEGER || _format == GL_ALPHA_INTEGER) return 1;
if (_format == GL_RG || _format == GL_RG8I || _format == GL_RG16I || _format == GL_RG32I
|| _format == GL_RG8UI || _format == GL_RG16UI || _format == GL_RG32UI
|| _format == GL_RG16F || _format == GL_RG32F ) return 2;
if (_format == GL_RGB || _format == GL_RGB8I || _format == GL_RGB16I || _format == GL_RGB32I
|| _format == GL_RGB8UI || _format == GL_RGB16UI || _format == GL_RGB32UI
|| _format == GL_RGB16F || _format == GL_RGB32F ) return 3;
if (_format == GL_BGR || _format == GL_RGB_INTEGER || _format == GL_BGR_INTEGER) return 3;
if (_format == GL_RGBA || _format == GL_RGBA8I || _format == GL_RGBA16I || _format == GL_RGBA32I
|| _format == GL_RGBA8UI || _format == GL_RGBA16UI || _format == GL_RGBA32UI
|| _format == GL_RGBA16F || _format == GL_RGBA32F ) return 4;
if (_format == GL_BGRA || _format == GL_RGBA_INTEGER || _format == GL_BGRA_INTEGER) return 4;
return 1; // unknown number of channels, assume 1
}
uint32_t getOpenGLMinorVersionNumber();
uint32_t getOpenGLMajorVersionNumber();
......
......@@ -114,7 +114,7 @@ SharedTextureData Texture::getImageData(GLint _lod, GLenum _type) const
dataObject->setHeight(height);
dataObject->setDepth(depth);
dataObject->setType(_type);
dataObject->setFormat(GL_RGB);
dataObject->setFormat(mFormat);
dataObject->setData(imageData); // dataObject will take care of freeing imageData
return dataObject;
......
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