Commit ee341708 authored by Janis Born's avatar Janis Born

loadTexture2D now also loads DDS files based on file ending

parent f1e32bf8
......@@ -5,6 +5,7 @@
**********************************************************************/
#include <ACGL/OpenGL/Data/TextureLoadStore.hh>
#include <ACGL/Base/FileHelpers.hh>
using namespace ACGL;
using namespace ACGL::OpenGL;
......@@ -15,17 +16,25 @@ namespace OpenGL{
SharedTexture2D loadTexture2D( const std::string &_filename )
{
SharedTexture2D texture = SharedTexture2D( new Texture2D() );
SharedTextureData data = loadTextureData( _filename );
if (!data) {
ACGL::Utils::error() << "can't create Texture from file " << _filename << " creating small empty texture instead." << std::endl;
texture->resize( glm::uvec2(4,4) );
} else {
texture->setImageData( loadTextureData( _filename ) );
std::string fileEnding = Base::FileHelpers::getFileEnding(_filename);
if(fileEnding == "dds")
{
return loadTexture2DFromDDS(_filename);
}
texture->generateMipmaps(); // calculates all remaining mipmap levels
else
{
SharedTexture2D texture = SharedTexture2D( new Texture2D() );
SharedTextureData data = loadTextureData( _filename );
if (!data) {
ACGL::Utils::error() << "can't create Texture from file " << _filename << " creating small empty texture instead." << std::endl;
texture->resize( glm::uvec2(4,4) );
} else {
texture->setImageData( loadTextureData( _filename ) );
}
texture->generateMipmaps(); // calculates all remaining mipmap levels
return texture;
return texture;
}
}
}
......
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