On 9/1/2010 2:34 PM, Jos Timanta Tarigan wrote:
> well actually im dealing with colors (RGB) and it has value 0-255, and those
> value represented by unsigned char(8 bit) to be able to be placed in the GPU
> memory. the problem is available data represented in float value, 0-1, 1 is 
> the
> most value. now i need to convert this and im not pretty sure how to do it. 
> yes
> i can easily do this:
>
> int rgbValue = floor(inputDecimal * 255);
>
> but those resulting an integer value from 0-255 (which is represented as 32 
> bit)
>
>
> any idea?
>
> thanks=================================
> http://www.svnstrk.blogspot.com

Use an explicit cast - and skip the call to the math library:

red = (unsigned char)(inputDecimal * 255);

-- 
Thomas Hruska
CubicleSoft President

Barebones CMS is a high-performance, open source content management 
system for web developers operating in a team environment.

An open source CubicleSoft initiative.
Your choice of a MIT or LGPL license.

http://barebonescms.com/

Reply via email to