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