Game Development Community

Bug in GBitmap::sampleTexel

by John Carroll · in Torque Game Engine Advanced · 06/01/2007 (10:22 am) · 0 replies

Hi,
I've found a bug in GBitmap::sampleTexel. The problem was that this function didn't take into account that values in a bitmap might be in RGB order, rather than BGR order. I've reworked this function and it now looks like this:
ColorF GBitmap::sampleTexel(F32 u, F32 v)
{
	ColorI iColor;
	
        // normally sampling wraps all the way around at 1.0,
	// but locking doesn't support this, and we seem to calc
	// the uv based on a clamped 0 - 1...

	Point2F max(F32(getWidth()-1), F32(getHeight()-1));
	Point2F posf;

	getColor(mClampF(((u) * max.x), 0.0, max.x), mClampF(((v) * max.y), 0.0, max.y), iColor);

	return iColor;
}

About the author

Working on using Torque as an Image Generator for Tactical Simulations under laser and live fire conditions, for Law Enforcement/Military applications.