Make IPixels single vectors in order to allow us to use their operators and other convenience functions.

This commit is contained in:
Pavel Krajcevski 2013-10-10 14:36:45 -04:00
parent 127fd7b365
commit b07fe9b670
2 changed files with 9 additions and 10 deletions

View File

@ -54,23 +54,21 @@
#define BASE_INCLUDE_IPIXEL_H_
#include "TexCompTypes.h"
#include "VectorBase.h"
namespace FasTC {
class IPixel {
private:
float m_Intensity;
class IPixel : public VectorBase<float, 1> {
public:
IPixel() : m_Intensity(0.0f) { }
IPixel(float f) : m_Intensity(f) { }
IPixel() : VectorBase<float, 1>() { vec[0] = 0.0f; }
IPixel(float f) : VectorBase<float, 1>(&f) { }
operator float() const {
return m_Intensity;
return vec[0];
}
IPixel operator=(const float &f) {
return m_Intensity = f;
return vec[0] = f;
}
// Take all of the components, transform them to their 8-bit variants,
@ -80,6 +78,7 @@ class IPixel {
uint32 Pack() const;
void Unpack(uint32 rgba);
};
REGISTER_VECTOR_TYPE(IPixel);
} // namespace FasTC

View File

@ -62,14 +62,14 @@ namespace FasTC {
uint32 IPixel::Pack() const {
uint32 ret = 0xFF << 24;
for(uint32 i = 0; i < 3; i++) {
ret |= static_cast<uint32>((255.0 * m_Intensity) + 0.5f) << i*8;
ret |= static_cast<uint32>((255.0 * vec[0]) + 0.5f) << i*8;
}
return ret;
}
void IPixel::Unpack(uint32 rgba) {
Pixel p(rgba);
m_Intensity = p.ToIntensity();
vec[0] = p.ToIntensity();
}
} // namespace FasTC