From f8377cf7ed66e6dda6e9b0afcd1a9b746205cbe7 Mon Sep 17 00:00:00 2001 From: castano Date: Mon, 3 Dec 2007 23:26:48 +0000 Subject: [PATCH] Remove msvc warnings. --- src/nvcore/StdStream.h | 2 +- src/nvcore/TextWriter.cpp | 2 +- src/nvimage/BlockDXT.cpp | 22 ++++++++--------- src/nvimage/Filter.cpp | 16 ++++++------- src/nvimage/FloatImage.cpp | 48 +++++++++++++++++++------------------- src/nvmath/Color.h | 2 +- src/nvmath/Eigen.cpp | 8 +++---- 7 files changed, 50 insertions(+), 50 deletions(-) diff --git a/src/nvcore/StdStream.h b/src/nvcore/StdStream.h index bf3e5b8..f10629b 100644 --- a/src/nvcore/StdStream.h +++ b/src/nvcore/StdStream.h @@ -203,7 +203,7 @@ public: virtual int tell() const { - return m_ptr - m_mem; + return int(m_ptr - m_mem); } virtual int size() const diff --git a/src/nvcore/TextWriter.cpp b/src/nvcore/TextWriter.cpp index b65a862..f5e1783 100644 --- a/src/nvcore/TextWriter.cpp +++ b/src/nvcore/TextWriter.cpp @@ -17,7 +17,7 @@ TextWriter::TextWriter(Stream * s) : void TextWriter::writeString(const char * str) { nvDebugCheck(s != NULL); - s->serialize(const_cast(str), strlen(str)); + s->serialize(const_cast(str), (int)strlen(str)); } void TextWriter::writeString(const char * str, uint len) diff --git a/src/nvimage/BlockDXT.cpp b/src/nvimage/BlockDXT.cpp index 2a38947..6e185b5 100644 --- a/src/nvimage/BlockDXT.cpp +++ b/src/nvimage/BlockDXT.cpp @@ -356,12 +356,12 @@ void AlphaBlockDXT5::evaluatePalette8(uint8 alpha[8]) const // Bit code 000 = alpha0, 001 = alpha1, others are interpolated. alpha[0] = alpha0; alpha[1] = alpha1; - alpha[2] = (6 * alpha0 + 1 * alpha1) / 7; // bit code 010 - alpha[3] = (5 * alpha0 + 2 * alpha1) / 7; // bit code 011 - alpha[4] = (4 * alpha0 + 3 * alpha1) / 7; // bit code 100 - alpha[5] = (3 * alpha0 + 4 * alpha1) / 7; // bit code 101 - alpha[6] = (2 * alpha0 + 5 * alpha1) / 7; // bit code 110 - alpha[7] = (1 * alpha0 + 6 * alpha1) / 7; // bit code 111 + 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 @@ -370,10 +370,10 @@ void AlphaBlockDXT5::evaluatePalette6(uint8 alpha[8]) const // Bit code 000 = alpha0, 001 = alpha1, others are interpolated. alpha[0] = alpha0; alpha[1] = alpha1; - alpha[2] = (4 * alpha0 + 1 * alpha1) / 5; // Bit code 010 - alpha[3] = (3 * alpha0 + 2 * alpha1) / 5; // Bit code 011 - alpha[4] = (2 * alpha0 + 3 * alpha1) / 5; // Bit code 100 - alpha[5] = (1 * alpha0 + 4 * alpha1) / 5; // Bit code 101 + 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 } @@ -403,7 +403,7 @@ uint AlphaBlockDXT5::index(uint index) const nvDebugCheck(index < 16); int offset = (3 * index + 16); - return (this->u >> offset) & 0x7; + return uint((this->u >> offset) & 0x7); } void AlphaBlockDXT5::setIndex(uint index, uint value) diff --git a/src/nvimage/Filter.cpp b/src/nvimage/Filter.cpp index 3d93a6f..c969d5e 100644 --- a/src/nvimage/Filter.cpp +++ b/src/nvimage/Filter.cpp @@ -60,13 +60,13 @@ namespace // http://en.wikipedia.org/wiki/Bessel_function inline static float bessel0(float x) { - const float EPSILON_RATIO = 1E-6; + const float EPSILON_RATIO = 1e-6f; float xh, sum, pow, ds; int k; - xh = 0.5 * x; - sum = 1.0; - pow = 1.0; + xh = 0.5f * x; + sum = 1.0f; + pow = 1.0f; k = 0; ds = 1.0; while (ds > sum * EPSILON_RATIO) { @@ -249,7 +249,7 @@ Kernel1::Kernel1(const Filter & f, int iscale, int samples/*= 32*/) const float scale = 1.0f / iscale; m_width = f.width() * iscale; - m_windowSize = ceilf(2 * m_width); + m_windowSize = (int)ceilf(2 * m_width); m_data = new float[m_windowSize]; const float offset = float(m_windowSize) / 2; @@ -523,7 +523,7 @@ PolyphaseKernel::PolyphaseKernel(const Filter & f, uint srcLength, uint dstLengt m_length = dstLength; m_width = f.width() * iscale; - m_windowSize = ceilf(m_width * 2) + 1; + m_windowSize = (int)ceilf(m_width * 2) + 1; m_data = new float[m_windowSize * m_length]; memset(m_data, 0, sizeof(float) * m_windowSize * m_length); @@ -532,8 +532,8 @@ PolyphaseKernel::PolyphaseKernel(const Filter & f, uint srcLength, uint dstLengt { const float center = (0.5f + i) * iscale; - const int left = floorf(center - m_width); - const int right = ceilf(center + m_width); + const int left = (int)floorf(center - m_width); + const int right = (int)ceilf(center + m_width); nvDebugCheck(right - left <= m_windowSize); float total = 0.0f; diff --git a/src/nvimage/FloatImage.cpp b/src/nvimage/FloatImage.cpp index fe7e578..701977f 100644 --- a/src/nvimage/FloatImage.cpp +++ b/src/nvimage/FloatImage.cpp @@ -32,7 +32,7 @@ namespace static int mirror(int x, int w) { - x = fabs(x); + x = abs(x); while (x >= w) { x = 2 * w - x - 2; } @@ -337,10 +337,10 @@ float FloatImage::sampleLinearMirror(float x, float y, int c) const const float fracX = frac(x); const float fracY = frac(y); - int ix0 = mirror(x, w); - int iy0 = mirror(y, h); - int ix1 = mirror(x + 1, w); - int iy1 = mirror(y + 1, h); + int ix0 = mirror(iround(x), w); + int iy0 = mirror(iround(y), h); + int ix1 = mirror(iround(x) + 1, w); + int iy1 = mirror(iround(y) + 1, h); float f1 = pixel(ix0, iy0, c); float f2 = pixel(ix1, iy0, c); @@ -387,9 +387,9 @@ FloatImage * FloatImage::fastDownSample() const for(uint x = 0; x < w; x++) { - const float w0 = (w - x); - const float w1 = (w - 0); - const float w2 = (1 + x); + const float w0 = float(w - x); + const float w1 = float(w - 0); + const float w2 = float(1 + x); *dst++ = scale * (w0 * src[0] + w1 * src[1] + w2 * src[2]); src += 2; @@ -450,15 +450,15 @@ FloatImage * FloatImage::fastDownSample() const for(uint y = 0; y < h; y++) { - const float v0 = (h - y); - const float v1 = (h - 0); - const float v2 = (1 + y); + const float v0 = float(h - y); + const float v1 = float(h - 0); + const float v2 = float(1 + y); for (uint x = 0; x < w; x++) { - const float w0 = (w - x); - const float w1 = (w - 0); - const float w2 = (1 + x); + const float w0 = float(w - x); + const float w1 = float(w - 0); + const float w2 = float(1 + x); float f = 0.0f; f += v0 * (w0 * src[0 * m_width + 2 * x] + w1 * src[0 * m_width + 2 * x + 1] + w2 * src[0 * m_width + 2 * x + 2]); @@ -487,9 +487,9 @@ FloatImage * FloatImage::fastDownSample() const { for (uint x = 0; x < w; x++) { - const float w0 = (w - x); - const float w1 = (w - 0); - const float w2 = (1 + x); + const float w0 = float(w - x); + const float w1 = float(w - 0); + const float w2 = float(1 + x); float f = 0.0f; f += w0 * (src[2 * x + 0] + src[m_width + 2 * x + 0]); @@ -517,9 +517,9 @@ FloatImage * FloatImage::fastDownSample() const for(uint y = 0; y < h; y++) { - const float v0 = (h - y); - const float v1 = (h - 0); - const float v2 = (1 + y); + const float v0 = float(h - y); + const float v1 = float(h - 0); + const float v2 = float(1 + y); for (uint x = 0; x < w; x++) { @@ -767,8 +767,8 @@ void FloatImage::applyKernelVertical(const PolyphaseKernel & k, int x, int c, Wr { const float center = (0.5f + i) * iscale; - const int left = floor(center - width); - const int right = ceil(center + width); + const int left = (int)floorf(center - width); + const int right = (int)ceilf(center + width); nvCheck(right - left <= windowSize); float sum = 0; @@ -799,8 +799,8 @@ void FloatImage::applyKernelHorizontal(const PolyphaseKernel & k, int y, int c, { const float center = (0.5f + i) * iscale; - const int left = floorf(center - width); - const int right = ceilf(center + width); + const int left = (int)floorf(center - width); + const int right = (int)ceilf(center + width); nvDebugCheck(right - left <= windowSize); float sum = 0; diff --git a/src/nvmath/Color.h b/src/nvmath/Color.h index b0e244b..6791975 100644 --- a/src/nvmath/Color.h +++ b/src/nvmath/Color.h @@ -18,7 +18,7 @@ public: Color64(uint16 R, uint16 G, uint16 B, uint16 A) { setRGBA(R, G, B, A); } explicit Color64(uint64 U) : u(U) { } - void setRGBA(uint8 R, uint8 G, uint8 B, uint8 A) + void setRGBA(uint16 R, uint16 G, uint16 B, uint16 A) { r = R; g = G; diff --git a/src/nvmath/Eigen.cpp b/src/nvmath/Eigen.cpp index 1ab4c55..8247918 100644 --- a/src/nvmath/Eigen.cpp +++ b/src/nvmath/Eigen.cpp @@ -276,14 +276,14 @@ void semi_definite_symmetric_eigen( delta = a_ll - a_mm; - if( delta == 0.0 ) { + if( delta == 0.0f ) { x = - PI/4 ; } else { - x = - atan( (a_lm+a_lm) / delta ) / 2.0 ; + x = - atanf( (a_lm+a_lm) / delta ) / 2.0f ; } - sinx = sin(x) ; - cosx = cos(x) ; + sinx = sinf(x); + cosx = cosf(x); sinx_2 = sinx*sinx; cosx_2 = cosx*cosx; sincos = sinx*cosx;