Commit f16f84a7 authored by Robert Menzel's avatar Robert Menzel

added texture2D direct loading function

parent bd3d17c6
/***********************************************************************
* Copyright 2011-2012 Computer Graphics Group RWTH Aachen University. *
* All rights reserved. *
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
**********************************************************************/
#pragma once
/**
* Helper function for writing the contents of a Texture object into a file
* and loading them from a file.
*/
#include <ACGL/ACGL.hh>
#include <ACGL/OpenGL/Data/TextureDataLoadStore.hh>
#include <ACGL/OpenGL/Objects/Texture.hh>
#include <string>
namespace ACGL{
namespace OpenGL{
//! loads the texture and creates mip maps
SharedTexture2D loadTexture2D( const std::string &_filename );
}
}
/***********************************************************************
* Copyright 2011-2012 Computer Graphics Group RWTH Aachen University. *
* All rights reserved. *
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
**********************************************************************/
#include <ACGL/OpenGL/Data/TextureLoadStore.hh>
using namespace ACGL;
using namespace ACGL::OpenGL;
using namespace ACGL::Utils;
namespace ACGL{
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 ) );
}
texture->generateMipmaps(); // calculates all remaining mipmap levels
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