Commit 34442236 authored by Philip Trettner's avatar Philip Trettner
Browse files

Merge remote-tracking branch 'origin/master'

parents e434fd23 8692c38e
......@@ -75,6 +75,19 @@ IF(ACGL_COMPILE_WITH_QT)
SET(LIBRARIES ${LIBRARIES} ${QT_LIBRARIES})
ENDIF()
# static linking for MSVC
IF(ACGL_STATIC_RUNTIME_ENV)
if(MSVC)
foreach(flag
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
if(${flag} MATCHES "/MD")
string(REGEX REPLACE "/MD" "/MT" ${flag} "${${flag}}")
endif()
endforeach()
endif()
ENDIF()
################################################################################
# Final Definition
################################################################################
......
......@@ -17,6 +17,8 @@
#include <ACGL/OpenGL/Tools.hh>
#include <string>
#include <map>
#include <vector>
namespace ACGL{
namespace OpenGL{
......@@ -25,6 +27,15 @@ namespace OpenGL{
// generic load/save
///////////////////////////////////////////////////////////////////////////////////////////////////
//! functionpointer which can be used for generic Texture loading
typedef SharedTextureData (*TextureLoadFuncPtr)(const std::string&);
//! registers a functionpointer to be used for loading specified file types (E.G. provide a load function which loads compressed)
void registerTextureLoadFunction(std::vector<std::string> _endings, TextureLoadFuncPtr _function);
//! remove a registered functionpointer (if you want to use the stock ones again
void unregisterTextureLoadFunction(TextureLoadFuncPtr _function);
//! generic load function that will use one of the loading functions below based on the file ending
SharedTextureData loadTextureData(const std::string &_filename);
......
......@@ -54,11 +54,38 @@ namespace OpenGL{
// generic load/save
///////////////////////////////////////////////////////////////////////////////////////////////////
std::map<std::string,TextureLoadFuncPtr> textureLoadFunctions = std::map<std::string,TextureLoadFuncPtr>();
void registerTextureLoadFunction(std::vector<std::string> _endings, TextureLoadFuncPtr _function)
{
if(_function != nullptr)
{
std::vector<std::string>::iterator n = _endings.end();
for(std::vector<std::string>::iterator i = _endings.begin() ; i != n ; i++ )
{
textureLoadFunctions.insert( std::pair<std::string,TextureLoadFuncPtr>(*i ,_function) );
}
}
}
void unregisterTextureLoadFunction(TextureLoadFuncPtr _function)
{
std::map<std::string,TextureLoadFuncPtr>::iterator n = textureLoadFunctions.end();
for(std::map<std::string,TextureLoadFuncPtr>::iterator i = textureLoadFunctions.begin() ; i != n ; i++)
{
if(i->second == _function)
textureLoadFunctions.erase(i);
}
}
SharedTextureData loadTextureData(const std::string &_filename)
{
// lower case file ending:
std::string fileEnding = getFileEnding( _filename );
if(textureLoadFunctions.find(fileEnding) != textureLoadFunctions.end())
return textureLoadFunctions[fileEnding](_filename);
if (fileEnding == "png") {
return loadTextureDataFromLodepng( _filename );
} else if (fileEnding == "hdr") {
......
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