diff --git a/src/nvcore/Array.h b/src/nvcore/Array.h index 3759b6f..e01e322 100644 --- a/src/nvcore/Array.h +++ b/src/nvcore/Array.h @@ -275,12 +275,14 @@ namespace nv } /// Remove the first instance of the given element. - void remove(const T & element) + bool remove(const T & element) { - for (uint i = 0; i < m_size; i++) { - removeAt(i); - break; + uint index; + if (find(element, &index)) { + removeAt(index); + return true; } + return false; } /// Insert the given element at the given index shifting all the elements up. @@ -342,7 +344,7 @@ namespace nv } if( m_size == 0 ) { - //Allocate(0); // Don't shrink automatically. + //allocate(0); // Don't shrink automatically. } else if( m_size <= m_buffer_size/* && m_size > m_buffer_size >> 1*/) { // don't compact yet. @@ -382,7 +384,7 @@ namespace nv } if( m_size == 0 ) { - //Allocate(0); // Don't shrink automatically. + //allocate(0); // Don't shrink automatically. } else if( m_size <= m_buffer_size && m_size > m_buffer_size >> 1 ) { // don't compact yet. diff --git a/src/nvcore/Debug.cpp b/src/nvcore/Debug.cpp index b42782d..cbff8a1 100644 --- a/src/nvcore/Debug.cpp +++ b/src/nvcore/Debug.cpp @@ -48,9 +48,6 @@ # endif #endif -#include // std::runtime_error -#undef assert // defined on mingw - using namespace nv; namespace @@ -356,7 +353,7 @@ namespace if( ret == NV_ABORT_EXIT ) { // Exit cleanly. - throw std::runtime_error("Assertion failed"); + throw "Assertion failed"; } return ret; diff --git a/src/nvcore/DefsVcWin32.h b/src/nvcore/DefsVcWin32.h index a342ccc..c0e224e 100644 --- a/src/nvcore/DefsVcWin32.h +++ b/src/nvcore/DefsVcWin32.h @@ -24,7 +24,6 @@ #if _MSC_VER < 1500 # define vsnprintf _vsnprintf #endif -#define vsscanf _vsscanf #define chdir _chdir #define getcwd _getcwd diff --git a/src/nvcore/Ptr.h b/src/nvcore/Ptr.h index 2d58f28..6c5aa96 100644 --- a/src/nvcore/Ptr.h +++ b/src/nvcore/Ptr.h @@ -5,12 +5,13 @@ #include "nvcore.h" #include "Debug.h" -#include "RefCounted.h" // WeakProxy namespace nv { + class WeakProxy; + /** Simple auto pointer template class. * * This is very similar to the standard auto_ptr class, but with some @@ -273,7 +274,7 @@ namespace nv void operator=(T * p) { - if (p != NULL) { + if (p) { m_proxy = p->getWeakProxy(); nvDebugCheck(m_proxy != NULL); nvDebugCheck(m_proxy->ptr() == p); diff --git a/src/nvcore/StrLib.cpp b/src/nvcore/StrLib.cpp index 4b77fe0..76d0c71 100644 --- a/src/nvcore/StrLib.cpp +++ b/src/nvcore/StrLib.cpp @@ -9,12 +9,6 @@ #include // vsnprintf #endif -#if NV_OS_WIN32 -#define NV_PATH_SEPARATOR '\\' -#else -#define NV_PATH_SEPARATOR '/' -#endif - using namespace nv; namespace @@ -230,7 +224,7 @@ StringBuilder & StringBuilder::format( const char * fmt, ... ) va_list arg; va_start( arg, fmt ); - format( fmt, arg ); + formatList( fmt, arg ); va_end( arg ); @@ -239,7 +233,7 @@ StringBuilder & StringBuilder::format( const char * fmt, ... ) /** Format a string safely. */ -StringBuilder & StringBuilder::format( const char * fmt, va_list arg ) +StringBuilder & StringBuilder::formatList( const char * fmt, va_list arg ) { nvDebugCheck(fmt != NULL); @@ -315,14 +309,14 @@ StringBuilder & StringBuilder::append( const char * s ) /** Append a formatted string. */ -StringBuilder & StringBuilder::appendFormat( const char * format, ... ) +StringBuilder & StringBuilder::appendFormat( const char * fmt, ... ) { - nvDebugCheck( format != NULL ); + nvDebugCheck( fmt != NULL ); va_list arg; - va_start( arg, format ); + va_start( arg, fmt ); - appendFormat( format, arg ); + appendFormatList( fmt, arg ); va_end( arg ); @@ -331,16 +325,21 @@ StringBuilder & StringBuilder::appendFormat( const char * format, ... ) /** Append a formatted string. */ -StringBuilder & StringBuilder::appendFormat( const char * format, va_list arg ) +StringBuilder & StringBuilder::appendFormatList( const char * fmt, va_list arg ) { - nvDebugCheck( format != NULL ); + nvDebugCheck( fmt != NULL ); va_list tmp; va_copy(tmp, arg); - StringBuilder tmp_str; - tmp_str.format( format, tmp ); - append( tmp_str ); + if (m_size == 0) { + formatList(fmt, arg); + } + else { + StringBuilder tmp_str; + tmp_str.formatList( fmt, tmp ); + append( tmp_str ); + } va_end(tmp); @@ -459,17 +458,13 @@ const char * Path::extension() const /// Toggles path separators (ie. \\ into /). -void Path::translatePath() +void Path::translatePath(char pathSeparator /*= NV_PATH_SEPARATOR*/) { nvCheck( m_str != NULL ); - for(int i = 0; ; i++) { - if( m_str[i] == '\0' ) break; -#if NV_PATH_SEPARATOR == '/' - if( m_str[i] == '\\' ) m_str[i] = NV_PATH_SEPARATOR; -#else - if( m_str[i] == '/' ) m_str[i] = NV_PATH_SEPARATOR; -#endif + for (int i = 0; ; i++) { + if (m_str[i] == '\0') break; + if (m_str[i] == '\\' || m_str[i] == '/') m_str[i] = pathSeparator; } } @@ -501,13 +496,13 @@ void Path::stripExtension() nvCheck( m_str != NULL ); int length = (int)strlen(m_str) - 1; - while( length > 0 && m_str[length] != '.' ) { + while (length > 0 && m_str[length] != '.') { length--; if( m_str[length] == NV_PATH_SEPARATOR ) { return; // no extension } } - if( length ) { + if (length > 0) { m_str[length] = 0; } } diff --git a/src/nvcore/StrLib.h b/src/nvcore/StrLib.h index f532ac3..926c2c9 100644 --- a/src/nvcore/StrLib.h +++ b/src/nvcore/StrLib.h @@ -10,6 +10,11 @@ #include // strlen, strcmp, etc. +#if NV_OS_WIN32 +#define NV_PATH_SEPARATOR '\\' +#else +#define NV_PATH_SEPARATOR '/' +#endif namespace nv { @@ -32,6 +37,7 @@ namespace nv }; + NVCORE_API int strCaseCmp(const char * s1, const char * s2) NV_PURE; NVCORE_API int strCmp(const char * s1, const char * s2) NV_PURE; @@ -60,11 +66,11 @@ namespace nv ~StringBuilder(); StringBuilder & format( const char * format, ... ) __attribute__((format (printf, 2, 3))); - StringBuilder & format( const char * format, va_list arg ); + StringBuilder & formatList( const char * format, va_list arg ); StringBuilder & append( const char * str ); StringBuilder & appendFormat( const char * format, ... ) __attribute__((format (printf, 2, 3))); - StringBuilder & appendFormat( const char * format, va_list arg ); + StringBuilder & appendFormatList( const char * format, va_list arg ); StringBuilder & number( int i, int base = 10 ); StringBuilder & number( uint i, int base = 10 ); @@ -142,7 +148,7 @@ namespace nv const char * fileName() const; const char * extension() const; - void translatePath(); + void translatePath(char pathSeparator = NV_PATH_SEPARATOR); void stripFileName(); void stripExtension(); @@ -361,6 +367,10 @@ namespace nv }; + template <> struct Hash { + uint operator()(const String & str) const { return str.hash(); } + }; + } // nv namespace #endif // NV_CORE_STRING_H diff --git a/src/nvcore/nvcore.h b/src/nvcore/nvcore.h index 08a2d4f..f77a95a 100644 --- a/src/nvcore/nvcore.h +++ b/src/nvcore/nvcore.h @@ -37,27 +37,27 @@ #define NV_OS_STRING POSH_OS_STRING #if defined POSH_OS_LINUX -# define NV_OS_LINUX 1 -# define NV_OS_UNIX 1 +# define NV_OS_LINUX 1 +# define NV_OS_UNIX 1 #elif defined POSH_OS_FREEBSD -# define NV_OS_FREEBSD 1 -# define NV_OS_UNIX 1 +# define NV_OS_FREEBSD 1 +# define NV_OS_UNIX 1 #elif defined POSH_OS_CYGWIN32 -# define NV_OS_CYGWIN 1 +# define NV_OS_CYGWIN 1 #elif defined POSH_OS_MINGW -# define NV_OS_MINGW 1 -# define NV_OS_WIN32 1 +# define NV_OS_MINGW 1 +# define NV_OS_WIN32 1 #elif defined POSH_OS_OSX -# define NV_OS_DARWIN 1 -# define NV_OS_UNIX 1 +# define NV_OS_DARWIN 1 +# define NV_OS_UNIX 1 #elif defined POSH_OS_UNIX -# define NV_OS_UNIX 1 +# define NV_OS_UNIX 1 #elif defined POSH_OS_WIN32 -# define NV_OS_WIN32 1 +# define NV_OS_WIN32 1 #elif defined POSH_OS_WIN64 -# define NV_OS_WIN64 1 +# define NV_OS_WIN64 1 #else -# error "Unsupported OS" +# error "Unsupported OS" #endif // CPUs: @@ -151,8 +151,8 @@ /// @hideinitializer #define NV_UNUSED(a) ((a)=(a)) -/// Null index. @@ Move this somewhere else... This could have collisions with other definitions! -#define NIL uint(~0) +/// Null index. @@ Move this somewhere else... it's only used by nvmesh. +const unsigned int NIL = unsigned int(~0); /// Null pointer. #ifndef NULL diff --git a/src/nvimage/BlockDXT.cpp b/src/nvimage/BlockDXT.cpp index 8f00ac5..455a735 100644 --- a/src/nvimage/BlockDXT.cpp +++ b/src/nvimage/BlockDXT.cpp @@ -22,7 +22,6 @@ // OTHER DEALINGS IN THE SOFTWARE. #include "BlockDXT.h" - #include "ColorBlock.h" #include "nvcore/Stream.h" @@ -33,178 +32,178 @@ using namespace nv; /*---------------------------------------------------------------------------- - BlockDXT1 + BlockDXT1 ----------------------------------------------------------------------------*/ uint BlockDXT1::evaluatePalette(Color32 color_array[4]) const { - // Does bit expansion before interpolation. - color_array[0].r = (col0.r << 3) | (col0.r >> 2); - color_array[0].g = (col0.g << 2) | (col0.g >> 4); - color_array[0].b = (col0.b << 3) | (col0.b >> 2); - color_array[0].a = 0xFF; - - // @@ Same as above, but faster? -// Color32 c; -// c.u = ((col0.u << 3) & 0xf8) | ((col0.u << 5) & 0xfc00) | ((col0.u << 8) & 0xf80000); -// c.u |= (c.u >> 5) & 0x070007; -// c.u |= (c.u >> 6) & 0x000300; -// color_array[0].u = c.u; - - color_array[1].r = (col1.r << 3) | (col1.r >> 2); - color_array[1].g = (col1.g << 2) | (col1.g >> 4); - color_array[1].b = (col1.b << 3) | (col1.b >> 2); - color_array[1].a = 0xFF; - - // @@ Same as above, but faster? -// c.u = ((col1.u << 3) & 0xf8) | ((col1.u << 5) & 0xfc00) | ((col1.u << 8) & 0xf80000); -// c.u |= (c.u >> 5) & 0x070007; -// c.u |= (c.u >> 6) & 0x000300; -// color_array[1].u = c.u; - - if( col0.u > col1.u ) { - // Four-color block: derive the other two colors. - color_array[2].r = (2 * color_array[0].r + color_array[1].r) / 3; - color_array[2].g = (2 * color_array[0].g + color_array[1].g) / 3; - color_array[2].b = (2 * color_array[0].b + color_array[1].b) / 3; - color_array[2].a = 0xFF; - - color_array[3].r = (2 * color_array[1].r + color_array[0].r) / 3; - color_array[3].g = (2 * color_array[1].g + color_array[0].g) / 3; - color_array[3].b = (2 * color_array[1].b + color_array[0].b) / 3; - color_array[3].a = 0xFF; - - return 4; - } - else { - // Three-color block: derive the other color. - color_array[2].r = (color_array[0].r + color_array[1].r) / 2; - color_array[2].g = (color_array[0].g + color_array[1].g) / 2; - color_array[2].b = (color_array[0].b + color_array[1].b) / 2; - color_array[2].a = 0xFF; - - // Set all components to 0 to match DXT specs. - color_array[3].r = 0x00; // color_array[2].r; - color_array[3].g = 0x00; // color_array[2].g; - color_array[3].b = 0x00; // color_array[2].b; - color_array[3].a = 0x00; - - return 3; - } + // Does bit expansion before interpolation. + color_array[0].b = (col0.b << 3) | (col0.b >> 2); + color_array[0].g = (col0.g << 2) | (col0.g >> 4); + color_array[0].r = (col0.r << 3) | (col0.r >> 2); + color_array[0].a = 0xFF; + + // @@ Same as above, but faster? + // Color32 c; + // c.u = ((col0.u << 3) & 0xf8) | ((col0.u << 5) & 0xfc00) | ((col0.u << 8) & 0xf80000); + // c.u |= (c.u >> 5) & 0x070007; + // c.u |= (c.u >> 6) & 0x000300; + // color_array[0].u = c.u; + + color_array[1].r = (col1.r << 3) | (col1.r >> 2); + color_array[1].g = (col1.g << 2) | (col1.g >> 4); + color_array[1].b = (col1.b << 3) | (col1.b >> 2); + color_array[1].a = 0xFF; + + // @@ Same as above, but faster? + // c.u = ((col1.u << 3) & 0xf8) | ((col1.u << 5) & 0xfc00) | ((col1.u << 8) & 0xf80000); + // c.u |= (c.u >> 5) & 0x070007; + // c.u |= (c.u >> 6) & 0x000300; + // color_array[1].u = c.u; + + if( col0.u > col1.u ) { + // Four-color block: derive the other two colors. + color_array[2].r = (2 * color_array[0].r + color_array[1].r) / 3; + color_array[2].g = (2 * color_array[0].g + color_array[1].g) / 3; + color_array[2].b = (2 * color_array[0].b + color_array[1].b) / 3; + color_array[2].a = 0xFF; + + color_array[3].r = (2 * color_array[1].r + color_array[0].r) / 3; + color_array[3].g = (2 * color_array[1].g + color_array[0].g) / 3; + color_array[3].b = (2 * color_array[1].b + color_array[0].b) / 3; + color_array[3].a = 0xFF; + + return 4; + } + else { + // Three-color block: derive the other color. + color_array[2].r = (color_array[0].r + color_array[1].r) / 2; + color_array[2].g = (color_array[0].g + color_array[1].g) / 2; + color_array[2].b = (color_array[0].b + color_array[1].b) / 2; + color_array[2].a = 0xFF; + + // Set all components to 0 to match DXT specs. + color_array[3].r = 0x00; // color_array[2].r; + color_array[3].g = 0x00; // color_array[2].g; + color_array[3].b = 0x00; // color_array[2].b; + color_array[3].a = 0x00; + + return 3; + } } uint BlockDXT1::evaluatePaletteNV5x(Color32 color_array[4]) const { - // Does bit expansion before interpolation. - color_array[0].r = (3 * col0.r * 22) / 8; - color_array[0].g = (col0.g << 2) | (col0.g >> 4); - color_array[0].b = (3 * col0.b * 22) / 8; - color_array[0].a = 0xFF; - - color_array[1].r = (3 * col1.r * 22) / 8; - color_array[1].g = (col1.g << 2) | (col1.g >> 4); - color_array[1].b = (3 * col1.b * 22) / 8; - color_array[1].a = 0xFF; - - if( col0.u > col1.u ) { - // Four-color block: derive the other two colors. - color_array[2].r = (2 * col0.r + col1.r) * 22 / 8; - color_array[2].g = (256 * color_array[0].g + (color_array[1].g - color_array[0].g)/4 + 128 + (color_array[1].g - color_array[0].g) * 80) / 256; - color_array[2].b = (2 * col0.b + col1.b) * 22 / 8; - color_array[2].a = 0xFF; - - color_array[3].r = (2 * col1.r + col0.r) * 22 / 8; - color_array[3].g = (256 * color_array[1].g + (color_array[0].g - color_array[1].g)/4 + 128 + (color_array[0].g - color_array[1].g) * 80) / 256; - color_array[3].b = (2 * col1.b + col0.b) * 22 / 8; - - color_array[3].a = 0xFF; - return 4; - } - else { - // Three-color block: derive the other color. - color_array[2].r = (col0.r + col1.r) * 33 / 8; - color_array[2].g = (256 * color_array[0].g + (color_array[1].g - color_array[0].g)/4 + 128 + (color_array[1].g - color_array[0].g) * 128) / 256; - color_array[2].b = (col0.b + col1.b) * 33 / 8; - color_array[2].a = 0xFF; - - // Set all components to 0 to match DXT specs. - color_array[3].r = 0x00; // color_array[2].r; - color_array[3].g = 0x00; // color_array[2].g; - color_array[3].b = 0x00; // color_array[2].b; - color_array[3].a = 0x00; - - return 3; - } + // Does bit expansion before interpolation. + color_array[0].b = col0.b * 22 / 8; + color_array[0].g = (col0.g << 2) | (col0.g >> 4); + color_array[0].r = col0.r * 22 / 8; + color_array[0].a = 0xFF; + + color_array[1].r = col1.r * 22 / 8; + color_array[1].g = (col1.g << 2) | (col1.g >> 4); + color_array[1].b = col1.b * 22 / 8; + color_array[1].a = 0xFF; + + if( col0.u > col1.u ) { + // Four-color block: derive the other two colors. + color_array[2].r = (2 * col0.r + col1.r) * 22 / 8; + color_array[2].g = (256 * color_array[0].g + (color_array[1].g - color_array[0].g)/4 + 128 + (color_array[1].g - color_array[0].g) * 80) / 256; + color_array[2].b = (2 * col0.b + col1.b) * 22 / 8; + color_array[2].a = 0xFF; + + color_array[3].r = (2 * col1.r + col0.r) * 22 / 8; + color_array[3].g = (256 * color_array[1].g + (color_array[0].g - color_array[1].g)/4 + 128 + (color_array[0].g - color_array[1].g) * 80) / 256; + color_array[3].b = (2 * col1.b + col0.b) * 22 / 8; + color_array[3].a = 0xFF; + + return 4; + } + else { + // Three-color block: derive the other color. + color_array[2].r = (col0.r + col1.r) * 33 / 8; + color_array[2].g = (256 * color_array[0].g + (color_array[1].g - color_array[0].g)/4 + 128 + (color_array[1].g - color_array[0].g) * 128) / 256; + color_array[2].b = (col0.b + col1.b) * 33 / 8; + color_array[2].a = 0xFF; + + // Set all components to 0 to match DXT specs. + color_array[3].r = 0x00; // color_array[2].r; + color_array[3].g = 0x00; // color_array[2].g; + color_array[3].b = 0x00; // color_array[2].b; + color_array[3].a = 0x00; + + return 3; + } } // Evaluate palette assuming 3 color block. void BlockDXT1::evaluatePalette3(Color32 color_array[4]) const { - color_array[0].b = (col0.b << 3) | (col0.b >> 2); - color_array[0].g = (col0.g << 2) | (col0.g >> 4); - color_array[0].r = (col0.r << 3) | (col0.r >> 2); - color_array[0].a = 0xFF; - - color_array[1].r = (col1.r << 3) | (col1.r >> 2); - color_array[1].g = (col1.g << 2) | (col1.g >> 4); - color_array[1].b = (col1.b << 3) | (col1.b >> 2); - color_array[1].a = 0xFF; - - // Three-color block: derive the other color. - color_array[2].r = (color_array[0].r + color_array[1].r) / 2; - color_array[2].g = (color_array[0].g + color_array[1].g) / 2; - color_array[2].b = (color_array[0].b + color_array[1].b) / 2; - color_array[2].a = 0xFF; - - // Set all components to 0 to match DXT specs. - color_array[3].r = 0x00; // color_array[2].r; - color_array[3].g = 0x00; // color_array[2].g; - color_array[3].b = 0x00; // color_array[2].b; - color_array[3].a = 0x00; + color_array[0].b = (col0.b << 3) | (col0.b >> 2); + color_array[0].g = (col0.g << 2) | (col0.g >> 4); + color_array[0].r = (col0.r << 3) | (col0.r >> 2); + color_array[0].a = 0xFF; + + color_array[1].r = (col1.r << 3) | (col1.r >> 2); + color_array[1].g = (col1.g << 2) | (col1.g >> 4); + color_array[1].b = (col1.b << 3) | (col1.b >> 2); + color_array[1].a = 0xFF; + + // Three-color block: derive the other color. + color_array[2].r = (color_array[0].r + color_array[1].r) / 2; + color_array[2].g = (color_array[0].g + color_array[1].g) / 2; + color_array[2].b = (color_array[0].b + color_array[1].b) / 2; + color_array[2].a = 0xFF; + + // Set all components to 0 to match DXT specs. + color_array[3].r = 0x00; // color_array[2].r; + color_array[3].g = 0x00; // color_array[2].g; + color_array[3].b = 0x00; // color_array[2].b; + color_array[3].a = 0x00; } // Evaluate palette assuming 4 color block. void BlockDXT1::evaluatePalette4(Color32 color_array[4]) const { - color_array[0].b = (col0.b << 3) | (col0.b >> 2); - color_array[0].g = (col0.g << 2) | (col0.g >> 4); - color_array[0].r = (col0.r << 3) | (col0.r >> 2); - color_array[0].a = 0xFF; - - color_array[1].r = (col1.r << 3) | (col1.r >> 2); - color_array[1].g = (col1.g << 2) | (col1.g >> 4); - color_array[1].b = (col1.b << 3) | (col1.b >> 2); - color_array[1].a = 0xFF; - - // Four-color block: derive the other two colors. - color_array[2].r = (2 * color_array[0].r + color_array[1].r) / 3; - color_array[2].g = (2 * color_array[0].g + color_array[1].g) / 3; - color_array[2].b = (2 * color_array[0].b + color_array[1].b) / 3; - color_array[2].a = 0xFF; - - color_array[3].r = (2 * color_array[1].r + color_array[0].r) / 3; - color_array[3].g = (2 * color_array[1].g + color_array[0].g) / 3; - color_array[3].b = (2 * color_array[1].b + color_array[0].b) / 3; - color_array[3].a = 0xFF; + color_array[0].b = (col0.b << 3) | (col0.b >> 2); + color_array[0].g = (col0.g << 2) | (col0.g >> 4); + color_array[0].r = (col0.r << 3) | (col0.r >> 2); + color_array[0].a = 0xFF; + + color_array[1].r = (col1.r << 3) | (col1.r >> 2); + color_array[1].g = (col1.g << 2) | (col1.g >> 4); + color_array[1].b = (col1.b << 3) | (col1.b >> 2); + color_array[1].a = 0xFF; + + // Four-color block: derive the other two colors. + color_array[2].r = (2 * color_array[0].r + color_array[1].r) / 3; + color_array[2].g = (2 * color_array[0].g + color_array[1].g) / 3; + color_array[2].b = (2 * color_array[0].b + color_array[1].b) / 3; + color_array[2].a = 0xFF; + + color_array[3].r = (2 * color_array[1].r + color_array[0].r) / 3; + color_array[3].g = (2 * color_array[1].g + color_array[0].g) / 3; + color_array[3].b = (2 * color_array[1].b + color_array[0].b) / 3; + color_array[3].a = 0xFF; } void BlockDXT1::decodeBlock(ColorBlock * block) const { - nvDebugCheck(block != NULL); - - // Decode color block. - Color32 color_array[4]; - evaluatePalette(color_array); - - // Write color block. - for( uint j = 0; j < 4; j++ ) { - for( uint i = 0; i < 4; i++ ) { - uint idx = (row[j] >> (2 * i)) & 3; - block->color(i, j) = color_array[idx]; - } - } + nvDebugCheck(block != NULL); + + // Decode color block. + Color32 color_array[4]; + evaluatePalette(color_array); + + // Write color block. + for( uint j = 0; j < 4; j++ ) { + for( uint i = 0; i < 4; i++ ) { + uint idx = (row[j] >> (2 * i)) & 3; + block->color(i, j) = color_array[idx]; + } + } } void BlockDXT1::decodeBlockNV5x(ColorBlock * block) const @@ -224,43 +223,42 @@ void BlockDXT1::decodeBlockNV5x(ColorBlock * block) const } } - void BlockDXT1::setIndices(int * idx) { - indices = 0; - for(uint i = 0; i < 16; i++) { - indices |= (idx[i] & 3) << (2 * i); - } + indices = 0; + for(uint i = 0; i < 16; i++) { + indices |= (idx[i] & 3) << (2 * i); + } } /// Flip DXT1 block vertically. inline void BlockDXT1::flip4() { - swap(row[0], row[3]); - swap(row[1], row[2]); + swap(row[0], row[3]); + swap(row[1], row[2]); } /// Flip half DXT1 block vertically. inline void BlockDXT1::flip2() { - swap(row[0], row[1]); + swap(row[0], row[1]); } /*---------------------------------------------------------------------------- - BlockDXT3 + BlockDXT3 ----------------------------------------------------------------------------*/ void BlockDXT3::decodeBlock(ColorBlock * block) const { - nvDebugCheck(block != NULL); - - // Decode color. - color.decodeBlock(block); - - // Decode alpha. - alpha.decodeBlock(block); + nvDebugCheck(block != NULL); + + // Decode color. + color.decodeBlock(block); + + // Decode alpha. + alpha.decodeBlock(block); } void BlockDXT3::decodeBlockNV5x(ColorBlock * block) const @@ -273,184 +271,184 @@ void BlockDXT3::decodeBlockNV5x(ColorBlock * block) const void AlphaBlockDXT3::decodeBlock(ColorBlock * block) const { - nvDebugCheck(block != NULL); - - block->color(0x0).a = (alpha0 << 4) | alpha0; - block->color(0x1).a = (alpha1 << 4) | alpha1; - block->color(0x2).a = (alpha2 << 4) | alpha2; - block->color(0x3).a = (alpha3 << 4) | alpha3; - block->color(0x4).a = (alpha4 << 4) | alpha4; - block->color(0x5).a = (alpha5 << 4) | alpha5; - block->color(0x6).a = (alpha6 << 4) | alpha6; - block->color(0x7).a = (alpha7 << 4) | alpha7; - block->color(0x8).a = (alpha8 << 4) | alpha8; - block->color(0x9).a = (alpha9 << 4) | alpha9; - block->color(0xA).a = (alphaA << 4) | alphaA; - block->color(0xB).a = (alphaB << 4) | alphaB; - block->color(0xC).a = (alphaC << 4) | alphaC; - block->color(0xD).a = (alphaD << 4) | alphaD; - block->color(0xE).a = (alphaE << 4) | alphaE; - block->color(0xF).a = (alphaF << 4) | alphaF; + nvDebugCheck(block != NULL); + + block->color(0x0).a = (alpha0 << 4) | alpha0; + block->color(0x1).a = (alpha1 << 4) | alpha1; + block->color(0x2).a = (alpha2 << 4) | alpha2; + block->color(0x3).a = (alpha3 << 4) | alpha3; + block->color(0x4).a = (alpha4 << 4) | alpha4; + block->color(0x5).a = (alpha5 << 4) | alpha5; + block->color(0x6).a = (alpha6 << 4) | alpha6; + block->color(0x7).a = (alpha7 << 4) | alpha7; + block->color(0x8).a = (alpha8 << 4) | alpha8; + block->color(0x9).a = (alpha9 << 4) | alpha9; + block->color(0xA).a = (alphaA << 4) | alphaA; + block->color(0xB).a = (alphaB << 4) | alphaB; + block->color(0xC).a = (alphaC << 4) | alphaC; + block->color(0xD).a = (alphaD << 4) | alphaD; + block->color(0xE).a = (alphaE << 4) | alphaE; + block->color(0xF).a = (alphaF << 4) | alphaF; } /// Flip DXT3 alpha block vertically. void AlphaBlockDXT3::flip4() { - swap(row[0], row[3]); - swap(row[1], row[2]); + swap(row[0], row[3]); + swap(row[1], row[2]); } /// Flip half DXT3 alpha block vertically. void AlphaBlockDXT3::flip2() { - swap(row[0], row[1]); + swap(row[0], row[1]); } /// Flip DXT3 block vertically. void BlockDXT3::flip4() { - alpha.flip4(); - color.flip4(); + alpha.flip4(); + color.flip4(); } /// Flip half DXT3 block vertically. void BlockDXT3::flip2() { - alpha.flip2(); - color.flip2(); + alpha.flip2(); + color.flip2(); } /*---------------------------------------------------------------------------- - BlockDXT5 + BlockDXT5 ----------------------------------------------------------------------------*/ void AlphaBlockDXT5::evaluatePalette(uint8 alpha[8]) const { - if (alpha0 > alpha1) { - evaluatePalette8(alpha); - } - else { - evaluatePalette6(alpha); - } + if (alpha0 > alpha1) { + evaluatePalette8(alpha); + } + else { + evaluatePalette6(alpha); + } } void AlphaBlockDXT5::evaluatePalette8(uint8 alpha[8]) const { - // 8-alpha block: derive the other six alphas. - // Bit code 000 = alpha0, 001 = alpha1, others are interpolated. - alpha[0] = alpha0; - alpha[1] = alpha1; - alpha[2] = (6 * alpha[0] + 1 * alpha[1]) / 7; // bit code 010 - alpha[3] = (5 * alpha[0] + 2 * alpha[1]) / 7; // bit code 011 - alpha[4] = (4 * alpha[0] + 3 * alpha[1]) / 7; // bit code 100 - alpha[5] = (3 * alpha[0] + 4 * alpha[1]) / 7; // bit code 101 - alpha[6] = (2 * alpha[0] + 5 * alpha[1]) / 7; // bit code 110 - alpha[7] = (1 * alpha[0] + 6 * alpha[1]) / 7; // bit code 111 + // 8-alpha block: derive the other six alphas. + // Bit code 000 = alpha0, 001 = alpha1, others are interpolated. + alpha[0] = alpha0; + alpha[1] = alpha1; + alpha[2] = (6 * alpha[0] + 1 * alpha[1]) / 7; // bit code 010 + alpha[3] = (5 * alpha[0] + 2 * alpha[1]) / 7; // bit code 011 + alpha[4] = (4 * alpha[0] + 3 * alpha[1]) / 7; // bit code 100 + alpha[5] = (3 * alpha[0] + 4 * alpha[1]) / 7; // bit code 101 + alpha[6] = (2 * alpha[0] + 5 * alpha[1]) / 7; // bit code 110 + alpha[7] = (1 * alpha[0] + 6 * alpha[1]) / 7; // bit code 111 } void AlphaBlockDXT5::evaluatePalette6(uint8 alpha[8]) const { - // 6-alpha block. - // Bit code 000 = alpha0, 001 = alpha1, others are interpolated. - alpha[0] = alpha0; - alpha[1] = alpha1; - alpha[2] = (4 * alpha[0] + 1 * alpha[1]) / 5; // Bit code 010 - alpha[3] = (3 * alpha[0] + 2 * alpha[1]) / 5; // Bit code 011 - alpha[4] = (2 * alpha[0] + 3 * alpha[1]) / 5; // Bit code 100 - alpha[5] = (1 * alpha[0] + 4 * alpha[1]) / 5; // Bit code 101 - alpha[6] = 0x00; // Bit code 110 - alpha[7] = 0xFF; // Bit code 111 + // 6-alpha block. + // Bit code 000 = alpha0, 001 = alpha1, others are interpolated. + alpha[0] = alpha0; + alpha[1] = alpha1; + alpha[2] = (4 * alpha[0] + 1 * alpha[1]) / 5; // Bit code 010 + alpha[3] = (3 * alpha[0] + 2 * alpha[1]) / 5; // Bit code 011 + alpha[4] = (2 * alpha[0] + 3 * alpha[1]) / 5; // Bit code 100 + alpha[5] = (1 * alpha[0] + 4 * alpha[1]) / 5; // Bit code 101 + alpha[6] = 0x00; // Bit code 110 + alpha[7] = 0xFF; // Bit code 111 } void AlphaBlockDXT5::indices(uint8 index_array[16]) const { - index_array[0x0] = bits0; - index_array[0x1] = bits1; - index_array[0x2] = bits2; - index_array[0x3] = bits3; - index_array[0x4] = bits4; - index_array[0x5] = bits5; - index_array[0x6] = bits6; - index_array[0x7] = bits7; - index_array[0x8] = bits8; - index_array[0x9] = bits9; - index_array[0xA] = bitsA; - index_array[0xB] = bitsB; - index_array[0xC] = bitsC; - index_array[0xD] = bitsD; - index_array[0xE] = bitsE; - index_array[0xF] = bitsF; + index_array[0x0] = bits0; + index_array[0x1] = bits1; + index_array[0x2] = bits2; + index_array[0x3] = bits3; + index_array[0x4] = bits4; + index_array[0x5] = bits5; + index_array[0x6] = bits6; + index_array[0x7] = bits7; + index_array[0x8] = bits8; + index_array[0x9] = bits9; + index_array[0xA] = bitsA; + index_array[0xB] = bitsB; + index_array[0xC] = bitsC; + index_array[0xD] = bitsD; + index_array[0xE] = bitsE; + index_array[0xF] = bitsF; } uint AlphaBlockDXT5::index(uint index) const { - nvDebugCheck(index < 16); + nvDebugCheck(index < 16); - int offset = (3 * index + 16); - return uint((this->u >> offset) & 0x7); + int offset = (3 * index + 16); + return uint((this->u >> offset) & 0x7); } void AlphaBlockDXT5::setIndex(uint index, uint value) { - nvDebugCheck(index < 16); - nvDebugCheck(value < 8); + nvDebugCheck(index < 16); + nvDebugCheck(value < 8); - int offset = (3 * index + 16); - uint64 mask = uint64(0x7) << offset; - this->u = (this->u & ~mask) | (uint64(value) << offset); + int offset = (3 * index + 16); + uint64 mask = uint64(0x7) << offset; + this->u = (this->u & ~mask) | (uint64(value) << offset); } void AlphaBlockDXT5::decodeBlock(ColorBlock * block) const { - nvDebugCheck(block != NULL); - - uint8 alpha_array[8]; - evaluatePalette(alpha_array); - - uint8 index_array[16]; - indices(index_array); - - for(uint i = 0; i < 16; i++) { - block->color(i).a = alpha_array[index_array[i]]; - } + nvDebugCheck(block != NULL); + + uint8 alpha_array[8]; + evaluatePalette(alpha_array); + + uint8 index_array[16]; + indices(index_array); + + for(uint i = 0; i < 16; i++) { + block->color(i).a = alpha_array[index_array[i]]; + } } void AlphaBlockDXT5::flip4() { - uint64 * b = (uint64 *)this; - - // @@ The masks might have to be byte swapped. - uint64 tmp = (*b & POSH_U64(0x000000000000FFFF)); - tmp |= (*b & POSH_U64(0x000000000FFF0000)) << 36; - tmp |= (*b & POSH_U64(0x000000FFF0000000)) << 12; - tmp |= (*b & POSH_U64(0x000FFF0000000000)) >> 12; - tmp |= (*b & POSH_U64(0xFFF0000000000000)) >> 36; - - *b = tmp; + uint64 * b = (uint64 *)this; + + // @@ The masks might have to be byte swapped. + uint64 tmp = (*b & POSH_U64(0x000000000000FFFF)); + tmp |= (*b & POSH_U64(0x000000000FFF0000)) << 36; + tmp |= (*b & POSH_U64(0x000000FFF0000000)) << 12; + tmp |= (*b & POSH_U64(0x000FFF0000000000)) >> 12; + tmp |= (*b & POSH_U64(0xFFF0000000000000)) >> 36; + + *b = tmp; } void AlphaBlockDXT5::flip2() { - uint * b = (uint *)this; - - // @@ The masks might have to be byte swapped. - uint tmp = (*b & 0xFF000000); - tmp |= (*b & 0x00000FFF) << 12; - tmp |= (*b & 0x00FFF000) >> 12; - - *b = tmp; + uint * b = (uint *)this; + + // @@ The masks might have to be byte swapped. + uint tmp = (*b & 0xFF000000); + tmp |= (*b & 0x00000FFF) << 12; + tmp |= (*b & 0x00FFF000) >> 12; + + *b = tmp; } void BlockDXT5::decodeBlock(ColorBlock * block) const { - nvDebugCheck(block != NULL); - - // Decode color. - color.decodeBlock(block); - - // Decode alpha. - alpha.decodeBlock(block); + nvDebugCheck(block != NULL); + + // Decode color. + color.decodeBlock(block); + + // Decode alpha. + alpha.decodeBlock(block); } void BlockDXT5::decodeBlockNV5x(ColorBlock * block) const @@ -467,148 +465,148 @@ void BlockDXT5::decodeBlockNV5x(ColorBlock * block) const /// Flip DXT5 block vertically. void BlockDXT5::flip4() { - alpha.flip4(); - color.flip4(); + alpha.flip4(); + color.flip4(); } /// Flip half DXT5 block vertically. void BlockDXT5::flip2() { - alpha.flip2(); - color.flip2(); + alpha.flip2(); + color.flip2(); } /// Decode ATI1 block. void BlockATI1::decodeBlock(ColorBlock * block) const { - uint8 alpha_array[8]; - alpha.evaluatePalette(alpha_array); - - uint8 index_array[16]; - alpha.indices(index_array); - - for(uint i = 0; i < 16; i++) { - Color32 & c = block->color(i); - c.b = c.g = c.r = alpha_array[index_array[i]]; - c.a = 255; - } + uint8 alpha_array[8]; + alpha.evaluatePalette(alpha_array); + + uint8 index_array[16]; + alpha.indices(index_array); + + for(uint i = 0; i < 16; i++) { + Color32 & c = block->color(i); + c.b = c.g = c.r = alpha_array[index_array[i]]; + c.a = 255; + } } /// Flip ATI1 block vertically. void BlockATI1::flip4() { - alpha.flip4(); + alpha.flip4(); } /// Flip half ATI1 block vertically. void BlockATI1::flip2() { - alpha.flip2(); + alpha.flip2(); } /// Decode ATI2 block. void BlockATI2::decodeBlock(ColorBlock * block) const { - uint8 alpha_array[8]; - uint8 index_array[16]; - - x.evaluatePalette(alpha_array); - x.indices(index_array); - - for(uint i = 0; i < 16; i++) { - Color32 & c = block->color(i); - c.r = alpha_array[index_array[i]]; - } + uint8 alpha_array[8]; + uint8 index_array[16]; - y.evaluatePalette(alpha_array); - y.indices(index_array); - - for(uint i = 0; i < 16; i++) { - Color32 & c = block->color(i); - c.g = alpha_array[index_array[i]]; - c.b = 0; - c.a = 255; - } + x.evaluatePalette(alpha_array); + x.indices(index_array); + + for(uint i = 0; i < 16; i++) { + Color32 & c = block->color(i); + c.r = alpha_array[index_array[i]]; + } + + y.evaluatePalette(alpha_array); + y.indices(index_array); + + for(uint i = 0; i < 16; i++) { + Color32 & c = block->color(i); + c.g = alpha_array[index_array[i]]; + c.b = 0; + c.a = 255; + } } /// Flip ATI2 block vertically. void BlockATI2::flip4() { - x.flip4(); - y.flip4(); + x.flip4(); + y.flip4(); } /// Flip half ATI2 block vertically. void BlockATI2::flip2() { - x.flip2(); - y.flip2(); + x.flip2(); + y.flip2(); } void BlockCTX1::evaluatePalette(Color32 color_array[4]) const { - // Does bit expansion before interpolation. - color_array[0].b = 0x00; - color_array[0].g = col0[1]; - color_array[0].r = col0[0]; - color_array[0].a = 0xFF; - - color_array[1].r = 0x00; - color_array[1].g = col0[1]; - color_array[1].b = col1[0]; - color_array[1].a = 0xFF; - - color_array[2].r = 0x00; - color_array[2].g = (2 * color_array[0].g + color_array[1].g) / 3; - color_array[2].b = (2 * color_array[0].b + color_array[1].b) / 3; - color_array[2].a = 0xFF; - - color_array[3].r = 0x00; - color_array[3].g = (2 * color_array[1].g + color_array[0].g) / 3; - color_array[3].b = (2 * color_array[1].b + color_array[0].b) / 3; - color_array[3].a = 0xFF; + // Does bit expansion before interpolation. + color_array[0].b = 0x00; + color_array[0].g = col0[1]; + color_array[0].r = col0[0]; + color_array[0].a = 0xFF; + + color_array[1].r = 0x00; + color_array[1].g = col0[1]; + color_array[1].b = col1[0]; + color_array[1].a = 0xFF; + + color_array[2].r = 0x00; + color_array[2].g = (2 * color_array[0].g + color_array[1].g) / 3; + color_array[2].b = (2 * color_array[0].b + color_array[1].b) / 3; + color_array[2].a = 0xFF; + + color_array[3].r = 0x00; + color_array[3].g = (2 * color_array[1].g + color_array[0].g) / 3; + color_array[3].b = (2 * color_array[1].b + color_array[0].b) / 3; + color_array[3].a = 0xFF; } void BlockCTX1::decodeBlock(ColorBlock * block) const { - nvDebugCheck(block != NULL); - - // Decode color block. - Color32 color_array[4]; - evaluatePalette(color_array); - - // Write color block. - for( uint j = 0; j < 4; j++ ) { - for( uint i = 0; i < 4; i++ ) { - uint idx = (row[j] >> (2 * i)) & 3; - block->color(i, j) = color_array[idx]; - } - } + nvDebugCheck(block != NULL); + + // Decode color block. + Color32 color_array[4]; + evaluatePalette(color_array); + + // Write color block. + for( uint j = 0; j < 4; j++ ) { + for( uint i = 0; i < 4; i++ ) { + uint idx = (row[j] >> (2 * i)) & 3; + block->color(i, j) = color_array[idx]; + } + } } void BlockCTX1::setIndices(int * idx) { - indices = 0; - for(uint i = 0; i < 16; i++) { - indices |= (idx[i] & 3) << (2 * i); - } + indices = 0; + for(uint i = 0; i < 16; i++) { + indices |= (idx[i] & 3) << (2 * i); + } } /// Flip CTX1 block vertically. inline void BlockCTX1::flip4() { - swap(row[0], row[3]); - swap(row[1], row[2]); + swap(row[0], row[3]); + swap(row[1], row[2]); } /// Flip half CTX1 block vertically. inline void BlockCTX1::flip2() { - swap(row[0], row[1]); + swap(row[0], row[1]); } @@ -616,46 +614,46 @@ inline void BlockCTX1::flip2() Stream & nv::operator<<(Stream & stream, BlockDXT1 & block) { - stream << block.col0.u << block.col1.u; - stream.serialize(&block.indices, sizeof(block.indices)); - return stream; + stream << block.col0.u << block.col1.u; + stream.serialize(&block.indices, sizeof(block.indices)); + return stream; } Stream & nv::operator<<(Stream & stream, AlphaBlockDXT3 & block) { - stream.serialize(&block, sizeof(block)); - return stream; + stream.serialize(&block, sizeof(block)); + return stream; } Stream & nv::operator<<(Stream & stream, BlockDXT3 & block) { - return stream << block.alpha << block.color; + return stream << block.alpha << block.color; } Stream & nv::operator<<(Stream & stream, AlphaBlockDXT5 & block) { - stream.serialize(&block, sizeof(block)); - return stream; + stream.serialize(&block, sizeof(block)); + return stream; } Stream & nv::operator<<(Stream & stream, BlockDXT5 & block) { - return stream << block.alpha << block.color; + return stream << block.alpha << block.color; } Stream & nv::operator<<(Stream & stream, BlockATI1 & block) { - return stream << block.alpha; + return stream << block.alpha; } Stream & nv::operator<<(Stream & stream, BlockATI2 & block) { - return stream << block.x << block.y; + return stream << block.x << block.y; } Stream & nv::operator<<(Stream & stream, BlockCTX1 & block) { - stream.serialize(&block, sizeof(block)); - return stream; + stream.serialize(&block, sizeof(block)); + return stream; } diff --git a/src/nvimage/BlockDXT.h b/src/nvimage/BlockDXT.h index 1603072..80144a9 100644 --- a/src/nvimage/BlockDXT.h +++ b/src/nvimage/BlockDXT.h @@ -21,17 +21,18 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR // OTHER DEALINGS IN THE SOFTWARE. +#pragma once #ifndef NV_IMAGE_BLOCKDXT_H #define NV_IMAGE_BLOCKDXT_H -#include +#include "nvimage.h" -#include +#include "nvmath/Color.h" namespace nv { - struct ColorBlock; - class Stream; + struct ColorBlock; + class Stream; /// DXT1 block. diff --git a/src/nvimage/ColorBlock.cpp b/src/nvimage/ColorBlock.cpp index 87bda90..b6e6db9 100644 --- a/src/nvimage/ColorBlock.cpp +++ b/src/nvimage/ColorBlock.cpp @@ -161,28 +161,25 @@ bool ColorBlock::isSingleColor() const /// Returns true if the block has a single color, ignoring transparent pixels. bool ColorBlock::isSingleColorNoAlpha() const { -Color32 c; -int i; -for(i = 0; i < 16; i++) -{ -if (m_color[i].a != 0) { -c = m_color[i]; -break; -} -} + Color32 c; + int i; + for(i = 0; i < 16; i++) + { + if (m_color[i].a != 0) c = m_color[i]; + } -Color32 mask(0xFF, 0xFF, 0xFF, 0x00); -uint u = c.u & mask.u; + Color32 mask(0xFF, 0xFF, 0xFF, 0x00); + uint u = c.u & mask.u; -for(; i < 16; i++) -{ -if (u != (m_color[i].u & mask.u)) -{ -return false; -} -} + for(; i < 16; i++) + { + if (u != (m_color[i].u & mask.u)) + { + return false; + } + } -return true; + return true; } */ @@ -483,10 +480,10 @@ void FloatColorBlock::init(const Image * img, uint x, uint y) const uint bx = e % w; Color32 c = img->pixel(x+bx, y+by); Vector4 & v = color(e, i); - v.x = c.r / 255; - v.y = c.g / 255; - v.z = c.b / 255; - v.w = c.a / 255; + v.x = c.r / 255.0f; + v.y = c.g / 255.0f; + v.z = c.b / 255.0f; + v.w = c.a / 255.0f; } } } diff --git a/src/nvimage/ColorSpace.h b/src/nvimage/ColorSpace.h index 8c35760..2242a8d 100644 --- a/src/nvimage/ColorSpace.h +++ b/src/nvimage/ColorSpace.h @@ -1,5 +1,6 @@ // This code is in the public domain -- jim@tilander.org +#pragma once #ifndef NV_IMAGE_COLORSPACE_H #define NV_IMAGE_COLORSPACE_H diff --git a/src/nvimage/DirectDrawSurface.h b/src/nvimage/DirectDrawSurface.h index 4b923a7..502aa1f 100644 --- a/src/nvimage/DirectDrawSurface.h +++ b/src/nvimage/DirectDrawSurface.h @@ -25,7 +25,7 @@ #ifndef NV_IMAGE_DIRECTDRAWSURFACE_H #define NV_IMAGE_DIRECTDRAWSURFACE_H -#include +#include "nvimage.h" namespace nv { diff --git a/src/nvimage/Filter.cpp b/src/nvimage/Filter.cpp index 4538c40..21a2609 100644 --- a/src/nvimage/Filter.cpp +++ b/src/nvimage/Filter.cpp @@ -83,15 +83,15 @@ namespace /*// Alternative bessel function from Paul Heckbert. static float _bessel0(float x) { - const float EPSILON_RATIO = 1E-6; - float sum = 1.0f; - float y = x * x / 4.0f; - float t = y; - for(int i = 2; t > EPSILON_RATIO; i++) { - sum += t; - t *= y / float(i * i); - } - return sum; + const float EPSILON_RATIO = 1E-6; + float sum = 1.0f; + float y = x * x / 4.0f; + float t = y; + for(int i = 2; t > EPSILON_RATIO; i++) { + sum += t; + t *= y / float(i * i); + } + return sum; }*/ } // namespace diff --git a/src/nvimage/Image.cpp b/src/nvimage/Image.cpp index 923501c..99fcc04 100644 --- a/src/nvimage/Image.cpp +++ b/src/nvimage/Image.cpp @@ -39,6 +39,7 @@ const Image & Image::operator=(const Image & img) void Image::allocate(uint w, uint h) { + free(); m_width = w; m_height = h; m_data = (Color32 *)nv::mem::realloc(m_data, w * h * sizeof(Color32)); diff --git a/src/nvimage/NormalMap.cpp b/src/nvimage/NormalMap.cpp index 0e97afe..51967d8 100644 --- a/src/nvimage/NormalMap.cpp +++ b/src/nvimage/NormalMap.cpp @@ -21,14 +21,14 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR // OTHER DEALINGS IN THE SOFTWARE. -#include -#include -#include -#include +#include "NormalMap.h" +#include "Filter.h" +#include "FloatImage.h" +#include "Image.h" -#include +#include "nvmath/Color.h" -#include +#include "nvcore/Ptr.h" using namespace nv; diff --git a/src/nvimage/NormalMap.h b/src/nvimage/NormalMap.h index 48b2fbe..3f13d42 100644 --- a/src/nvimage/NormalMap.h +++ b/src/nvimage/NormalMap.h @@ -21,12 +21,14 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR // OTHER DEALINGS IN THE SOFTWARE. +#pragma once #ifndef NV_IMAGE_NORMALMAP_H #define NV_IMAGE_NORMALMAP_H -#include -#include -#include +#include "nvimage.h" +#include "FloatImage.h" + +#include "nvmath/Vector.h" namespace nv diff --git a/src/nvimage/PixelFormat.h b/src/nvimage/PixelFormat.h index 0106f3d..3ff5406 100644 --- a/src/nvimage/PixelFormat.h +++ b/src/nvimage/PixelFormat.h @@ -21,10 +21,11 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR // OTHER DEALINGS IN THE SOFTWARE. +#pragma once #ifndef NV_IMAGE_PIXELFORMAT_H #define NV_IMAGE_PIXELFORMAT_H -#include +#include "nvimage.h" namespace nv diff --git a/src/nvimage/PsdFile.h b/src/nvimage/PsdFile.h index 41379ed..20842dc 100644 --- a/src/nvimage/PsdFile.h +++ b/src/nvimage/PsdFile.h @@ -1,9 +1,10 @@ // This code is in the public domain -- castanyo@yahoo.es +#pragma once #ifndef NV_IMAGE_PSDFILE_H #define NV_IMAGE_PSDFILE_H -#include +#include "nvcore/Stream.h" namespace nv { diff --git a/src/nvimage/Quantize.h b/src/nvimage/Quantize.h index 5b4a955..2278d45 100644 --- a/src/nvimage/Quantize.h +++ b/src/nvimage/Quantize.h @@ -1,9 +1,10 @@ // This code is in the public domain -- castanyo@yahoo.es +#pragma once #ifndef NV_IMAGE_QUANTIZE_H #define NV_IMAGE_QUANTIZE_H -#include +#include "nvimage.h" namespace nv diff --git a/src/nvimage/TgaFile.h b/src/nvimage/TgaFile.h index bdbfce5..ed562b6 100644 --- a/src/nvimage/TgaFile.h +++ b/src/nvimage/TgaFile.h @@ -1,9 +1,10 @@ // This code is in the public domain -- castanyo@yahoo.es +#pragma once #ifndef NV_IMAGE_TGAFILE_H #define NV_IMAGE_TGAFILE_H -#include +#include "nvcore/Stream.h" namespace nv { diff --git a/src/nvimage/nvimage.h b/src/nvimage/nvimage.h index beb3965..b6001ae 100644 --- a/src/nvimage/nvimage.h +++ b/src/nvimage/nvimage.h @@ -1,5 +1,6 @@ // This code is in the public domain -- castanyo@yahoo.es +#pragma once #ifndef NV_IMAGE_H #define NV_IMAGE_H diff --git a/src/nvtt/CompressorDXT.h b/src/nvtt/CompressorDXT.h index 6e181aa..9fbf945 100644 --- a/src/nvtt/CompressorDXT.h +++ b/src/nvtt/CompressorDXT.h @@ -26,7 +26,7 @@ #include "Compressor.h" -struct Tile; +class Tile; namespace nv { diff --git a/src/nvtt/tests/imperativeapi.cpp b/src/nvtt/tests/imperativeapi.cpp index 7504798..4791e41 100644 --- a/src/nvtt/tests/imperativeapi.cpp +++ b/src/nvtt/tests/imperativeapi.cpp @@ -69,7 +69,7 @@ int main(int argc, char *argv[]) float gamma = 2.2f; image.toLinear(gamma); - float alphaRef = 0.95; + float alphaRef = 0.95f; float coverage = image.alphaTestCoverage(alphaRef); // Build mimaps.