From 213d98f985715c43c119a69e332e1f5c3e012a31 Mon Sep 17 00:00:00 2001 From: Pavel Krajcevski Date: Tue, 28 Aug 2012 19:42:28 -0400 Subject: [PATCH] Finish the hooking up of the compression library to the core library --- CLTool/CMakeLists.txt | 2 +- Core/CMakeLists.txt | 7 ++++++- Core/src/TexComp.cpp | 13 +++++++++++++ IO/src/ImageFile.cpp | 4 ++++ IO/src/ImageLoaderPNG.cpp | 3 ++- 5 files changed, 26 insertions(+), 3 deletions(-) diff --git a/CLTool/CMakeLists.txt b/CLTool/CMakeLists.txt index 9e2eeb8..22278ff 100644 --- a/CLTool/CMakeLists.txt +++ b/CLTool/CMakeLists.txt @@ -13,6 +13,6 @@ ADD_EXECUTABLE( ${SOURCES} ) +TARGET_LINK_LIBRARIES( tc BPTCEncoder ) TARGET_LINK_LIBRARIES( tc TexCompIO ) TARGET_LINK_LIBRARIES( tc TexCompCore ) -TARGET_LINK_LIBRARIES( tc BPTCEncoder ) diff --git a/Core/CMakeLists.txt b/Core/CMakeLists.txt index c17b51d..6af42b0 100644 --- a/Core/CMakeLists.txt +++ b/Core/CMakeLists.txt @@ -9,8 +9,12 @@ SET( HEADERS "include/CompressedImage.h" ) -INCLUDE_DIRECTORIES( ${TexC_BINARY_DIR}/IO/include ) +INCLUDE_DIRECTORIES( ${TexC_SOURCE_DIR}/BPTCEncoder/include ) +INCLUDE_DIRECTORIES( ${TexC_BINARY_DIR}/BPTCEncoder/include ) + INCLUDE_DIRECTORIES( ${TexC_SOURCE_DIR}/IO/include ) +INCLUDE_DIRECTORIES( ${TexC_BINARY_DIR}/IO/include ) + INCLUDE_DIRECTORIES( ${TexC_SOURCE_DIR}/Core/include ) ADD_LIBRARY( TexCompCore @@ -19,3 +23,4 @@ ADD_LIBRARY( TexCompCore ) TARGET_LINK_LIBRARIES( TexCompCore TexCompIO ) +TARGET_LINK_LIBRARIES( TexCompCore BPTCEncoder ) diff --git a/Core/src/TexComp.cpp b/Core/src/TexComp.cpp index 0f47171..99203f5 100644 --- a/Core/src/TexComp.cpp +++ b/Core/src/TexComp.cpp @@ -1,3 +1,4 @@ +#include "BC7Compressor.h" #include "TexComp.h" #include @@ -10,6 +11,18 @@ SCompressionSettings:: SCompressionSettings() {} static CompressionFunc ChooseFuncFromSettings(const SCompressionSettings &s) { + switch(s.format) { + case eCompressionFormat_BPTC: + { + if(s.bUseSIMD) { + return BC7C::CompressImageBC7SIMD; + } + else { + return BC7C::CompressImageBC7; + } + } + break; + } return NULL; } diff --git a/IO/src/ImageFile.cpp b/IO/src/ImageFile.cpp index 24bcca8..e1f3167 100644 --- a/IO/src/ImageFile.cpp +++ b/IO/src/ImageFile.cpp @@ -180,6 +180,10 @@ bool ImageFile::LoadImage(const unsigned char *rawImageData) { break; } + // Read the image data! + if(!loader->ReadData()) + return false; + m_Width = loader->GetWidth(); m_Height = loader->GetHeight(); diff --git a/IO/src/ImageLoaderPNG.cpp b/IO/src/ImageLoaderPNG.cpp index efe1f80..baedf2b 100644 --- a/IO/src/ImageLoaderPNG.cpp +++ b/IO/src/ImageLoaderPNG.cpp @@ -43,7 +43,8 @@ ImageLoaderPNG::~ImageLoaderPNG() { bool ImageLoaderPNG::ReadData() { const int kNumSigBytesToRead = 8; - if(!png_sig_cmp(m_RawData, 0, kNumSigBytesToRead)) { + const int numSigNoMatch = png_sig_cmp(m_RawData, 0, kNumSigBytesToRead); + if(numSigNoMatch) { ReportError("Incorrect PNG signature"); return false; }