Commit e6ee447f authored by Robert Menzel's avatar Robert Menzel

added support for user defined internal format at image file loader

parent 87c69437
......@@ -33,7 +33,8 @@ public:
mAnisotropicFilter(0.0f),
mWrapS(0),
mWrapT(0),
mWrapR(0)
mWrapR(0),
mInternalFormat(GL_INVALID_ENUM)
{}
virtual ~TextureControlFile(void) {}
......@@ -44,6 +45,7 @@ public:
inline TextureControlFile& minFilter (GLint _minFilter) { mMinFilter = _minFilter; return *this; }
inline TextureControlFile& magFilter (GLint _magFilter) { mMagFilter = _magFilter; return *this; }
inline TextureControlFile& anisotropicFilter (GLfloat _anisotropicFilter) { mAnisotropicFilter = _anisotropicFilter; return *this; }
inline TextureControlFile& internalFormat(GLenum _internalFormat) { mInternalFormat = _internalFormat; }
inline TextureControlFile& wrap (GLenum _wrapS, GLenum _wrapT = 0, GLenum _wrapR = 0)
{
......@@ -74,6 +76,7 @@ protected:
GLenum mWrapS;
GLenum mWrapT;
GLenum mWrapR;
GLenum mInternalFormat;
};
} // OpenGL
......
......@@ -16,7 +16,8 @@ TextureControlFile::TextureControlFile(const std::string& _filename)
mAnisotropicFilter(0.0f),
mWrapS(0),
mWrapT(0),
mWrapR(0)
mWrapR(0),
mInternalFormat(GL_INVALID_ENUM)
{
if(!mDataController)
ACGL::Utils::error() << "No valid texture controller to load the image. Perhaps there is no loader for that file extension: " << _filename << std::endl;
......@@ -30,7 +31,8 @@ TextureControlFile::TextureControlFile(const char* _filename)
mAnisotropicFilter(0.0f),
mWrapS(0),
mWrapT(0),
mWrapR(0)
mWrapR(0),
mInternalFormat(GL_INVALID_ENUM)
{
if(!mDataController)
ACGL::Utils::error() << "No valid texture controller to load the image. Perhaps there is no loader for that file extension: " << _filename << std::endl;
......@@ -47,11 +49,18 @@ bool TextureControlFile::load(SharedTexture& texture)
return false;
texture->bind();
GLenum internalFormat;
if (mInternalFormat == GL_INVALID_ENUM) {
internalFormat = tempData->getFormat();
} else {
internalFormat = mInternalFormat;
}
texture->setImageData2D(
tempData->getData(),
tempData->getWidth(),
tempData->getHeight(),
tempData->getFormat(),
internalFormat,
tempData->getFormat(),
tempData->getType());
texture->generateMipmaps();
......
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