Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
Signed-off-by: Squareys <squareys@googlemail.com>
  • Loading branch information
Squareys committed Aug 23, 2019
1 parent 6783147 commit 5d5f0a0
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/MagnumExternal/BasisUniversal/CMakeLists.txt
Expand Up @@ -35,3 +35,10 @@ target_link_libraries(basisu_encoder PRIVATE basisu::transcoder)
add_library(basisu::encoder ALIAS basisu_encoder)
target_compile_definitions(basisu_encoder PUBLIC BASISU_NO_ITERATOR_DEBUG_LEVEL)

if(BUILD_STATIC_PIC)
set_target_properties(basisu_transcoder
PROPERTIES POSITION_INDEPENDENT_CODE ON)
set_target_properties(basisu_encoder
PROPERTIES POSITION_INDEPENDENT_CODE ON)
endif()

43 changes: 42 additions & 1 deletion src/MagnumPlugins/BasisImporter/BasisImporter.h
Expand Up @@ -80,6 +80,33 @@ component of the `MagnumPlugins` package and link to the `MagnumPlugins::BasisIm
target. See @ref building-plugins, @ref plugins for more information.
TODO: Anything else needed here? Example of how to config? See Assimp maybe
# Target format
Basis is a compressed format that is *transcoded* into a compressed GPU format. With
BasisImporter, this format can be chosen in different ways:
@cpp
/\* Choose Ect1 target format *\/
Containers::Pointer<AbstractImporter> importer =
manager.instantiate("BasisImporterEct1");
/\* Choose Bc5 target format *\/
Containers::Pointer<AbstractImporter> importer =
manager.instantiate("BasisImporterBc5");
@ce
If you want to be able to change the target format dynamically, you may want to
set the "format" configuration of the plugin:
@cpp
Containers::Pointer<AbstractImporter> importer =
manager.instantiate("BasisImporter");
importer->configuration().set("format", "Ect1");
@ce
If you link to the plugin you may also use @ref BasisImporter::setTargetFormat().
*/
class MAGNUM_BASISIMPORTER_EXPORT BasisImporter: public AbstractImporter {
public:
Expand All @@ -89,6 +116,20 @@ class MAGNUM_BASISIMPORTER_EXPORT BasisImporter: public AbstractImporter {
/** @brief Plugin manager constructor */
explicit BasisImporter(PluginManager::AbstractManager& manager, const std::string& plugin);

/**
* @brief Set the importers target format
* @param format The format to transcode Basis files to
*/
void setTargetFormat(BasisTranscodingType format);

/**
* @brief The importers target format
* @param format The format to transcode Basis files to
*
* See @ref basisimporter-target-format.
*/
BasisTranscodingType targetFormat();

~BasisImporter();

private:
Expand Down Expand Up @@ -118,7 +159,7 @@ template<> struct ConfigurationValue<Magnum::Trade::BasisTranscodingType> {
const Magnum::Trade::BasisTranscodingType& value,
ConfigurationValueFlags)
{
#define _c(value) case Magnum::Trade::BasisTranscodingType::##value: return #value;
#define _c(value) case Magnum::Trade::BasisTranscodingType::value: return #value;
switch(value) {
_c(Ect1)
_c(Ect2)
Expand Down
3 changes: 3 additions & 0 deletions src/MagnumPlugins/BasisImporter/Test/BasisImporterTest.cpp
Expand Up @@ -137,8 +137,11 @@ void BasisImporterTest::rgb() {

Containers::Pointer<AbstractImporter> importer = _manager.instantiate(pluginName);
CORRADE_VERIFY(importer);
CORRADE_COMPARE(importer->configuration().value<std::string>("format"),
instanceId == 0 ? "Ect1" : suffix);
CORRADE_VERIFY(importer->openFile(Utility::Directory::join(BASISIMPORTER_TEST_DIR, "rgb.basis")));


/* Verify that everything is working the same way on second use */
Containers::Optional<Trade::ImageData2D> image = importer->image2D(0);
CORRADE_VERIFY(image);
Expand Down

0 comments on commit 5d5f0a0

Please sign in to comment.